use of com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool in project glide by bumptech.
the class LoadBitmapTest method loadFromRequestBuilder_asDrawable_withBitmapAndStrategyBeforeLoad_notFromCache.
@Test
public void loadFromRequestBuilder_asDrawable_withBitmapAndStrategyBeforeLoad_notFromCache() {
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical);
Glide.init(context, new GlideBuilder().setMemoryCache(new LruResourceCache(Util.getBitmapByteSize(bitmap) * 10)).setBitmapPool(new LruBitmapPool(Util.getBitmapByteSize(bitmap) * 10)));
Target<Drawable> target = concurrency.wait(GlideApp.with(context).asDrawable().diskCacheStrategy(DiskCacheStrategy.ALL).load(bitmap).centerCrop().submit(100, 100));
Glide.with(context).clear(target);
assertThat(bitmap.isRecycled()).isFalse();
concurrency.runOnMainThread(new Runnable() {
@Override
public void run() {
Glide.get(context).clearMemory();
}
});
concurrency.wait(GlideApp.with(context).load(bitmap).centerCrop().listener(drawableListener).submit(100, 100));
verify(drawableListener).onResourceReady(anyDrawable(), any(), anyDrawableTarget(), eq(DataSource.LOCAL), anyBoolean());
}
use of com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool in project glide by bumptech.
the class LoadDrawableTest method loadFromRequestManager_withBitmap_doesNotLoadFromDiskCache.
@Test
public void loadFromRequestManager_withBitmap_doesNotLoadFromDiskCache() {
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical);
BitmapDrawable drawable = new BitmapDrawable(context.getResources(), bitmap);
Glide.init(context, new GlideBuilder().setMemoryCache(new LruResourceCache(Util.getBitmapByteSize(bitmap) * 10)).setBitmapPool(new LruBitmapPool(Util.getBitmapByteSize(bitmap) * 10)));
Target<Drawable> target = concurrency.wait(GlideApp.with(context).load(drawable).centerCrop().submit(100, 100));
Glide.with(context).clear(target);
assertThat(bitmap.isRecycled()).isFalse();
concurrency.runOnMainThread(new Runnable() {
@Override
public void run() {
Glide.get(context).clearMemory();
}
});
concurrency.wait(GlideApp.with(context).load(drawable).centerCrop().listener(listener).submit(100, 100));
verify(listener).onResourceReady(anyDrawable(), any(), anyDrawableTarget(), eq(DataSource.LOCAL), anyBoolean());
}
use of com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool in project glide by bumptech.
the class LoadDrawableTest method loadFromRequestBuilder_asDrawable_withBitmapAndStrategyBeforeLoad_notFromCache.
@Test
public void loadFromRequestBuilder_asDrawable_withBitmapAndStrategyBeforeLoad_notFromCache() {
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical);
BitmapDrawable drawable = new BitmapDrawable(context.getResources(), bitmap);
Glide.init(context, new GlideBuilder().setMemoryCache(new LruResourceCache(Util.getBitmapByteSize(bitmap) * 10)).setBitmapPool(new LruBitmapPool(Util.getBitmapByteSize(bitmap) * 10)));
Target<Drawable> target = concurrency.wait(GlideApp.with(context).asDrawable().diskCacheStrategy(DiskCacheStrategy.ALL).load(drawable).centerCrop().submit(100, 100));
Glide.with(context).clear(target);
assertThat(bitmap.isRecycled()).isFalse();
concurrency.runOnMainThread(new Runnable() {
@Override
public void run() {
Glide.get(context).clearMemory();
}
});
concurrency.wait(GlideApp.with(context).load(drawable).centerCrop().listener(listener).submit(100, 100));
verify(listener).onResourceReady(anyDrawable(), any(), anyDrawableTarget(), eq(DataSource.LOCAL), anyBoolean());
}
use of com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool in project glide by bumptech.
the class LoadDrawableTest method loadFromRequestBuilder_asDrawable_withBitmap_doesNotLoadFromDiskCache.
@Test
public void loadFromRequestBuilder_asDrawable_withBitmap_doesNotLoadFromDiskCache() {
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), ResourceIds.raw.canonical);
BitmapDrawable drawable = new BitmapDrawable(context.getResources(), bitmap);
Glide.init(context, new GlideBuilder().setMemoryCache(new LruResourceCache(Util.getBitmapByteSize(bitmap) * 10)).setBitmapPool(new LruBitmapPool(Util.getBitmapByteSize(bitmap) * 10)));
Target<Drawable> target = concurrency.wait(GlideApp.with(context).asDrawable().load(drawable).centerCrop().submit(100, 100));
Glide.with(context).clear(target);
assertThat(bitmap.isRecycled()).isFalse();
concurrency.runOnMainThread(new Runnable() {
@Override
public void run() {
Glide.get(context).clearMemory();
}
});
concurrency.wait(GlideApp.with(context).load(drawable).centerCrop().listener(listener).submit(100, 100));
verify(listener).onResourceReady(anyDrawable(), any(), anyDrawableTarget(), eq(DataSource.LOCAL), anyBoolean());
}
use of com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool in project glide by bumptech.
the class WideGamutTest method load_withWideGamutImage_bitmapInPoolWithSizeAndConfig_usesBitmapFromPool.
@Test
public void load_withWideGamutImage_bitmapInPoolWithSizeAndConfig_usesBitmapFromPool() {
int bitmapDimension = 1000;
Glide.init(context, new GlideBuilder().setBitmapPool(new LruBitmapPool(bitmapDimension * bitmapDimension * 8 * 4)));
Bitmap expected = Bitmap.createBitmap(bitmapDimension, bitmapDimension, Bitmap.Config.RGBA_F16);
Glide.get(context).getBitmapPool().put(expected);
Bitmap bitmap = concurrency.get(Glide.with(context).asBitmap().load(ResourceIds.raw.webkit_logo_p3).submit());
assertThat(bitmap).isSameAs(expected);
}
Aggregations