Skip to content

Commit

Permalink
Fix anchor usage in SubtitlePainter's setupBitmapLayout
Browse files Browse the repository at this point in the history
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
  • Loading branch information
AquilesCanta authored and ojw28 committed May 31, 2019
1 parent 9b104f6 commit 42ffc52
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,16 @@ private void setupBitmapLayout() {
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);
}

Expand Down

0 comments on commit 42ffc52

Please sign in to comment.