Search in sources :

Example 1 with LruArrayPool

use of com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool in project glide by bumptech.

the class GlideBuilder method createGlide.

Glide createGlide(Context context) {
    if (sourceExecutor == null) {
        sourceExecutor = GlideExecutor.newSourceExecutor();
    }
    if (diskCacheExecutor == null) {
        diskCacheExecutor = GlideExecutor.newDiskCacheExecutor();
    }
    if (memorySizeCalculator == null) {
        memorySizeCalculator = new MemorySizeCalculator.Builder(context).build();
    }
    if (connectivityMonitorFactory == null) {
        connectivityMonitorFactory = new DefaultConnectivityMonitorFactory();
    }
    if (bitmapPool == null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            int size = memorySizeCalculator.getBitmapPoolSize();
            bitmapPool = new LruBitmapPool(size);
        } else {
            bitmapPool = new BitmapPoolAdapter();
        }
    }
    if (arrayPool == null) {
        arrayPool = new LruArrayPool(memorySizeCalculator.getArrayPoolSizeInBytes());
    }
    if (memoryCache == null) {
        memoryCache = new LruResourceCache(memorySizeCalculator.getMemoryCacheSize());
    }
    if (diskCacheFactory == null) {
        diskCacheFactory = new InternalCacheDiskCacheFactory(context);
    }
    if (engine == null) {
        engine = new Engine(memoryCache, diskCacheFactory, diskCacheExecutor, sourceExecutor, GlideExecutor.newUnlimitedSourceExecutor());
    }
    return new Glide(context, engine, memoryCache, bitmapPool, arrayPool, connectivityMonitorFactory, logLevel, defaultRequestOptions.lock());
}
Also used : LruArrayPool(com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool) DefaultConnectivityMonitorFactory(com.bumptech.glide.manager.DefaultConnectivityMonitorFactory) LruBitmapPool(com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool) LruResourceCache(com.bumptech.glide.load.engine.cache.LruResourceCache) BitmapPoolAdapter(com.bumptech.glide.load.engine.bitmap_recycle.BitmapPoolAdapter) InternalCacheDiskCacheFactory(com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory) Engine(com.bumptech.glide.load.engine.Engine)

Example 2 with LruArrayPool

use of com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool in project glide by bumptech.

the class GlideContextTest method setUp.

@Before
public void setUp() {
    Application app = RuntimeEnvironment.application;
    transitionOptions = new HashMap<>();
    context = new GlideContext(app, new LruArrayPool(), new Registry(), new ImageViewTargetFactory(), new RequestOptions(), transitionOptions, mock(Engine.class), Log.DEBUG);
}
Also used : LruArrayPool(com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool) ImageViewTargetFactory(com.bumptech.glide.request.target.ImageViewTargetFactory) RequestOptions(com.bumptech.glide.request.RequestOptions) Application(android.app.Application) Before(org.junit.Before)

Example 3 with LruArrayPool

use of com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool in project glide by bumptech.

the class ByteBufferGifDecoderTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    gifHeader = Mockito.spy(new GifHeader());
    when(parser.parseHeader()).thenReturn(gifHeader);
    when(parserPool.obtain(isA(ByteBuffer.class))).thenReturn(parser);
    when(decoderFactory.build(isA(GifDecoder.BitmapProvider.class), eq(gifHeader), isA(ByteBuffer.class), anyInt())).thenReturn(gifDecoder);
    List<ImageHeaderParser> parsers = new ArrayList<>();
    parsers.add(new DefaultImageHeaderParser());
    options = new Options();
    decoder = new ByteBufferGifDecoder(RuntimeEnvironment.application, parsers, bitmapPool, new LruArrayPool(ARRAY_POOL_SIZE_BYTES), parserPool, decoderFactory);
}
Also used : Options(com.bumptech.glide.load.Options) LruArrayPool(com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool) DefaultImageHeaderParser(com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser) ArrayList(java.util.ArrayList) GifHeader(com.bumptech.glide.gifdecoder.GifHeader) ByteBuffer(java.nio.ByteBuffer) DefaultImageHeaderParser(com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser) ImageHeaderParser(com.bumptech.glide.load.ImageHeaderParser) Before(org.junit.Before)

Example 4 with LruArrayPool

use of com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool in project glide by bumptech.

the class DownsamplerEmulatorTest method buildDownsampler.

private static Downsampler buildDownsampler() {
    List<ImageHeaderParser> parsers = Collections.<ImageHeaderParser>singletonList(new DefaultImageHeaderParser());
    DisplayMetrics displayMetrics = new DisplayMetrics();
    // XHDPI.
    displayMetrics.densityDpi = 320;
    BitmapPool bitmapPool = new BitmapPoolAdapter();
    ArrayPool arrayPool = new LruArrayPool();
    return new Downsampler(parsers, displayMetrics, bitmapPool, arrayPool);
}
Also used : LruArrayPool(com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool) ArrayPool(com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool) LruArrayPool(com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool) BitmapPoolAdapter(com.bumptech.glide.load.engine.bitmap_recycle.BitmapPoolAdapter) ImageHeaderParser(com.bumptech.glide.load.ImageHeaderParser) DisplayMetrics(android.util.DisplayMetrics) BitmapPool(com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool)

Example 5 with LruArrayPool

use of com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool in project glide by bumptech.

the class ResourceCacheKeyTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    arrayPool = new LruArrayPool();
    doAnswer(new Util.WriteDigest("transformation1")).when(transformation1).updateDiskCacheKey(any(MessageDigest.class));
    doAnswer(new Util.WriteDigest("transformation1")).when(transformation2).updateDiskCacheKey(any(MessageDigest.class));
}
Also used : LruArrayPool(com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool) Util(com.bumptech.glide.tests.Util) MessageDigest(java.security.MessageDigest) Before(org.junit.Before)

Aggregations

LruArrayPool (com.bumptech.glide.load.engine.bitmap_recycle.LruArrayPool)9 Before (org.junit.Before)6 ImageHeaderParser (com.bumptech.glide.load.ImageHeaderParser)3 Options (com.bumptech.glide.load.Options)2 BitmapPoolAdapter (com.bumptech.glide.load.engine.bitmap_recycle.BitmapPoolAdapter)2 DefaultImageHeaderParser (com.bumptech.glide.load.resource.bitmap.DefaultImageHeaderParser)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 ByteBuffer (java.nio.ByteBuffer)2 ArrayList (java.util.ArrayList)2 Application (android.app.Application)1 DisplayMetrics (android.util.DisplayMetrics)1 GifHeader (com.bumptech.glide.gifdecoder.GifHeader)1 Engine (com.bumptech.glide.load.engine.Engine)1 ArrayPool (com.bumptech.glide.load.engine.bitmap_recycle.ArrayPool)1 BitmapPool (com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool)1 LruBitmapPool (com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool)1 InternalCacheDiskCacheFactory (com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory)1 LruResourceCache (com.bumptech.glide.load.engine.cache.LruResourceCache)1 DefaultConnectivityMonitorFactory (com.bumptech.glide.manager.DefaultConnectivityMonitorFactory)1