Commit 6a36574a by ibaker Committed by Ian Baker

Use anti-aliasing and bitmap filtering for bitmap subtitles

issue:#6950
PiperOrigin-RevId: 307411067
parent 8d0d31e1
...@@ -95,6 +95,8 @@ ...@@ -95,6 +95,8 @@
(a (a
[previous draft](https://www.w3.org/TR/2014/WD-webvtt1-20141111/#dfn-webvtt-text-position-cue-setting) [previous draft](https://www.w3.org/TR/2014/WD-webvtt1-20141111/#dfn-webvtt-text-position-cue-setting)
used `start`, `middle` and `end`). used `start`, `middle` and `end`).
* Use anti-aliasing and bitmap filtering when displaying bitmap subtitles
([#6950](https://github.com/google/ExoPlayer/pull/6950)).
* DRM: * DRM:
* Add support for attaching DRM sessions to clear content in the demo app. * Add support for attaching DRM sessions to clear content in the demo app.
* Remove `DrmSessionManager` references from all renderers. * Remove `DrmSessionManager` references from all renderers.
......
...@@ -65,7 +65,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; ...@@ -65,7 +65,8 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
private final float spacingAdd; private final float spacingAdd;
private final TextPaint textPaint; private final TextPaint textPaint;
private final Paint paint; private final Paint windowPaint;
private final Paint bitmapPaint;
// Previous input variables. // Previous input variables.
@Nullable private CharSequence cueText; @Nullable private CharSequence cueText;
...@@ -124,9 +125,13 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; ...@@ -124,9 +125,13 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
textPaint.setAntiAlias(true); textPaint.setAntiAlias(true);
textPaint.setSubpixelText(true); textPaint.setSubpixelText(true);
paint = new Paint(); windowPaint = new Paint();
paint.setAntiAlias(true); windowPaint.setAntiAlias(true);
paint.setStyle(Style.FILL); windowPaint.setStyle(Style.FILL);
bitmapPaint = new Paint();
bitmapPaint.setAntiAlias(true);
bitmapPaint.setFilterBitmap(true);
} }
/** /**
...@@ -442,9 +447,13 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; ...@@ -442,9 +447,13 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
canvas.translate(textLeft, textTop); canvas.translate(textLeft, textTop);
if (Color.alpha(windowColor) > 0) { if (Color.alpha(windowColor) > 0) {
paint.setColor(windowColor); windowPaint.setColor(windowColor);
canvas.drawRect( canvas.drawRect(
-textPaddingX, 0, textLayout.getWidth() + textPaddingX, textLayout.getHeight(), paint); -textPaddingX,
0,
textLayout.getWidth() + textPaddingX,
textLayout.getHeight(),
windowPaint);
} }
if (edgeType == CaptionStyleCompat.EDGE_TYPE_OUTLINE) { if (edgeType == CaptionStyleCompat.EDGE_TYPE_OUTLINE) {
...@@ -478,7 +487,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull; ...@@ -478,7 +487,7 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
@RequiresNonNull({"cueBitmap", "bitmapRect"}) @RequiresNonNull({"cueBitmap", "bitmapRect"})
private void drawBitmapLayout(Canvas canvas) { private void drawBitmapLayout(Canvas canvas) {
canvas.drawBitmap(cueBitmap, /* src= */ null, bitmapRect, /* paint= */ null); canvas.drawBitmap(cueBitmap, /* src= */ null, bitmapRect, bitmapPaint);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment