Skip to content

Commit

Permalink
Fix rendering DVB subtitle on API 28.
Browse files Browse the repository at this point in the history
Issue: #5862
PiperOrigin-RevId: 248112524
  • Loading branch information
marcbaechinger authored and ojw28 committed May 15, 2019
1 parent 035686e commit cea3071
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* Offline: Add option to remove all downloads.
* Add a workaround for a decoder failure on ZTE Axon7 mini devices when playing
48kHz audio ([#5821](https://github.com/google/ExoPlayer/issues/5821)).
* Fix DVB subtitles for SDK 28
([#5862](https://github.com/google/ExoPlayer/issues/5862)).

### 2.10.0 ###

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffXfermode;
import android.graphics.Region;
import android.util.SparseArray;
import com.google.android.exoplayer2.text.Cue;
import com.google.android.exoplayer2.util.Log;
Expand Down Expand Up @@ -150,6 +149,8 @@ public List<Cue> decode(byte[] data, int limit) {
List<Cue> cues = new ArrayList<>();
SparseArray<PageRegion> pageRegions = subtitleService.pageComposition.regions;
for (int i = 0; i < pageRegions.size(); i++) {
// Save clean clipping state.
canvas.save();
PageRegion pageRegion = pageRegions.valueAt(i);
int regionId = pageRegions.keyAt(i);
RegionComposition regionComposition = subtitleService.regions.get(regionId);
Expand All @@ -163,9 +164,7 @@ public List<Cue> decode(byte[] data, int limit) {
displayDefinition.horizontalPositionMaximum);
int clipBottom = Math.min(baseVerticalAddress + regionComposition.height,
displayDefinition.verticalPositionMaximum);
canvas.clipRect(baseHorizontalAddress, baseVerticalAddress, clipRight, clipBottom,
Region.Op.REPLACE);

canvas.clipRect(baseHorizontalAddress, baseVerticalAddress, clipRight, clipBottom);
ClutDefinition clutDefinition = subtitleService.cluts.get(regionComposition.clutId);
if (clutDefinition == null) {
clutDefinition = subtitleService.ancillaryCluts.get(regionComposition.clutId);
Expand Down Expand Up @@ -214,9 +213,11 @@ public List<Cue> decode(byte[] data, int limit) {
(float) regionComposition.height / displayDefinition.height));

canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR);
// Restore clean clipping state.
canvas.restore();
}

return cues;
return Collections.unmodifiableList(cues);
}

// Static parsing.
Expand Down

0 comments on commit cea3071

Please sign in to comment.