aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVignesh Venkatasubramanian <vigneshv@google.com>2023-11-06 17:16:52 -0800
committerSam <sam.a.judd@gmail.com>2023-11-09 15:27:13 -0800
commit3bbc3908edd8432f55ccfae3257bad533c1bf7d1 (patch)
tree678f25f467603ce1260f80055a141c08e31a312e
parentc06a85d8427de557a1a04e0370e44007301bcf9b (diff)
downloadglide-3bbc3908edd8432f55ccfae3257bad533c1bf7d1.tar.gz
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
-rw-r--r--integration/avif/src/main/java/com/bumptech/glide/integration/avif/AvifGlideModule.java17
1 files changed, 15 insertions, 2 deletions
diff --git a/integration/avif/src/main/java/com/bumptech/glide/integration/avif/AvifGlideModule.java b/integration/avif/src/main/java/com/bumptech/glide/integration/avif/AvifGlideModule.java
index 337faf31..13dfdd21 100644
--- a/integration/avif/src/main/java/com/bumptech/glide/integration/avif/AvifGlideModule.java
+++ b/integration/avif/src/main/java/com/bumptech/glide/integration/avif/AvifGlideModule.java
@@ -2,10 +2,12 @@ package com.bumptech.glide.integration.avif;
import android.content.Context;
import android.graphics.Bitmap;
+import android.graphics.drawable.BitmapDrawable;
import androidx.annotation.NonNull;
import com.bumptech.glide.Glide;
import com.bumptech.glide.Registry;
import com.bumptech.glide.annotation.GlideModule;
+import com.bumptech.glide.load.resource.bitmap.BitmapDrawableDecoder;
import com.bumptech.glide.module.LibraryGlideModule;
import java.io.InputStream;
import java.nio.ByteBuffer;
@@ -21,10 +23,21 @@ public final class AvifGlideModule extends LibraryGlideModule {
// the integration will be preferred for Avif images.
AvifByteBufferBitmapDecoder byteBufferBitmapDecoder =
new AvifByteBufferBitmapDecoder(glide.getBitmapPool());
- registry.prepend(ByteBuffer.class, Bitmap.class, byteBufferBitmapDecoder);
+ registry.prepend(
+ Registry.BUCKET_BITMAP, ByteBuffer.class, Bitmap.class, byteBufferBitmapDecoder);
+ registry.prepend(
+ Registry.BUCKET_BITMAP_DRAWABLE,
+ ByteBuffer.class,
+ BitmapDrawable.class,
+ new BitmapDrawableDecoder<>(context.getResources(), byteBufferBitmapDecoder));
AvifStreamBitmapDecoder streamBitmapDecoder =
new AvifStreamBitmapDecoder(
registry.getImageHeaderParsers(), byteBufferBitmapDecoder, glide.getArrayPool());
- registry.prepend(InputStream.class, Bitmap.class, streamBitmapDecoder);
+ registry.prepend(Registry.BUCKET_BITMAP, InputStream.class, Bitmap.class, streamBitmapDecoder);
+ registry.prepend(
+ Registry.BUCKET_BITMAP_DRAWABLE,
+ InputStream.class,
+ BitmapDrawable.class,
+ new BitmapDrawableDecoder<>(context.getResources(), streamBitmapDecoder));
}
}