Migrate usages of Cue's bitmap constructor to Cue.Builder
PiperOrigin-RevId: 285956436
This commit is contained in:
parent
04b1782a53
commit
f10bc37831
@ -227,50 +227,6 @@ public final class Cue {
|
||||
*/
|
||||
public final float textSize;
|
||||
|
||||
/**
|
||||
* Creates an image cue.
|
||||
*
|
||||
* @param bitmap See {@link #bitmap}.
|
||||
* @param horizontalPosition The position of the horizontal anchor within the viewport, expressed
|
||||
* as a fraction of the viewport width.
|
||||
* @param horizontalPositionAnchor The horizontal anchor. One of {@link #ANCHOR_TYPE_START},
|
||||
* {@link #ANCHOR_TYPE_MIDDLE}, {@link #ANCHOR_TYPE_END} and {@link #TYPE_UNSET}.
|
||||
* @param verticalPosition The position of the vertical anchor within the viewport, expressed as a
|
||||
* fraction of the viewport height.
|
||||
* @param verticalPositionAnchor The vertical anchor. One of {@link #ANCHOR_TYPE_START}, {@link
|
||||
* #ANCHOR_TYPE_MIDDLE}, {@link #ANCHOR_TYPE_END} and {@link #TYPE_UNSET}.
|
||||
* @param width The width of the cue as a fraction of the viewport width.
|
||||
* @param height The height of the cue as a fraction of the viewport height, or {@link
|
||||
* #DIMEN_UNSET} if the bitmap should be displayed at its natural height for the specified
|
||||
* {@code width}.
|
||||
* @deprecated Use {@link Builder}.
|
||||
*/
|
||||
@Deprecated
|
||||
public Cue(
|
||||
Bitmap bitmap,
|
||||
float horizontalPosition,
|
||||
@AnchorType int horizontalPositionAnchor,
|
||||
float verticalPosition,
|
||||
@AnchorType int verticalPositionAnchor,
|
||||
float width,
|
||||
float height) {
|
||||
this(
|
||||
/* text= */ null,
|
||||
/* textAlignment= */ null,
|
||||
bitmap,
|
||||
verticalPosition,
|
||||
/* lineType= */ LINE_TYPE_FRACTION,
|
||||
verticalPositionAnchor,
|
||||
horizontalPosition,
|
||||
horizontalPositionAnchor,
|
||||
/* textSizeType= */ TYPE_UNSET,
|
||||
/* textSize= */ DIMEN_UNSET,
|
||||
width,
|
||||
height,
|
||||
/* windowColorSet= */ false,
|
||||
/* windowColor= */ Color.BLACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a text cue whose {@link #textAlignment} is null, whose type parameters are set to
|
||||
* {@link #TYPE_UNSET} and whose dimension parameters are set to {@link #DIMEN_UNSET}.
|
||||
|
@ -208,12 +208,23 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
fillRegionPaint);
|
||||
}
|
||||
|
||||
Bitmap cueBitmap = Bitmap.createBitmap(bitmap, baseHorizontalAddress, baseVerticalAddress,
|
||||
regionComposition.width, regionComposition.height);
|
||||
cues.add(new Cue(cueBitmap, (float) baseHorizontalAddress / displayDefinition.width,
|
||||
Cue.ANCHOR_TYPE_START, (float) baseVerticalAddress / displayDefinition.height,
|
||||
Cue.ANCHOR_TYPE_START, (float) regionComposition.width / displayDefinition.width,
|
||||
(float) regionComposition.height / displayDefinition.height));
|
||||
cues.add(
|
||||
new Cue.Builder()
|
||||
.setBitmap(
|
||||
Bitmap.createBitmap(
|
||||
bitmap,
|
||||
baseHorizontalAddress,
|
||||
baseVerticalAddress,
|
||||
regionComposition.width,
|
||||
regionComposition.height))
|
||||
.setPosition((float) baseHorizontalAddress / displayDefinition.width)
|
||||
.setPositionAnchor(Cue.ANCHOR_TYPE_START)
|
||||
.setLine(
|
||||
(float) baseVerticalAddress / displayDefinition.height, Cue.LINE_TYPE_FRACTION)
|
||||
.setLineAnchor(Cue.ANCHOR_TYPE_START)
|
||||
.setSize((float) regionComposition.width / displayDefinition.width)
|
||||
.setBitmapHeight((float) regionComposition.height / displayDefinition.height)
|
||||
.build());
|
||||
|
||||
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
|
||||
// Restore clean clipping state.
|
||||
|
@ -235,14 +235,15 @@ public final class PgsDecoder extends SimpleSubtitleDecoder {
|
||||
Bitmap bitmap =
|
||||
Bitmap.createBitmap(argbBitmapData, bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888);
|
||||
// Build the cue.
|
||||
return new Cue(
|
||||
bitmap,
|
||||
(float) bitmapX / planeWidth,
|
||||
Cue.ANCHOR_TYPE_START,
|
||||
(float) bitmapY / planeHeight,
|
||||
Cue.ANCHOR_TYPE_START,
|
||||
(float) bitmapWidth / planeWidth,
|
||||
(float) bitmapHeight / planeHeight);
|
||||
return new Cue.Builder()
|
||||
.setBitmap(bitmap)
|
||||
.setPosition((float) bitmapX / planeWidth)
|
||||
.setPositionAnchor(Cue.ANCHOR_TYPE_START)
|
||||
.setLine((float) bitmapY / planeHeight, Cue.LINE_TYPE_FRACTION)
|
||||
.setLineAnchor(Cue.ANCHOR_TYPE_START)
|
||||
.setSize((float) bitmapWidth / planeWidth)
|
||||
.setBitmapHeight((float) bitmapHeight / planeHeight)
|
||||
.build();
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
|
@ -228,14 +228,15 @@ import java.util.TreeSet;
|
||||
TtmlRegion region = regionMap.get(regionImagePair.first);
|
||||
|
||||
cues.add(
|
||||
new Cue(
|
||||
bitmap,
|
||||
region.position,
|
||||
Cue.ANCHOR_TYPE_START,
|
||||
region.line,
|
||||
region.lineAnchor,
|
||||
region.width,
|
||||
region.height));
|
||||
new Cue.Builder()
|
||||
.setBitmap(bitmap)
|
||||
.setPosition(region.position)
|
||||
.setPositionAnchor(Cue.ANCHOR_TYPE_START)
|
||||
.setLine(region.line, Cue.LINE_TYPE_FRACTION)
|
||||
.setLineAnchor(region.lineAnchor)
|
||||
.setSize(region.width)
|
||||
.setBitmapHeight(region.height)
|
||||
.build());
|
||||
}
|
||||
|
||||
// Create text based cues.
|
||||
|
Loading…
x
Reference in New Issue
Block a user