Fix EffectPlaybackPixelTest
The tests using createTimestampOverlay() were passing even if the effect was removed, because the overlay was too small. PiperOrigin-RevId: 678169395
Before Width: | Height: | Size: 522 KiB After Width: | Height: | Size: 511 KiB |
Before Width: | Height: | Size: 536 KiB After Width: | Height: | Size: 526 KiB |
Before Width: | Height: | Size: 558 KiB After Width: | Height: | Size: 548 KiB |
Before Width: | Height: | Size: 560 KiB After Width: | Height: | Size: 551 KiB |
Before Width: | Height: | Size: 559 KiB After Width: | Height: | Size: 508 KiB |
Before Width: | Height: | Size: 562 KiB After Width: | Height: | Size: 539 KiB |
Before Width: | Height: | Size: 563 KiB After Width: | Height: | Size: 542 KiB |
Before Width: | Height: | Size: 564 KiB After Width: | Height: | Size: 526 KiB |
Before Width: | Height: | Size: 567 KiB After Width: | Height: | Size: 552 KiB |
Before Width: | Height: | Size: 568 KiB After Width: | Height: | Size: 553 KiB |
Before Width: | Height: | Size: 567 KiB After Width: | Height: | Size: 535 KiB |
Before Width: | Height: | Size: 572 KiB After Width: | Height: | Size: 559 KiB |
Before Width: | Height: | Size: 537 KiB After Width: | Height: | Size: 524 KiB |
Before Width: | Height: | Size: 571 KiB After Width: | Height: | Size: 564 KiB |
Before Width: | Height: | Size: 570 KiB After Width: | Height: | Size: 535 KiB |
Before Width: | Height: | Size: 571 KiB After Width: | Height: | Size: 536 KiB |
Before Width: | Height: | Size: 571 KiB After Width: | Height: | Size: 548 KiB |
Before Width: | Height: | Size: 571 KiB After Width: | Height: | Size: 540 KiB |
Before Width: | Height: | Size: 573 KiB After Width: | Height: | Size: 545 KiB |
Before Width: | Height: | Size: 573 KiB After Width: | Height: | Size: 564 KiB |
Before Width: | Height: | Size: 572 KiB After Width: | Height: | Size: 541 KiB |
Before Width: | Height: | Size: 573 KiB After Width: | Height: | Size: 541 KiB |
Before Width: | Height: | Size: 574 KiB After Width: | Height: | Size: 561 KiB |
Before Width: | Height: | Size: 544 KiB After Width: | Height: | Size: 510 KiB |
Before Width: | Height: | Size: 548 KiB After Width: | Height: | Size: 525 KiB |
Before Width: | Height: | Size: 549 KiB After Width: | Height: | Size: 535 KiB |
Before Width: | Height: | Size: 548 KiB After Width: | Height: | Size: 519 KiB |
Before Width: | Height: | Size: 555 KiB After Width: | Height: | Size: 542 KiB |
Before Width: | Height: | Size: 557 KiB After Width: | Height: | Size: 547 KiB |
Before Width: | Height: | Size: 556 KiB After Width: | Height: | Size: 532 KiB |
Before Width: | Height: | Size: 526 KiB After Width: | Height: | Size: 511 KiB |
@ -23,6 +23,7 @@ import android.text.style.AbsoluteSizeSpan;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.text.style.TypefaceSpan;
|
||||
import androidx.media3.effect.OverlayEffect;
|
||||
import androidx.media3.effect.OverlaySettings;
|
||||
import androidx.media3.effect.TextOverlay;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
@ -35,27 +36,45 @@ import com.google.common.collect.ImmutableList;
|
||||
public static OverlayEffect createTimestampOverlay() {
|
||||
return new OverlayEffect(
|
||||
ImmutableList.of(
|
||||
new TextOverlay() {
|
||||
@Override
|
||||
public SpannableString getText(long presentationTimeUs) {
|
||||
SpannableString text = new SpannableString(String.valueOf(presentationTimeUs));
|
||||
text.setSpan(
|
||||
new ForegroundColorSpan(Color.WHITE),
|
||||
/* start= */ 0,
|
||||
text.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
text.setSpan(
|
||||
new AbsoluteSizeSpan(/* size= */ 96),
|
||||
/* start= */ 0,
|
||||
text.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
text.setSpan(
|
||||
new TypefaceSpan(/* family= */ "sans-serif"),
|
||||
/* start= */ 0,
|
||||
text.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
return text;
|
||||
}
|
||||
}));
|
||||
new TimestampTextOverlay(0, -0.7f),
|
||||
new TimestampTextOverlay(0, 0),
|
||||
new TimestampTextOverlay(0, 0.7f)));
|
||||
}
|
||||
|
||||
private static class TimestampTextOverlay extends TextOverlay {
|
||||
|
||||
private final float x;
|
||||
private final float y;
|
||||
|
||||
public TimestampTextOverlay(float x, float y) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpannableString getText(long presentationTimeUs) {
|
||||
SpannableString text = new SpannableString(String.valueOf(presentationTimeUs));
|
||||
text.setSpan(
|
||||
new ForegroundColorSpan(Color.WHITE),
|
||||
/* start= */ 0,
|
||||
text.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
text.setSpan(
|
||||
new AbsoluteSizeSpan(/* size= */ 300),
|
||||
/* start= */ 0,
|
||||
text.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
text.setSpan(
|
||||
new TypefaceSpan(/* family= */ "sans-serif"),
|
||||
/* start= */ 0,
|
||||
text.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
return text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OverlaySettings getOverlaySettings(long presentationTimeUs) {
|
||||
return new OverlaySettings.Builder().setBackgroundFrameAnchor(x, y).build();
|
||||
}
|
||||
}
|
||||
}
|
||||
|