Skip to content

Commit 3bbc390

Browse files
vigneshvgsjudd
authored andcommitted
avif: Use the correct bucket for GlideModule
Instead of prepending to the default prepend_all bucket, prepend the Avif integration decoders to the Bitmap bucket. Also add a configuration for decoding into a BitmapDrawable. This prevents some incorrect interactions with the Downsampler when dealing with the animated drawables (if the Avif integration is in the prepend_all bucket, it prevents GIF animations from playing back since they are returned as a BitmapDrawable as explained in issue #5051). Fixes #5051
1 parent c06a85d commit 3bbc390

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

integration/avif/src/main/java/com/bumptech/glide/integration/avif/AvifGlideModule.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
import android.content.Context;
44
import android.graphics.Bitmap;
5+
import android.graphics.drawable.BitmapDrawable;
56
import androidx.annotation.NonNull;
67
import com.bumptech.glide.Glide;
78
import com.bumptech.glide.Registry;
89
import com.bumptech.glide.annotation.GlideModule;
10+
import com.bumptech.glide.load.resource.bitmap.BitmapDrawableDecoder;
911
import com.bumptech.glide.module.LibraryGlideModule;
1012
import java.io.InputStream;
1113
import java.nio.ByteBuffer;
@@ -21,10 +23,21 @@ public void registerComponents(
2123
// the integration will be preferred for Avif images.
2224
AvifByteBufferBitmapDecoder byteBufferBitmapDecoder =
2325
new AvifByteBufferBitmapDecoder(glide.getBitmapPool());
24-
registry.prepend(ByteBuffer.class, Bitmap.class, byteBufferBitmapDecoder);
26+
registry.prepend(
27+
Registry.BUCKET_BITMAP, ByteBuffer.class, Bitmap.class, byteBufferBitmapDecoder);
28+
registry.prepend(
29+
Registry.BUCKET_BITMAP_DRAWABLE,
30+
ByteBuffer.class,
31+
BitmapDrawable.class,
32+
new BitmapDrawableDecoder<>(context.getResources(), byteBufferBitmapDecoder));
2533
AvifStreamBitmapDecoder streamBitmapDecoder =
2634
new AvifStreamBitmapDecoder(
2735
registry.getImageHeaderParsers(), byteBufferBitmapDecoder, glide.getArrayPool());
28-
registry.prepend(InputStream.class, Bitmap.class, streamBitmapDecoder);
36+
registry.prepend(Registry.BUCKET_BITMAP, InputStream.class, Bitmap.class, streamBitmapDecoder);
37+
registry.prepend(
38+
Registry.BUCKET_BITMAP_DRAWABLE,
39+
InputStream.class,
40+
BitmapDrawable.class,
41+
new BitmapDrawableDecoder<>(context.getResources(), streamBitmapDecoder));
2942
}
3043
}

0 commit comments

Comments
 (0)