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
This commit is contained in:
parent
cda969985e
commit
6b15ace9aa
@ -37,6 +37,9 @@ public abstract class DrawableOverlay extends BitmapOverlay {
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user