Commit 7a95e08b by tofunmi Committed by Ian Baker

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
parent 1d0425e2
...@@ -35,6 +35,9 @@ public abstract class DrawableOverlay extends BitmapOverlay { ...@@ -35,6 +35,9 @@ public abstract class DrawableOverlay extends BitmapOverlay {
/** /**
* Returns the overlay {@link Drawable} displayed at the specified timestamp. * Returns the overlay {@link Drawable} displayed at the specified timestamp.
* *
* <p>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. * @param presentationTimeUs The presentation timestamp of the current frame, in microseconds.
*/ */
public abstract Drawable getDrawable(long presentationTimeUs); public abstract Drawable getDrawable(long presentationTimeUs);
...@@ -43,8 +46,7 @@ public abstract class DrawableOverlay extends BitmapOverlay { ...@@ -43,8 +46,7 @@ public abstract class DrawableOverlay extends BitmapOverlay {
public Bitmap getBitmap(long presentationTimeUs) { public Bitmap getBitmap(long presentationTimeUs) {
Drawable overlayDrawable = getDrawable(presentationTimeUs); Drawable overlayDrawable = getDrawable(presentationTimeUs);
// TODO(b/227625365): Drawable doesn't implement the equals method, so investigate other methods // TODO(b/227625365): Drawable doesn't implement the equals method, so investigate other methods
// of // of detecting the need to redraw the bitmap.
// detecting the need to redraw the bitmap.
if (!overlayDrawable.equals(lastDrawable)) { if (!overlayDrawable.equals(lastDrawable)) {
lastDrawable = overlayDrawable; lastDrawable = overlayDrawable;
lastBitmap = lastBitmap =
...@@ -59,9 +61,10 @@ public abstract class DrawableOverlay extends BitmapOverlay { ...@@ -59,9 +61,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. * 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 * @param overlaySettings The {@link OverlaySettings} configuring how the overlay is displayed on
* the frames. * the frames.
*/ */
...@@ -72,6 +75,11 @@ public abstract class DrawableOverlay extends BitmapOverlay { ...@@ -72,6 +75,11 @@ public abstract class DrawableOverlay extends BitmapOverlay {
public Drawable getDrawable(long presentationTimeUs) { public Drawable getDrawable(long presentationTimeUs) {
return drawable; return drawable;
} }
@Override
public OverlaySettings getOverlaySettings(long presentationTimeUs) {
return overlaySettings;
}
}; };
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment