From 6b15ace9aab296c2db030c77df61c46bd761f8dd Mon Sep 17 00:00:00 2001 From: tofunmi Date: Fri, 9 Dec 2022 10:15:46 +0000 Subject: [PATCH] Fix bugs in DrawableOverlay.java. calls setbounds() on the drawable as the bounds of a drawable must be set for the .draw() method to work as noted in the [Drawable Documentation](https://developer.android.com/reference/android/graphics/drawable/Drawable#draw(android.graphics.Canvas)). Also fixes createStaticDrawableOverlay() not taking specified overlay settings into account. PiperOrigin-RevId: 494116077 --- .../androidx/media3/effect/DrawableOverlay.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/libraries/effect/src/main/java/androidx/media3/effect/DrawableOverlay.java b/libraries/effect/src/main/java/androidx/media3/effect/DrawableOverlay.java index c11a368097..934bedf18c 100644 --- a/libraries/effect/src/main/java/androidx/media3/effect/DrawableOverlay.java +++ b/libraries/effect/src/main/java/androidx/media3/effect/DrawableOverlay.java @@ -37,6 +37,9 @@ public abstract class DrawableOverlay extends BitmapOverlay { /** * Returns the overlay {@link Drawable} displayed at the specified timestamp. * + *

The drawable must have it's bounds set via {@link Drawable#setBounds} for drawable to be + * displayed on the frame. + * * @param presentationTimeUs The presentation timestamp of the current frame, in microseconds. */ public abstract Drawable getDrawable(long presentationTimeUs); @@ -45,8 +48,7 @@ public abstract class DrawableOverlay extends BitmapOverlay { public Bitmap getBitmap(long presentationTimeUs) { Drawable overlayDrawable = getDrawable(presentationTimeUs); // TODO(b/227625365): Drawable doesn't implement the equals method, so investigate other methods - // of - // detecting the need to redraw the bitmap. + // of detecting the need to redraw the bitmap. if (!overlayDrawable.equals(lastDrawable)) { lastDrawable = overlayDrawable; lastBitmap = @@ -61,9 +63,10 @@ public abstract class DrawableOverlay extends BitmapOverlay { } /** - * Creates a {@link TextOverlay} that shows the {@code overlayDrawable} with the same {@link + * Creates a {@link TextOverlay} that shows the {@link Drawable} with the same {@link * OverlaySettings} throughout the whole video. * + * @param drawable The {@link Drawable} to be displayed. * @param overlaySettings The {@link OverlaySettings} configuring how the overlay is displayed on * the frames. */ @@ -74,6 +77,11 @@ public abstract class DrawableOverlay extends BitmapOverlay { public Drawable getDrawable(long presentationTimeUs) { return drawable; } + + @Override + public OverlaySettings getOverlaySettings(long presentationTimeUs) { + return overlaySettings; + } }; } }