Fix anchor usage in SubtitlePainter's setupBitmapLayout

According to Cue's constructor (for bitmaps) documentation:
+ cuePositionAnchor does horizontal anchoring.
+ cueLineAnchor does vertical anchoring.

Usage is currently inverted.

Issue:#5633
PiperOrigin-RevId: 250253002
This commit is contained in:
aquilescanta 2019-05-28 12:20:14 +01:00 committed by Oliver Woodman
parent 9b104f6ec0
commit 42ffc5215f

View file

@ -362,10 +362,16 @@ import com.google.android.exoplayer2.util.Util;
int width = Math.round(parentWidth * cueSize);
int height = cueBitmapHeight != Cue.DIMEN_UNSET ? Math.round(parentHeight * cueBitmapHeight)
: Math.round(width * ((float) cueBitmap.getHeight() / cueBitmap.getWidth()));
int x = Math.round(cueLineAnchor == Cue.ANCHOR_TYPE_END ? (anchorX - width)
: cueLineAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorX - (width / 2)) : anchorX);
int y = Math.round(cuePositionAnchor == Cue.ANCHOR_TYPE_END ? (anchorY - height)
: cuePositionAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorY - (height / 2)) : anchorY);
int x =
Math.round(
cuePositionAnchor == Cue.ANCHOR_TYPE_END
? (anchorX - width)
: cuePositionAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorX - (width / 2)) : anchorX);
int y =
Math.round(
cueLineAnchor == Cue.ANCHOR_TYPE_END
? (anchorY - height)
: cueLineAnchor == Cue.ANCHOR_TYPE_MIDDLE ? (anchorY - (height / 2)) : anchorY);
bitmapRect = new Rect(x, y, x + width, y + height);
}