Skip to content

Commit

Permalink
Fix positioning of subtitles.
Browse files Browse the repository at this point in the history
SubtitleView forwards the cue box position to SubtitlePainter. This should be
the position relative to the canvas of the SubtitleView. Currently, however,
we forward the position relative to the parent of SubtitleView. That causes
problems if SubtitleView has a non-zero offset position to its parent.

Issue:#4788

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=215535281
  • Loading branch information
tonihei authored and ojw28 committed Oct 20, 2018
1 parent b59781b commit e2c82a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
3 changes: 3 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* Fix an issue with blind seeking to windows with non-zero offset in a
`ConcatenatingMediaSource`
([#4873](https://github.com/google/ExoPlayer/issues/4873)).
* Fix issue where subtitles have a wrong position if SubtitleView has a non-zero
offset to its parent
([#4788](https://github.com/google/ExoPlayer/issues/4788)).

### 2.9.0 ###

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,19 +247,17 @@ public void setBottomPaddingFraction(float bottomPaddingFraction) {
@Override
public void dispatchDraw(Canvas canvas) {
int cueCount = (cues == null) ? 0 : cues.size();
int rawTop = getTop();
int rawBottom = getBottom();
int rawViewHeight = getHeight();

// Calculate the bounds after padding is taken into account.
int left = getLeft() + getPaddingLeft();
int top = rawTop + getPaddingTop();
int right = getRight() - getPaddingRight();
int bottom = rawBottom - getPaddingBottom();
// Calculate the cue box bounds relative to the canvas after padding is taken into account.
int left = getPaddingLeft();
int top = getPaddingTop();
int right = getWidth() - getPaddingRight();
int bottom = rawViewHeight - getPaddingBottom();
if (bottom <= top || right <= left) {
// No space to draw subtitles.
return;
}
int rawViewHeight = rawBottom - rawTop;
int viewHeightMinusPadding = bottom - top;

float defaultViewTextSizePx =
Expand Down

0 comments on commit e2c82a2

Please sign in to comment.