com.facebook.imagepipeline.memory.BitmapCounter Java Examples

The following examples show how to use com.facebook.imagepipeline.memory.BitmapCounter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ImageFilter.java    From react-native-image-filter-kit with MIT License 6 votes vote down vote up
private static void ashmemInfo(@Nonnull String stateLabel) {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    BitmapCounter counter = BitmapCounterProvider.get();

    FLog.d(
      ReactConstants.TAG,
      String.format(
        Locale.ROOT,
        "ImageFilterKit: bitmap pool %s - %d/%d images, %d/%d MB",
        stateLabel,
        counter.getCount(),
        counter.getMaxCount(),
        counter.getSize() / 1024 / 1024,
        counter.getMaxSize() / 1024 / 1024
      )
    );
  }
}
 
Example #2
Source File: GingerbreadPurgeableDecoderTest.java    From fresco with MIT License 5 votes vote down vote up
@Before
public void setUp() {

  mBitmap = MockBitmapFactory.create();
  mBitmapCounter = new BitmapCounter(MAX_BITMAP_COUNT, MAX_BITMAP_SIZE);

  mockStatic(DalvikPurgeableDecoder.class);
  when(DalvikPurgeableDecoder.getBitmapFactoryOptions(anyInt(), any(Bitmap.Config.class)))
      .thenCallRealMethod();
  when(DalvikPurgeableDecoder.endsWithEOI(any(CloseableReference.class), anyInt()))
      .thenCallRealMethod();
  mockStatic(BitmapCounterProvider.class);
  when(BitmapCounterProvider.get()).thenReturn(mBitmapCounter);

  mockStatic(BitmapFactory.class);
  when(BitmapFactory.decodeFileDescriptor(
          any(FileDescriptor.class), any(Rect.class), any(BitmapFactory.Options.class)))
      .thenReturn(mBitmap);

  mInputBuf = new byte[LENGTH];
  PooledByteBuffer input = new TrivialPooledByteBuffer(mInputBuf, POINTER);
  mByteBufferRef = CloseableReference.of(input);
  mEncodedImage = new EncodedImage(mByteBufferRef);

  mDecodeBuf = new byte[LENGTH + 2];
  mDecodeBufRef = CloseableReference.of(mDecodeBuf, mock(ResourceReleaser.class));

  mockStatic(Bitmaps.class);
  mGingerbreadPurgeableDecoder = new GingerbreadPurgeableDecoder();
}
 
Example #3
Source File: KitKatPurgeableDecoderTest.java    From fresco with MIT License 5 votes vote down vote up
@Before
public void setUp() {
  mFlexByteArrayPool = mock(FlexByteArrayPool.class);

  mBitmap = MockBitmapFactory.create();
  mBitmapCounter = new BitmapCounter(MAX_BITMAP_COUNT, MAX_BITMAP_SIZE);

  mockStatic(DalvikPurgeableDecoder.class);
  when(DalvikPurgeableDecoder.getBitmapFactoryOptions(anyInt(), any(Bitmap.Config.class)))
      .thenCallRealMethod();
  when(DalvikPurgeableDecoder.endsWithEOI(any(CloseableReference.class), anyInt()))
      .thenCallRealMethod();
  mockStatic(BitmapCounterProvider.class);
  when(BitmapCounterProvider.get()).thenReturn(mBitmapCounter);

  mockStatic(BitmapFactory.class);
  when(BitmapFactory.decodeByteArray(
          any(byte[].class), anyInt(), anyInt(), any(BitmapFactory.Options.class)))
      .thenReturn(mBitmap);

  mInputBuf = new byte[LENGTH];
  PooledByteBuffer input = new TrivialPooledByteBuffer(mInputBuf, POINTER);
  mByteBufferRef = CloseableReference.of(input);
  mEncodedImage = new EncodedImage(mByteBufferRef);

  mDecodeBuf = new byte[LENGTH + 2];
  mDecodeBufRef = CloseableReference.of(mDecodeBuf, mock(ResourceReleaser.class));
  when(mFlexByteArrayPool.get(Integer.valueOf(LENGTH))).thenReturn(mDecodeBufRef);

  mockStatic(Bitmaps.class);
  mKitKatPurgeableDecoder = new KitKatPurgeableDecoder(mFlexByteArrayPool);
}