diff --git a/demos/transformer/src/main/java/androidx/media3/demo/transformer/PeriodicVignetteProcessor.java b/demos/transformer/src/main/java/androidx/media3/demo/transformer/PeriodicVignetteShaderProgram.java
similarity index 94%
rename from demos/transformer/src/main/java/androidx/media3/demo/transformer/PeriodicVignetteProcessor.java
rename to demos/transformer/src/main/java/androidx/media3/demo/transformer/PeriodicVignetteShaderProgram.java
index 4fbe0b9a80..81e6549d1f 100644
--- a/demos/transformer/src/main/java/androidx/media3/demo/transformer/PeriodicVignetteProcessor.java
+++ b/demos/transformer/src/main/java/androidx/media3/demo/transformer/PeriodicVignetteShaderProgram.java
@@ -23,14 +23,14 @@ import androidx.media3.common.FrameProcessingException;
import androidx.media3.common.util.GlProgram;
import androidx.media3.common.util.GlUtil;
import androidx.media3.common.util.Size;
-import androidx.media3.effect.SingleFrameGlTextureProcessor;
+import androidx.media3.effect.SingleFrameGlShaderProgram;
import java.io.IOException;
/**
- * A {@link SingleFrameGlTextureProcessor} that periodically dims the frames such that pixels are
+ * A {@link SingleFrameGlShaderProgram} that periodically dims the frames such that pixels are
* darker the further they are away from the frame center.
*/
-/* package */ final class PeriodicVignetteProcessor extends SingleFrameGlTextureProcessor {
+/* package */ final class PeriodicVignetteShaderProgram extends SingleFrameGlShaderProgram {
private static final String VERTEX_SHADER_PATH = "vertex_shader_copy_es2.glsl";
private static final String FRAGMENT_SHADER_PATH = "fragment_shader_vignette_es2.glsl";
@@ -61,7 +61,7 @@ import java.io.IOException;
* @param outerRadius The radius after which all pixels are black.
* @throws FrameProcessingException If a problem occurs while reading shader files.
*/
- public PeriodicVignetteProcessor(
+ public PeriodicVignetteShaderProgram(
Context context,
boolean useHdr,
float centerX,
diff --git a/demos/transformer/src/main/java/androidx/media3/demo/transformer/TransformerActivity.java b/demos/transformer/src/main/java/androidx/media3/demo/transformer/TransformerActivity.java
index 792e3ddb62..c80b564852 100644
--- a/demos/transformer/src/main/java/androidx/media3/demo/transformer/TransformerActivity.java
+++ b/demos/transformer/src/main/java/androidx/media3/demo/transformer/TransformerActivity.java
@@ -59,7 +59,7 @@ import androidx.media3.effect.BitmapOverlay;
import androidx.media3.effect.Contrast;
import androidx.media3.effect.DrawableOverlay;
import androidx.media3.effect.GlEffect;
-import androidx.media3.effect.GlTextureProcessor;
+import androidx.media3.effect.GlShaderProgram;
import androidx.media3.effect.HslAdjustment;
import androidx.media3.effect.OverlayEffect;
import androidx.media3.effect.OverlaySettings;
@@ -414,7 +414,7 @@ public final class TransformerActivity extends AppCompatActivity {
(GlEffect)
(Context context, boolean useHdr) -> {
try {
- return (GlTextureProcessor)
+ return (GlShaderProgram)
constructor.newInstance(
context,
useHdr,
@@ -424,7 +424,7 @@ public final class TransformerActivity extends AppCompatActivity {
/* outputStreamName= */ "output_video");
} catch (Exception e) {
runOnUiThread(() -> showToast(R.string.no_media_pipe_error));
- throw new RuntimeException("Failed to load MediaPipe processor", e);
+ throw new RuntimeException("Failed to load MediaPipeShaderProgram", e);
}
});
} catch (Exception e) {
@@ -495,7 +495,7 @@ public final class TransformerActivity extends AppCompatActivity {
effects.add(
(GlEffect)
(Context context, boolean useHdr) ->
- new PeriodicVignetteProcessor(
+ new PeriodicVignetteShaderProgram(
context,
useHdr,
bundle.getFloat(ConfigurationActivity.PERIODIC_VIGNETTE_CENTER_X),
diff --git a/demos/transformer/src/main/res/values/strings.xml b/demos/transformer/src/main/res/values/strings.xml
index 3ddbe129b9..2e0dd223b3 100644
--- a/demos/transformer/src/main/res/values/strings.xml
+++ b/demos/transformer/src/main/res/values/strings.xml
@@ -35,7 +35,7 @@
If {@code isSingleFrameGraph} is {@code false}, the {@code MediaPipeProcessor} may waste CPU - * time by continuously attempting to queue input frames to MediaPipe until they are accepted or - * waste memory if MediaPipe accepts and stores many frames internally. + *
If {@code isSingleFrameGraph} is {@code false}, the {@code MediaPipeShaderProgram} may waste + * CPU time by continuously attempting to queue input frames to MediaPipe until they are accepted + * or waste memory if MediaPipe accepts and stores many frames internally. * * @param context The {@link Context}. * @param useHdr Whether input textures come from an HDR source. If {@code true}, colors will be @@ -95,7 +95,7 @@ import java.util.concurrent.Future; * @param inputStreamName Name of the input video stream in the graph. * @param outputStreamName Name of the input video stream in the graph. */ - public MediaPipeProcessor( + public MediaPipeShaderProgram( Context context, boolean useHdr, String graphName, @@ -103,8 +103,8 @@ import java.util.concurrent.Future; String inputStreamName, String outputStreamName) { checkState(LOADER.isAvailable()); - // TODO(b/227624622): Confirm whether MediaPipeProcessor could support HDR colors. - checkArgument(!useHdr, "MediaPipeProcessor does not support HDR colors."); + // TODO(b/227624622): Confirm whether MediaPipeShaderProgram could support HDR colors. + checkArgument(!useHdr, "MediaPipeShaderProgram does not support HDR colors."); this.isSingleFrameGraph = isSingleFrameGraph; singleThreadExecutorService = @@ -233,7 +233,7 @@ import java.util.concurrent.Future; @Override public void flush() { - // TODO(b/238302341) Support seeking in MediaPipeProcessor. + // TODO(b/238302341) Support seeking in MediaPipeShaderProgram. throw new UnsupportedOperationException(); } diff --git a/libraries/common/src/main/java/androidx/media3/common/util/GlUtil.java b/libraries/common/src/main/java/androidx/media3/common/util/GlUtil.java index d2b6de9653..38cf24299b 100644 --- a/libraries/common/src/main/java/androidx/media3/common/util/GlUtil.java +++ b/libraries/common/src/main/java/androidx/media3/common/util/GlUtil.java @@ -411,7 +411,7 @@ public final class GlUtil { */ private static void assertValidTextureSize(int width, int height) throws GlException { // TODO(b/201293185): Consider handling adjustments for sizes > GL_MAX_TEXTURE_SIZE - // (ex. downscaling appropriately) in a texture processor instead of asserting incorrect + // (ex. downscaling appropriately) in a shader program instead of asserting incorrect // values. // For valid GL sizes, see: // https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glTexImage2D.xml diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java index d54cb2209a..5a27ef319c 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java @@ -45,7 +45,7 @@ import org.junit.Test; import org.junit.runner.RunWith; /** - * Pixel test for contrast adjustment via {@link ContrastProcessor}. + * Pixel test for contrast adjustment via {@link ContrastShaderProgram}. * *
Expected images are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link @@ -71,7 +71,7 @@ public class ContrastPixelTest { private @MonotonicNonNull EGLDisplay eglDisplay; private @MonotonicNonNull EGLContext eglContext; private @MonotonicNonNull EGLSurface placeholderEglSurface; - private @MonotonicNonNull SingleFrameGlTextureProcessor contrastProcessor; + private @MonotonicNonNull SingleFrameGlShaderProgram contrastShaderProgram; private int inputTexId; private int inputWidth; private int inputHeight; @@ -90,8 +90,8 @@ public class ContrastPixelTest { @After public void release() throws GlUtil.GlException, FrameProcessingException { - if (contrastProcessor != null) { - contrastProcessor.release(); + if (contrastShaderProgram != null) { + contrastShaderProgram.release(); } GlUtil.destroyEglContext(eglDisplay, eglContext); } @@ -99,13 +99,13 @@ public class ContrastPixelTest { @Test public void drawFrame_noContrastChange_leavesFrameUnchanged() throws Exception { String testId = "drawFrame_noContrastChange"; - contrastProcessor = - new Contrast(/* contrast= */ 0.0f).toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = contrastProcessor.configure(inputWidth, inputHeight); + contrastShaderProgram = + new Contrast(/* contrast= */ 0.0f).toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = contrastShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); - contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + contrastShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -118,9 +118,9 @@ public class ContrastPixelTest { @Test public void drawFrame_minimumContrast_producesAllGrayFrame() throws Exception { String testId = "drawFrame_minimumContrast"; - contrastProcessor = - new Contrast(/* contrast= */ -1.0f).toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = contrastProcessor.configure(inputWidth, inputHeight); + contrastShaderProgram = + new Contrast(/* contrast= */ -1.0f).toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = contrastShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = createArgb8888BitmapWithSolidColor( @@ -129,7 +129,7 @@ public class ContrastPixelTest { Color.rgb( OPENGL_NEUTRAL_RGB_VALUE, OPENGL_NEUTRAL_RGB_VALUE, OPENGL_NEUTRAL_RGB_VALUE)); - contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + contrastShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -143,13 +143,13 @@ public class ContrastPixelTest { public void drawFrame_decreaseContrast_decreasesPixelsGreaterEqual128IncreasesBelow() throws Exception { String testId = "drawFrame_decreaseContrast"; - contrastProcessor = - new Contrast(/* contrast= */ -0.75f).toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = contrastProcessor.configure(inputWidth, inputHeight); + contrastShaderProgram = + new Contrast(/* contrast= */ -0.75f).toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = contrastShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(DECREASE_CONTRAST_PNG_ASSET_PATH); - contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + contrastShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -163,13 +163,13 @@ public class ContrastPixelTest { public void drawFrame_increaseContrast_increasesPixelsGreaterEqual128DecreasesBelow() throws Exception { String testId = "drawFrame_increaseContrast"; - contrastProcessor = - new Contrast(/* contrast= */ 0.75f).toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = contrastProcessor.configure(inputWidth, inputHeight); + contrastShaderProgram = + new Contrast(/* contrast= */ 0.75f).toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = contrastShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(INCREASE_CONTRAST_PNG_ASSET_PATH); - contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + contrastShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -182,13 +182,13 @@ public class ContrastPixelTest { @Test public void drawFrame_maximumContrast_pixelEither0or255() throws Exception { String testId = "drawFrame_maximumContrast"; - contrastProcessor = - new Contrast(/* contrast= */ 1.0f).toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = contrastProcessor.configure(inputWidth, inputHeight); + contrastShaderProgram = + new Contrast(/* contrast= */ 1.0f).toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = contrastShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(MAXIMUM_CONTRAST_PNG_ASSET_PATH); - contrastProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + contrastShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java index 65cff67d14..b7be52698c 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java @@ -63,7 +63,7 @@ public final class CropPixelTest { private @MonotonicNonNull EGLDisplay eglDisplay; private @MonotonicNonNull EGLContext eglContext; - private @MonotonicNonNull SingleFrameGlTextureProcessor cropTextureProcessor; + private @MonotonicNonNull SingleFrameGlShaderProgram cropShaderProgram; private @MonotonicNonNull EGLSurface placeholderEglSurface; private int inputTexId; private int inputWidth; @@ -83,8 +83,8 @@ public final class CropPixelTest { @After public void release() throws GlUtil.GlException, FrameProcessingException { - if (cropTextureProcessor != null) { - cropTextureProcessor.release(); + if (cropShaderProgram != null) { + cropShaderProgram.release(); } if (eglContext != null && eglDisplay != null) { GlUtil.destroyEglContext(eglDisplay, eglContext); @@ -94,14 +94,14 @@ public final class CropPixelTest { @Test public void drawFrame_noEdits_matchesGoldenFile() throws Exception { String testId = "drawFrame_noEdits"; - cropTextureProcessor = + cropShaderProgram = new Crop(/* left= */ -1, /* right= */ 1, /* bottom= */ -1, /* top= */ 1) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = cropTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = cropShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); - cropTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + cropShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -115,14 +115,14 @@ public final class CropPixelTest { @Test public void drawFrame_cropSmaller_matchesGoldenFile() throws Exception { String testId = "drawFrame_cropSmaller"; - cropTextureProcessor = + cropShaderProgram = new Crop(/* left= */ -.9f, /* right= */ .1f, /* bottom= */ -1f, /* top= */ .5f) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = cropTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = cropShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(CROP_SMALLER_PNG_ASSET_PATH); - cropTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + cropShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -136,14 +136,14 @@ public final class CropPixelTest { @Test public void drawFrame_cropLarger_matchesGoldenFile() throws Exception { String testId = "drawFrame_cropLarger"; - cropTextureProcessor = + cropShaderProgram = new Crop(/* left= */ -2f, /* right= */ 2f, /* bottom= */ -1f, /* top= */ 2f) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = cropTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = cropShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(CROP_LARGER_PNG_ASSET_PATH); - cropTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + cropShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorFrameReleaseTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorFrameReleaseTest.java index 381a759511..2905f6154f 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorFrameReleaseTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorFrameReleaseTest.java @@ -370,7 +370,7 @@ public final class GlEffectsFrameProcessorFrameReleaseTest { } /** Produces blank frames with the given timestamps. */ - private static final class BlankFrameProducer implements GlTextureProcessor { + private static final class BlankFrameProducer implements GlShaderProgram { private @MonotonicNonNull TextureInfo blankTexture; private @MonotonicNonNull OutputListener outputListener; diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorPixelTest.java index 93e015ac43..32c5c4f97e 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/GlEffectsFrameProcessorPixelTest.java @@ -17,7 +17,7 @@ package androidx.media3.effect; import static androidx.media3.common.util.Assertions.checkNotNull; import static androidx.media3.common.util.Assertions.checkStateNotNull; -import static androidx.media3.effect.OverlayTextureProcessorPixelTest.OVERLAY_PNG_ASSET_PATH; +import static androidx.media3.effect.OverlayShaderProgramPixelTest.OVERLAY_PNG_ASSET_PATH; import static androidx.media3.test.utils.BitmapPixelTestUtil.MAXIMUM_AVERAGE_PIXEL_ABSOLUTE_DIFFERENCE; import static androidx.media3.test.utils.BitmapPixelTestUtil.getBitmapAveragePixelAbsoluteDifferenceArgb8888; import static androidx.media3.test.utils.BitmapPixelTestUtil.readBitmap; @@ -503,9 +503,9 @@ public final class GlEffectsFrameProcessorPixelTest { * Wraps a {@link GlEffect} to prevent the {@link GlEffectsFrameProcessor} from detecting its * class and optimizing it. * - *
This ensures that {@link GlEffectsFrameProcessor} uses a separate {@link GlTextureProcessor} + *
This ensures that {@link GlEffectsFrameProcessor} uses a separate {@link GlShaderProgram} * for the wrapped {@link GlEffect} rather than merging it with preceding or subsequent {@link - * GlEffect} instances and applying them in one combined {@link GlTextureProcessor}. + * GlEffect} instances and applying them in one combined {@link GlShaderProgram}. */ private static final class GlEffectWrapper implements GlEffect { @@ -516,9 +516,9 @@ public final class GlEffectsFrameProcessorPixelTest { } @Override - public GlTextureProcessor toGlTextureProcessor(Context context, boolean useHdr) + public GlShaderProgram toGlShaderProgram(Context context, boolean useHdr) throws FrameProcessingException { - return effect.toGlTextureProcessor(context, useHdr); + return effect.toGlShaderProgram(context, useHdr); } } } diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/HslAdjustmentPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/HslAdjustmentPixelTest.java index 5256ef5237..362ae5614e 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/HslAdjustmentPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/HslAdjustmentPixelTest.java @@ -75,7 +75,7 @@ public final class HslAdjustmentPixelTest { private @MonotonicNonNull EGLDisplay eglDisplay; private @MonotonicNonNull EGLContext eglContext; - private @MonotonicNonNull SingleFrameGlTextureProcessor hslProcessor; + private @MonotonicNonNull SingleFrameGlShaderProgram hslProcessor; private @MonotonicNonNull EGLSurface placeholderEglSurface; private int inputTexId; private int inputWidth; @@ -111,7 +111,7 @@ public final class HslAdjustmentPixelTest { public void drawFrame_noOpAdjustment_leavesFrameUnchanged() throws Exception { String testId = "drawFrame_noOpAdjustment"; HslAdjustment noOpAdjustment = new HslAdjustment.Builder().build(); - hslProcessor = noOpAdjustment.toGlTextureProcessor(context, /* useHdr= */ false); + hslProcessor = noOpAdjustment.toGlShaderProgram(context, /* useHdr= */ false); Size outputSize = hslProcessor.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); @@ -129,7 +129,7 @@ public final class HslAdjustmentPixelTest { public void drawFrame_minimumSaturation_producesGrayFrame() throws Exception { String testId = "drawFrame_minimumSaturation"; HslAdjustment minimumSaturation = new HslAdjustment.Builder().adjustSaturation(-100).build(); - hslProcessor = minimumSaturation.toGlTextureProcessor(context, /* useHdr= */ false); + hslProcessor = minimumSaturation.toGlShaderProgram(context, /* useHdr= */ false); Size outputSize = hslProcessor.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(MINIMUM_SATURATION_PNG_ASSET_PATH); @@ -147,7 +147,7 @@ public final class HslAdjustmentPixelTest { public void drawFrame_maximumSaturation_producesHighlySaturatedFrame() throws Exception { String testId = "drawFrame_maximumSaturation"; HslAdjustment maximumSaturation = new HslAdjustment.Builder().adjustSaturation(100).build(); - hslProcessor = maximumSaturation.toGlTextureProcessor(context, /* useHdr= */ false); + hslProcessor = maximumSaturation.toGlShaderProgram(context, /* useHdr= */ false); Size outputSize = hslProcessor.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(MAXIMUM_SATURATION_PNG_ASSET_PATH); @@ -165,7 +165,7 @@ public final class HslAdjustmentPixelTest { public void drawFrame_rotateHueByNegative90Degrees_matchesGoldenFile() throws Exception { String testId = "drawFrame_rotateHueByNegative90Degrees"; HslAdjustment negativeHueRotation90Degrees = new HslAdjustment.Builder().adjustHue(-90).build(); - hslProcessor = negativeHueRotation90Degrees.toGlTextureProcessor(context, /* useHdr= */ false); + hslProcessor = negativeHueRotation90Degrees.toGlShaderProgram(context, /* useHdr= */ false); Size outputSize = hslProcessor.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(ROTATE_HUE_BY_NEGATIVE_90_DEGREES_PNG_ASSET_PATH); @@ -183,7 +183,7 @@ public final class HslAdjustmentPixelTest { public void drawFrame_rotateHueBy60Degrees_matchesGoldenFile() throws Exception { String testId = "drawFrame_rotateHueBy60Degrees"; HslAdjustment hueRotation60Degrees = new HslAdjustment.Builder().adjustHue(60).build(); - hslProcessor = hueRotation60Degrees.toGlTextureProcessor(context, /* useHdr= */ false); + hslProcessor = hueRotation60Degrees.toGlShaderProgram(context, /* useHdr= */ false); Size outputSize = hslProcessor.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(ROTATE_HUE_BY_60_DEGREES_PNG_ASSET_PATH); @@ -202,7 +202,7 @@ public final class HslAdjustmentPixelTest { throws Exception { String testId = "drawFrame_rotateHueByNegative300Degrees"; HslAdjustment hueRotation420Degrees = new HslAdjustment.Builder().adjustHue(-300).build(); - hslProcessor = hueRotation420Degrees.toGlTextureProcessor(context, /* useHdr= */ false); + hslProcessor = hueRotation420Degrees.toGlShaderProgram(context, /* useHdr= */ false); Size outputSize = hslProcessor.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(ROTATE_HUE_BY_60_DEGREES_PNG_ASSET_PATH); @@ -220,7 +220,7 @@ public final class HslAdjustmentPixelTest { public void drawFrame_rotateHueBy360Degrees_leavesFrameUnchanged() throws Exception { String testId = "drawFrame_rotateHueBy360Degrees"; HslAdjustment hueRotation360Degrees = new HslAdjustment.Builder().adjustHue(360).build(); - hslProcessor = hueRotation360Degrees.toGlTextureProcessor(context, /* useHdr= */ false); + hslProcessor = hueRotation360Degrees.toGlShaderProgram(context, /* useHdr= */ false); Size outputSize = hslProcessor.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); @@ -238,7 +238,7 @@ public final class HslAdjustmentPixelTest { public void drawFrame_minimumLightness_producesBlackFrame() throws Exception { String testId = "drawFrame_minimumLightness"; HslAdjustment minimumLightness = new HslAdjustment.Builder().adjustLightness(-100).build(); - hslProcessor = minimumLightness.toGlTextureProcessor(context, /* useHdr= */ false); + hslProcessor = minimumLightness.toGlShaderProgram(context, /* useHdr= */ false); Size outputSize = hslProcessor.configure(inputWidth, inputHeight); Bitmap expectedBitmap = createArgb8888BitmapWithSolidColor(inputWidth, inputHeight, Color.BLACK); @@ -257,7 +257,7 @@ public final class HslAdjustmentPixelTest { public void drawFrame_decreaseLightness_producesDarkerFrame() throws Exception { String testId = "drawFrame_decreaseLightness"; HslAdjustment decreasedLightness = new HslAdjustment.Builder().adjustLightness(-50).build(); - hslProcessor = decreasedLightness.toGlTextureProcessor(context, /* useHdr= */ false); + hslProcessor = decreasedLightness.toGlShaderProgram(context, /* useHdr= */ false); Size outputSize = hslProcessor.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(DECREASE_LIGHTNESS_PNG_ASSET_PATH); @@ -275,7 +275,7 @@ public final class HslAdjustmentPixelTest { public void drawFrame_increaseLightness_producesBrighterFrame() throws Exception { String testId = "drawFrame_increaseLightness"; HslAdjustment increasedLightness = new HslAdjustment.Builder().adjustLightness(50).build(); - hslProcessor = increasedLightness.toGlTextureProcessor(context, /* useHdr= */ false); + hslProcessor = increasedLightness.toGlShaderProgram(context, /* useHdr= */ false); Size outputSize = hslProcessor.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(INCREASE_LIGHTNESS_PNG_ASSET_PATH); @@ -293,7 +293,7 @@ public final class HslAdjustmentPixelTest { public void drawFrame_maximumLightness_producesWhiteFrame() throws Exception { String testId = "drawFrame_maximumLightness"; HslAdjustment maximumLightness = new HslAdjustment.Builder().adjustLightness(100).build(); - hslProcessor = maximumLightness.toGlTextureProcessor(context, /* useHdr= */ false); + hslProcessor = maximumLightness.toGlShaderProgram(context, /* useHdr= */ false); Size outputSize = hslProcessor.configure(inputWidth, inputHeight); Bitmap expectedBitmap = createArgb8888BitmapWithSolidColor(inputWidth, inputHeight, Color.WHITE); @@ -313,7 +313,7 @@ public final class HslAdjustmentPixelTest { String testId = "drawFrame_adjustAllHslSettings"; HslAdjustment allHslSettingsAdjusted = new HslAdjustment.Builder().adjustHue(60).adjustSaturation(30).adjustLightness(50).build(); - hslProcessor = allHslSettingsAdjusted.toGlTextureProcessor(context, /* useHdr= */ false); + hslProcessor = allHslSettingsAdjusted.toGlShaderProgram(context, /* useHdr= */ false); Size outputSize = hslProcessor.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(ADJUST_ALL_HSL_SETTINGS_PNG_ASSET_PATH); diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixTextureProcessorPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixShaderProgramPixelTest.java similarity index 85% rename from libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixTextureProcessorPixelTest.java rename to libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixShaderProgramPixelTest.java index 02e4957953..83770439b2 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixTextureProcessorPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixShaderProgramPixelTest.java @@ -42,7 +42,7 @@ import org.junit.Test; import org.junit.runner.RunWith; /** - * Pixel test for texture processing via {@link MatrixTextureProcessor}. + * Pixel test for texture processing via {@link MatrixShaderProgram}. * *
Expected images are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link @@ -50,7 +50,7 @@ import org.junit.runner.RunWith; * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}. */ @RunWith(AndroidJUnit4.class) -public final class MatrixTextureProcessorPixelTest { +public final class MatrixShaderProgramPixelTest { public static final String ORIGINAL_PNG_ASSET_PATH = "media/bitmap/sample_mp4_first_frame/electrical_colors/original.png"; public static final String TRANSLATE_RIGHT_PNG_ASSET_PATH = @@ -64,7 +64,7 @@ public final class MatrixTextureProcessorPixelTest { private @MonotonicNonNull EGLDisplay eglDisplay; private @MonotonicNonNull EGLContext eglContext; - private @MonotonicNonNull SingleFrameGlTextureProcessor matrixTextureProcessor; + private @MonotonicNonNull SingleFrameGlShaderProgram matrixShaderProgram; private int inputTexId; private int inputWidth; private int inputHeight; @@ -88,8 +88,8 @@ public final class MatrixTextureProcessorPixelTest { @After public void release() throws GlUtil.GlException, FrameProcessingException { - if (matrixTextureProcessor != null) { - matrixTextureProcessor.release(); + if (matrixShaderProgram != null) { + matrixShaderProgram.release(); } if (eglContext != null && eglDisplay != null) { GlUtil.destroyEglContext(eglDisplay, eglContext); @@ -101,12 +101,11 @@ public final class MatrixTextureProcessorPixelTest { String testId = "drawFrame_noEdits"; Matrix identityMatrix = new Matrix(); MatrixTransformation noEditsTransformation = (long presentationTimeUs) -> identityMatrix; - matrixTextureProcessor = - noEditsTransformation.toGlTextureProcessor(context, /* useHdr= */ false); - matrixTextureProcessor.configure(inputWidth, inputHeight); + matrixShaderProgram = noEditsTransformation.toGlShaderProgram(context, /* useHdr= */ false); + matrixShaderProgram.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); - matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + matrixShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); @@ -123,12 +122,12 @@ public final class MatrixTextureProcessorPixelTest { translateRightMatrix.postTranslate(/* dx= */ 1, /* dy= */ 0); MatrixTransformation translateRightTransformation = (long presentationTimeUs) -> translateRightMatrix; - matrixTextureProcessor = - translateRightTransformation.toGlTextureProcessor(context, /* useHdr= */ false); - matrixTextureProcessor.configure(inputWidth, inputHeight); + matrixShaderProgram = + translateRightTransformation.toGlShaderProgram(context, /* useHdr= */ false); + matrixShaderProgram.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(TRANSLATE_RIGHT_PNG_ASSET_PATH); - matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + matrixShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); @@ -144,12 +143,11 @@ public final class MatrixTextureProcessorPixelTest { Matrix scaleNarrowMatrix = new Matrix(); scaleNarrowMatrix.postScale(.5f, 1.2f); MatrixTransformation scaleNarrowTransformation = (long presentationTimeUs) -> scaleNarrowMatrix; - matrixTextureProcessor = - scaleNarrowTransformation.toGlTextureProcessor(context, /* useHdr= */ false); - matrixTextureProcessor.configure(inputWidth, inputHeight); + matrixShaderProgram = scaleNarrowTransformation.toGlShaderProgram(context, /* useHdr= */ false); + matrixShaderProgram.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(SCALE_NARROW_PNG_ASSET_PATH); - matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + matrixShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); @@ -165,12 +163,11 @@ public final class MatrixTextureProcessorPixelTest { Matrix rotate90Matrix = new Matrix(); rotate90Matrix.postRotate(/* degrees= */ 90); MatrixTransformation rotate90Transformation = (long presentationTimeUs) -> rotate90Matrix; - matrixTextureProcessor = - rotate90Transformation.toGlTextureProcessor(context, /* useHdr= */ false); - matrixTextureProcessor.configure(inputWidth, inputHeight); + matrixShaderProgram = rotate90Transformation.toGlShaderProgram(context, /* useHdr= */ false); + matrixShaderProgram.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(ROTATE_90_PNG_ASSET_PATH); - matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + matrixShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(inputWidth, inputHeight); maybeSaveTestBitmapToCacheDirectory(testId, /* bitmapLabel= */ "actual", actualBitmap); diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/OverlayTextureProcessorPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/OverlayShaderProgramPixelTest.java similarity index 86% rename from libraries/effect/src/androidTest/java/androidx/media3/effect/OverlayTextureProcessorPixelTest.java rename to libraries/effect/src/androidTest/java/androidx/media3/effect/OverlayShaderProgramPixelTest.java index ee0979cc2f..943efd87f6 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/OverlayTextureProcessorPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/OverlayShaderProgramPixelTest.java @@ -49,7 +49,7 @@ import org.junit.Test; import org.junit.runner.RunWith; /** - * Pixel test for texture processing via {@link OverlayTextureProcessor}. + * Pixel test for texture processing via {@link OverlayShaderProgram}. * *
Expected bitmaps are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link @@ -57,7 +57,7 @@ import org.junit.runner.RunWith; * bitmaps as recommended in {@link GlEffectsFrameProcessorPixelTest}. */ @RunWith(AndroidJUnit4.class) -public class OverlayTextureProcessorPixelTest { +public class OverlayShaderProgramPixelTest { public static final String OVERLAY_PNG_ASSET_PATH = "media/bitmap/overlay/media3test.png"; public static final String ORIGINAL_PNG_ASSET_PATH = "media/bitmap/sample_mp4_first_frame/electrical_colors/original.png"; @@ -82,7 +82,7 @@ public class OverlayTextureProcessorPixelTest { private @MonotonicNonNull EGLDisplay eglDisplay; private @MonotonicNonNull EGLContext eglContext; - private @MonotonicNonNull SingleFrameGlTextureProcessor overlayTextureProcessor; + private @MonotonicNonNull SingleFrameGlShaderProgram overlayShaderProgram; private @MonotonicNonNull EGLSurface placeholderEglSurface; private int inputTexId; private int inputWidth; @@ -102,8 +102,8 @@ public class OverlayTextureProcessorPixelTest { @After public void release() throws GlUtil.GlException, FrameProcessingException { - if (overlayTextureProcessor != null) { - overlayTextureProcessor.release(); + if (overlayShaderProgram != null) { + overlayShaderProgram.release(); } GlUtil.destroyEglContext(eglDisplay, eglContext); } @@ -111,14 +111,14 @@ public class OverlayTextureProcessorPixelTest { @Test public void drawFrame_noOverlay_leavesFrameUnchanged() throws Exception { String testId = "drawFrame_noOverlay"; - overlayTextureProcessor = + overlayShaderProgram = new OverlayEffect(/* textureOverlays= */ ImmutableList.of()) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = overlayShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); - overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + overlayShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -133,14 +133,14 @@ public class OverlayTextureProcessorPixelTest { String testId = "drawFrame_bitmapOverlay"; Bitmap overlayBitmap = readBitmap(OVERLAY_PNG_ASSET_PATH); BitmapOverlay bitmapOverlay = BitmapOverlay.createStaticBitmapOverlay(overlayBitmap); - overlayTextureProcessor = + overlayShaderProgram = new OverlayEffect(ImmutableList.of(bitmapOverlay)) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = overlayShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(OVERLAY_BITMAP_DEFAULT); - overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + overlayShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -178,14 +178,14 @@ public class OverlayTextureProcessorPixelTest { return overlaySettings; } }; - overlayTextureProcessor = + overlayShaderProgram = new OverlayEffect(ImmutableList.of(staticBitmapOverlay)) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = overlayShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(OVERLAY_BITMAP_SCALED); - overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + overlayShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -205,14 +205,14 @@ public class OverlayTextureProcessorPixelTest { new OverlaySettings.Builder().setMatrix(translateMatrix).setAnchor(-1f, 1f).build(); BitmapOverlay staticBitmapOverlay = BitmapOverlay.createStaticBitmapOverlay(overlayBitmap, overlaySettings); - overlayTextureProcessor = + overlayShaderProgram = new OverlayEffect(ImmutableList.of(staticBitmapOverlay)) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = overlayShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(OVERLAY_BITMAP_ANCHORED); - overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + overlayShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -229,14 +229,14 @@ public class OverlayTextureProcessorPixelTest { OverlaySettings overlaySettings = new OverlaySettings.Builder().setAlpha(0.5f).build(); BitmapOverlay translucentBitmapOverlay = BitmapOverlay.createStaticBitmapOverlay(bitmap, overlaySettings); - overlayTextureProcessor = + overlayShaderProgram = new OverlayEffect(ImmutableList.of(translucentBitmapOverlay)) - .toGlTextureProcessor(context, false); - Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, false); + Size outputSize = overlayShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(OVERLAY_BITMAP_TRANSLUCENT); - overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + overlayShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -258,14 +258,14 @@ public class OverlayTextureProcessorPixelTest { Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); TextOverlay staticTextOverlay = TextOverlay.createStaticTextOverlay(overlayText, overlaySettings); - overlayTextureProcessor = + overlayShaderProgram = new OverlayEffect(ImmutableList.of(staticTextOverlay)) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = overlayShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); - overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + overlayShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -285,14 +285,14 @@ public class OverlayTextureProcessorPixelTest { /* end= */ 4, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); TextOverlay staticTextOverlay = TextOverlay.createStaticTextOverlay(overlayText); - overlayTextureProcessor = + overlayShaderProgram = new OverlayEffect(ImmutableList.of(staticTextOverlay)) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = overlayShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(OVERLAY_TEXT_DEFAULT); - overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + overlayShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -317,14 +317,14 @@ public class OverlayTextureProcessorPixelTest { new OverlaySettings.Builder().setMatrix(translateMatrix).build(); TextOverlay staticTextOverlay = TextOverlay.createStaticTextOverlay(overlayText, overlaySettings); - overlayTextureProcessor = + overlayShaderProgram = new OverlayEffect(ImmutableList.of(staticTextOverlay)) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = overlayShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(OVERLAY_TEXT_TRANSLATE); - overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + overlayShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -351,14 +351,14 @@ public class OverlayTextureProcessorPixelTest { Bitmap bitmap = readBitmap(OVERLAY_PNG_ASSET_PATH); OverlaySettings overlaySettings2 = new OverlaySettings.Builder().setAlpha(0.5f).build(); BitmapOverlay bitmapOverlay = BitmapOverlay.createStaticBitmapOverlay(bitmap, overlaySettings2); - overlayTextureProcessor = + overlayShaderProgram = new OverlayEffect(ImmutableList.of(textOverlay, bitmapOverlay)) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = overlayShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(OVERLAY_MULTIPLE); - overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + overlayShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -388,14 +388,14 @@ public class OverlayTextureProcessorPixelTest { OverlaySettings overlaySettings2 = new OverlaySettings.Builder().setMatrix(scaleMatrix).build(); BitmapOverlay bitmapOverlay = BitmapOverlay.createStaticBitmapOverlay(bitmap, overlaySettings2); - overlayTextureProcessor = + overlayShaderProgram = new OverlayEffect(ImmutableList.of(bitmapOverlay, textOverlay)) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = overlayTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = overlayShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(OVERLAY_OVERLAP); - overlayTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + overlayShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java index e8ad755eb7..b3f89546c3 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java @@ -72,7 +72,7 @@ public final class PresentationPixelTest { private @MonotonicNonNull EGLDisplay eglDisplay; private @MonotonicNonNull EGLContext eglContext; - private @MonotonicNonNull SingleFrameGlTextureProcessor presentationTextureProcessor; + private @MonotonicNonNull SingleFrameGlShaderProgram presentationShaderProgram; private @MonotonicNonNull EGLSurface placeholderEglSurface; private int inputTexId; private int inputWidth; @@ -92,8 +92,8 @@ public final class PresentationPixelTest { @After public void release() throws GlUtil.GlException, FrameProcessingException { - if (presentationTextureProcessor != null) { - presentationTextureProcessor.release(); + if (presentationShaderProgram != null) { + presentationShaderProgram.release(); } if (eglContext != null && eglDisplay != null) { GlUtil.destroyEglContext(eglDisplay, eglContext); @@ -103,14 +103,14 @@ public final class PresentationPixelTest { @Test public void drawFrame_noEdits_matchesGoldenFile() throws Exception { String testId = "drawFrame_noEdits"; - presentationTextureProcessor = + presentationShaderProgram = Presentation.createForHeight(C.LENGTH_UNSET) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = presentationShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); - presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + presentationShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -124,14 +124,14 @@ public final class PresentationPixelTest { @Test public void drawFrame_changeAspectRatio_scaleToFit_narrow_matchesGoldenFile() throws Exception { String testId = "drawFrame_changeAspectRatio_scaleToFit_narrow"; - presentationTextureProcessor = + presentationShaderProgram = Presentation.createForAspectRatio(/* aspectRatio= */ 1f, Presentation.LAYOUT_SCALE_TO_FIT) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = presentationShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_SCALE_TO_FIT_NARROW_PNG_ASSET_PATH); - presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + presentationShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -145,14 +145,14 @@ public final class PresentationPixelTest { @Test public void drawFrame_changeAspectRatio_scaleToFit_wide_matchesGoldenFile() throws Exception { String testId = "drawFrame_changeAspectRatio_scaleToFit_wide"; - presentationTextureProcessor = + presentationShaderProgram = Presentation.createForAspectRatio(/* aspectRatio= */ 2f, Presentation.LAYOUT_SCALE_TO_FIT) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = presentationShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WIDE_PNG_ASSET_PATH); - presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + presentationShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -167,15 +167,15 @@ public final class PresentationPixelTest { public void drawFrame_changeAspectRatio_scaleToFitWithCrop_narrow_matchesGoldenFile() throws Exception { String testId = "drawFrame_changeAspectRatio_scaleToFitWithCrop_narrow"; - presentationTextureProcessor = + presentationShaderProgram = Presentation.createForAspectRatio( /* aspectRatio= */ 1f, Presentation.LAYOUT_SCALE_TO_FIT_WITH_CROP) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = presentationShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_NARROW_PNG_ASSET_PATH); - presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + presentationShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -190,15 +190,15 @@ public final class PresentationPixelTest { public void drawFrame_changeAspectRatio_scaleToFitWithCrop_wide_matchesGoldenFile() throws Exception { String testId = "drawFrame_changeAspectRatio_scaleToFitWithCrop_wide"; - presentationTextureProcessor = + presentationShaderProgram = Presentation.createForAspectRatio( /* aspectRatio= */ 2f, Presentation.LAYOUT_SCALE_TO_FIT_WITH_CROP) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = presentationShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_SCALE_TO_FIT_WITH_CROP_WIDE_PNG_ASSET_PATH); - presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + presentationShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -212,14 +212,14 @@ public final class PresentationPixelTest { @Test public void drawFrame_changeAspectRatio_stretchToFit_narrow_matchesGoldenFile() throws Exception { String testId = "drawFrame_changeAspectRatio_stretchToFit_narrow"; - presentationTextureProcessor = + presentationShaderProgram = Presentation.createForAspectRatio(/* aspectRatio= */ 1f, Presentation.LAYOUT_STRETCH_TO_FIT) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = presentationShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_STRETCH_TO_FIT_NARROW_PNG_ASSET_PATH); - presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + presentationShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -233,14 +233,14 @@ public final class PresentationPixelTest { @Test public void drawFrame_changeAspectRatio_stretchToFit_wide_matchesGoldenFile() throws Exception { String testId = "drawFrame_changeAspectRatio_stretchToFit_wide"; - presentationTextureProcessor = + presentationShaderProgram = Presentation.createForAspectRatio(/* aspectRatio= */ 2f, Presentation.LAYOUT_STRETCH_TO_FIT) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = presentationTextureProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = presentationShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(ASPECT_RATIO_STRETCH_TO_FIT_WIDE_PNG_ASSET_PATH); - presentationTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + presentationShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java index 16bebb9374..d668be3f98 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java @@ -69,7 +69,7 @@ public final class RgbAdjustmentPixelTest { private @MonotonicNonNull EGLDisplay eglDisplay; private @MonotonicNonNull EGLContext eglContext; - private @MonotonicNonNull SingleFrameGlTextureProcessor matrixTextureProcessor; + private @MonotonicNonNull SingleFrameGlShaderProgram matrixShaderProgram; private @MonotonicNonNull EGLSurface placeholderEglSurface; private int inputTexId; private int inputWidth; @@ -100,8 +100,8 @@ public final class RgbAdjustmentPixelTest { @After public void release() throws GlUtil.GlException, FrameProcessingException { - if (matrixTextureProcessor != null) { - matrixTextureProcessor.release(); + if (matrixShaderProgram != null) { + matrixShaderProgram.release(); } GlUtil.destroyEglContext(eglDisplay, eglContext); } @@ -110,11 +110,11 @@ public final class RgbAdjustmentPixelTest { public void drawFrame_identityMatrix_leavesFrameUnchanged() throws Exception { String testId = "drawFrame_identityMatrix"; RgbMatrix identityMatrix = new RgbAdjustment.Builder().build(); - matrixTextureProcessor = identityMatrix.toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); + matrixShaderProgram = identityMatrix.toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = matrixShaderProgram.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); - matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + matrixShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -129,13 +129,13 @@ public final class RgbAdjustmentPixelTest { String testId = "drawFrame_removeColors"; RgbMatrix removeColorMatrix = new RgbAdjustment.Builder().setRedScale(0).setGreenScale(0).setBlueScale(0).build(); - matrixTextureProcessor = removeColorMatrix.toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); + matrixShaderProgram = removeColorMatrix.toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = matrixShaderProgram.configure(inputWidth, inputHeight); Bitmap expectedBitmap = createArgb8888BitmapWithSolidColor( outputSize.getWidth(), outputSize.getHeight(), Color.BLACK); - matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + matrixShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -149,11 +149,11 @@ public final class RgbAdjustmentPixelTest { public void drawFrame_redOnlyFilter_removeBlueAndGreenValues() throws Exception { String testId = "drawFrame_redOnlyFilter"; RgbMatrix redOnlyMatrix = new RgbAdjustment.Builder().setBlueScale(0).setGreenScale(0).build(); - matrixTextureProcessor = redOnlyMatrix.toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); + matrixShaderProgram = redOnlyMatrix.toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = matrixShaderProgram.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(ONLY_RED_CHANNEL_PNG_ASSET_PATH); - matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + matrixShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -167,11 +167,11 @@ public final class RgbAdjustmentPixelTest { public void drawFrame_increaseRedChannel_producesBrighterAndRedderFrame() throws Exception { String testId = "drawFrame_increaseRedChannel"; RgbMatrix increaseRedMatrix = new RgbAdjustment.Builder().setRedScale(5).build(); - matrixTextureProcessor = increaseRedMatrix.toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); + matrixShaderProgram = increaseRedMatrix.toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = matrixShaderProgram.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(INCREASE_RED_CHANNEL_PNG_ASSET_PATH); - matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + matrixShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -186,12 +186,11 @@ public final class RgbAdjustmentPixelTest { String testId = "drawFrame_increaseBrightness"; RgbMatrix increaseBrightnessMatrix = new RgbAdjustment.Builder().setRedScale(5).setGreenScale(5).setBlueScale(5).build(); - matrixTextureProcessor = - increaseBrightnessMatrix.toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); + matrixShaderProgram = increaseBrightnessMatrix.toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = matrixShaderProgram.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(INCREASE_BRIGHTNESS_PNG_ASSET_PATH); - matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + matrixShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -207,18 +206,18 @@ public final class RgbAdjustmentPixelTest { RgbMatrix noRed = new RgbAdjustment.Builder().setRedScale(0).build(); RgbMatrix noGreen = new RgbAdjustment.Builder().setGreenScale(0).build(); RgbMatrix noBlue = new RgbAdjustment.Builder().setBlueScale(0).build(); - matrixTextureProcessor = - MatrixTextureProcessor.create( + matrixShaderProgram = + MatrixShaderProgram.create( context, /* matrixTransformations= */ ImmutableList.of(), /* rgbMatrices= */ ImmutableList.of(noRed, noGreen, noBlue), /* useHdr= */ false); - Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); + Size outputSize = matrixShaderProgram.configure(inputWidth, inputHeight); Bitmap expectedBitmap = createArgb8888BitmapWithSolidColor( outputSize.getWidth(), outputSize.getHeight(), Color.BLACK); - matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + matrixShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -233,16 +232,16 @@ public final class RgbAdjustmentPixelTest { String testId = "drawFrame_removeBlueAndGreenValuesInAChain"; RgbMatrix noGreen = new RgbAdjustment.Builder().setGreenScale(0).build(); RgbMatrix noBlue = new RgbAdjustment.Builder().setBlueScale(0).build(); - matrixTextureProcessor = - MatrixTextureProcessor.create( + matrixShaderProgram = + MatrixShaderProgram.create( context, /* matrixTransformations= */ ImmutableList.of(), /* rgbMatrices= */ ImmutableList.of(noGreen, noBlue), /* useHdr= */ false); - Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); + Size outputSize = matrixShaderProgram.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(ONLY_RED_CHANNEL_PNG_ASSET_PATH); - matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + matrixShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -259,16 +258,16 @@ public final class RgbAdjustmentPixelTest { RgbMatrix scaleRedMatrix = new RgbAdjustment.Builder().setRedScale(redScale).build(); RgbMatrix scaleRedByInverseMatrix = new RgbAdjustment.Builder().setRedScale(1 / redScale).build(); - matrixTextureProcessor = - MatrixTextureProcessor.create( + matrixShaderProgram = + MatrixShaderProgram.create( context, /* matrixTransformations= */ ImmutableList.of(), /* rgbMatrices= */ ImmutableList.of(scaleRedMatrix, scaleRedByInverseMatrix), /* useHdr= */ false); - Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); + Size outputSize = matrixShaderProgram.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); - matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + matrixShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java index 6a174515b6..acec4526d3 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java @@ -64,7 +64,7 @@ public final class RgbFilterPixelTest { private @MonotonicNonNull EGLDisplay eglDisplay; private @MonotonicNonNull EGLContext eglContext; - private @MonotonicNonNull SingleFrameGlTextureProcessor matrixTextureProcessor; + private @MonotonicNonNull SingleFrameGlShaderProgram matrixShaderProgram; private @MonotonicNonNull EGLSurface placeholderEglSurface; private int inputTexId; private int inputWidth; @@ -95,8 +95,8 @@ public final class RgbFilterPixelTest { @After public void release() throws GlUtil.GlException, FrameProcessingException { - if (matrixTextureProcessor != null) { - matrixTextureProcessor.release(); + if (matrixShaderProgram != null) { + matrixShaderProgram.release(); } GlUtil.destroyEglContext(eglDisplay, eglContext); } @@ -105,11 +105,11 @@ public final class RgbFilterPixelTest { public void drawFrame_grayscale_producesGrayscaleImage() throws Exception { String testId = "drawFrame_grayscale"; RgbMatrix grayscaleMatrix = RgbFilter.createGrayscaleFilter(); - matrixTextureProcessor = grayscaleMatrix.toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); + matrixShaderProgram = grayscaleMatrix.toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = matrixShaderProgram.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(GRAYSCALE_PNG_ASSET_PATH); - matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + matrixShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -123,11 +123,11 @@ public final class RgbFilterPixelTest { public void drawFrame_inverted_producesInvertedFrame() throws Exception { String testId = "drawFrame_inverted"; RgbMatrix invertedMatrix = RgbFilter.createInvertedFilter(); - matrixTextureProcessor = invertedMatrix.toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = matrixTextureProcessor.configure(inputWidth, inputHeight); + matrixShaderProgram = invertedMatrix.toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = matrixShaderProgram.configure(inputWidth, inputHeight); Bitmap expectedBitmap = readBitmap(INVERT_PNG_ASSET_PATH); - matrixTextureProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + matrixShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java index be7ea88149..56a1a89d73 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java @@ -44,7 +44,7 @@ import org.junit.Test; import org.junit.runner.RunWith; /** - * Pixel test for Lookup Tables via {@link ColorLutProcessor}. + * Pixel test for Lookup Tables via {@link ColorLutShaderProgram}. * *
Expected images are taken from an emulator, so tests on different emulators or physical * devices may fail. To test on other devices, please increase the {@link @@ -70,7 +70,7 @@ public class SingleColorLutPixelTest { private @MonotonicNonNull EGLDisplay eglDisplay; private @MonotonicNonNull EGLContext eglContext; private @MonotonicNonNull EGLSurface placeholderEglSurface; - private @MonotonicNonNull SingleFrameGlTextureProcessor colorLutProcessor; + private @MonotonicNonNull SingleFrameGlShaderProgram colorLutShaderProgram; private int inputTexId; private int inputWidth; private int inputHeight; @@ -89,8 +89,8 @@ public class SingleColorLutPixelTest { @After public void release() throws GlUtil.GlException, FrameProcessingException { - if (colorLutProcessor != null) { - colorLutProcessor.release(); + if (colorLutShaderProgram != null) { + colorLutShaderProgram.release(); } GlUtil.destroyEglContext(eglDisplay, eglContext); } @@ -99,14 +99,14 @@ public class SingleColorLutPixelTest { public void drawFrame_identityCubeLutSize2_leavesFrameUnchanged() throws Exception { String testId = "drawFrame_identityLutCubeSize2"; int[][][] cubeIdentityLut = createIdentityLutCube(/* length= */ 2); - colorLutProcessor = + colorLutShaderProgram = SingleColorLut.createFromCube(cubeIdentityLut) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = colorLutProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = colorLutShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); - colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + colorLutShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -120,14 +120,14 @@ public class SingleColorLutPixelTest { public void drawFrame_identityCubeLutSize64_leavesFrameUnchanged() throws Exception { String testId = "drawFrame_identityLutCubeSize64"; int[][][] cubeIdentityLut = createIdentityLutCube(/* length= */ 64); - colorLutProcessor = + colorLutShaderProgram = SingleColorLut.createFromCube(cubeIdentityLut) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = colorLutProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = colorLutShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); - colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + colorLutShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -141,14 +141,13 @@ public class SingleColorLutPixelTest { public void drawFrame_identityBitmapLutSize2_leavesFrameUnchanged() throws Exception { String testId = "drawFrame_identityBitmapLutSize2"; Bitmap bitmapLut = createIdentityLutBitmap(/* length= */ 2); - colorLutProcessor = - SingleColorLut.createFromBitmap(bitmapLut) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = colorLutProcessor.configure(inputWidth, inputHeight); + colorLutShaderProgram = + SingleColorLut.createFromBitmap(bitmapLut).toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = colorLutShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); - colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + colorLutShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -162,14 +161,13 @@ public class SingleColorLutPixelTest { public void drawFrame_identityBitmapLutSize64_leavesFrameUnchanged() throws Exception { String testId = "drawFrame_identityBitmapLutSize64"; Bitmap bitmapLut = createIdentityLutBitmap(/* length= */ 64); - colorLutProcessor = - SingleColorLut.createFromBitmap(bitmapLut) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = colorLutProcessor.configure(inputWidth, inputHeight); + colorLutShaderProgram = + SingleColorLut.createFromBitmap(bitmapLut).toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = colorLutShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); - colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + colorLutShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -183,14 +181,13 @@ public class SingleColorLutPixelTest { public void drawFrame_identityLutFromHaldImage_leavesFrameUnchanged() throws Exception { String testId = "drawFrame_identityLutFromHaldImage"; Bitmap bitmapLut = readBitmap(VERTICAL_HALD_IDENTITY_LUT); - colorLutProcessor = - SingleColorLut.createFromBitmap(bitmapLut) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = colorLutProcessor.configure(inputWidth, inputHeight); + colorLutShaderProgram = + SingleColorLut.createFromBitmap(bitmapLut).toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = colorLutShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); - colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + colorLutShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -206,14 +203,14 @@ public class SingleColorLutPixelTest { int length = 3; int[][][] mapWhiteToGreen = createIdentityLutCube(length); mapWhiteToGreen[length - 1][length - 1][length - 1] = Color.GREEN; - colorLutProcessor = + colorLutShaderProgram = SingleColorLut.createFromCube(mapWhiteToGreen) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = colorLutProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = colorLutShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(LUT_MAP_WHITE_TO_GREEN_ASSET_PATH); - colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + colorLutShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -227,14 +224,14 @@ public class SingleColorLutPixelTest { public void drawFrame_applyInvertedLut_producesInvertedFrame() throws Exception { String testId = "drawFrame_applyInvertedLut"; Bitmap invertedLutBitmap = readBitmap(VERTICAL_HALD_INVERTED_LUT); - colorLutProcessor = + colorLutShaderProgram = SingleColorLut.createFromBitmap(invertedLutBitmap) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = colorLutProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = colorLutShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(INVERT_PNG_ASSET_PATH); - colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + colorLutShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); @@ -248,14 +245,14 @@ public class SingleColorLutPixelTest { public void drawFrame_applyGrayscaleLut_producesGrayscaleFrame() throws Exception { String testId = "drawFrame_applyGrayscaleLut"; Bitmap grayscaleLutBitmap = readBitmap(VERTICAL_HALD_GRAYSCALE_LUT); - colorLutProcessor = + colorLutShaderProgram = SingleColorLut.createFromBitmap(grayscaleLutBitmap) - .toGlTextureProcessor(context, /* useHdr= */ false); - Size outputSize = colorLutProcessor.configure(inputWidth, inputHeight); + .toGlShaderProgram(context, /* useHdr= */ false); + Size outputSize = colorLutShaderProgram.configure(inputWidth, inputHeight); setupOutputTexture(outputSize.getWidth(), outputSize.getHeight()); Bitmap expectedBitmap = readBitmap(GRAYSCALE_PNG_ASSET_PATH); - colorLutProcessor.drawFrame(inputTexId, /* presentationTimeUs= */ 0); + colorLutShaderProgram.drawFrame(inputTexId, /* presentationTimeUs= */ 0); Bitmap actualBitmap = createArgb8888BitmapFromCurrentGlFramebuffer(outputSize.getWidth(), outputSize.getHeight()); diff --git a/libraries/effect/src/main/java/androidx/media3/effect/ChainingGlTextureProcessorListener.java b/libraries/effect/src/main/java/androidx/media3/effect/ChainingGlShaderProgramListener.java similarity index 56% rename from libraries/effect/src/main/java/androidx/media3/effect/ChainingGlTextureProcessorListener.java rename to libraries/effect/src/main/java/androidx/media3/effect/ChainingGlShaderProgramListener.java index dd287bc766..643d516093 100644 --- a/libraries/effect/src/main/java/androidx/media3/effect/ChainingGlTextureProcessorListener.java +++ b/libraries/effect/src/main/java/androidx/media3/effect/ChainingGlShaderProgramListener.java @@ -19,48 +19,48 @@ import android.util.Pair; import androidx.annotation.GuardedBy; import androidx.annotation.Nullable; import androidx.media3.common.C; -import androidx.media3.effect.GlTextureProcessor.InputListener; -import androidx.media3.effect.GlTextureProcessor.OutputListener; +import androidx.media3.effect.GlShaderProgram.InputListener; +import androidx.media3.effect.GlShaderProgram.OutputListener; import java.util.ArrayDeque; import java.util.Queue; /** - * Connects a producing and a consuming {@link GlTextureProcessor} instance. + * Connects a producing and a consuming {@link GlShaderProgram} instance. * - *
This listener should be set as {@link InputListener} on the consuming {@link - * GlTextureProcessor} and as {@link OutputListener} on the producing {@link GlTextureProcessor}. + *
This listener should be set as {@link InputListener} on the consuming {@link GlShaderProgram}
+ * and as {@link OutputListener} on the producing {@link GlShaderProgram}.
*/
-/* package */ final class ChainingGlTextureProcessorListener
- implements GlTextureProcessor.InputListener, GlTextureProcessor.OutputListener {
+/* package */ final class ChainingGlShaderProgramListener
+ implements GlShaderProgram.InputListener, GlShaderProgram.OutputListener {
- private final GlTextureProcessor producingGlTextureProcessor;
- private final GlTextureProcessor consumingGlTextureProcessor;
+ private final GlShaderProgram producingGlShaderProgram;
+ private final GlShaderProgram consumingGlShaderProgram;
private final FrameProcessingTaskExecutor frameProcessingTaskExecutor;
@GuardedBy("this")
private final Queue Use {@link #setTextureTransformMatrix(float[])} to provide the texture's transformation
* matrix.
*/
-/* package */ interface ExternalTextureProcessor extends GlTextureProcessor {
+/* package */ interface ExternalShaderProgram extends GlShaderProgram {
/**
* Sets the texture transform matrix for converting an external surface texture's coordinates to
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/ExternalTextureManager.java b/libraries/effect/src/main/java/androidx/media3/effect/ExternalTextureManager.java
index bbbbe435a7..51060d9dee 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/ExternalTextureManager.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/ExternalTextureManager.java
@@ -25,26 +25,26 @@ import androidx.media3.common.FrameInfo;
import androidx.media3.common.FrameProcessingException;
import androidx.media3.common.FrameProcessor;
import androidx.media3.common.util.GlUtil;
-import androidx.media3.effect.GlTextureProcessor.InputListener;
+import androidx.media3.effect.GlShaderProgram.InputListener;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Forwards externally produced frames that become available via a {@link SurfaceTexture} to an
- * {@link ExternalTextureProcessor} for consumption.
+ * {@link ExternalShaderProgram} for consumption.
*/
/* package */ class ExternalTextureManager implements InputListener {
private final FrameProcessingTaskExecutor frameProcessingTaskExecutor;
- private final ExternalTextureProcessor externalTextureProcessor;
+ private final ExternalShaderProgram externalShaderProgram;
private final int externalTexId;
private final SurfaceTexture surfaceTexture;
private final float[] textureTransformMatrix;
private final Queue Can be called on any thread.
*/
@@ -166,7 +166,7 @@ import java.util.concurrent.atomic.AtomicInteger;
() -> {
inputStreamEnded = true;
if (pendingFrames.isEmpty() && currentFrame == null) {
- externalTextureProcessor.signalEndOfCurrentInputStream();
+ externalShaderProgram.signalEndOfCurrentInputStream();
}
});
}
@@ -183,7 +183,7 @@ import java.util.concurrent.atomic.AtomicInteger;
availableFrameCount--;
surfaceTexture.updateTexImage();
}
- externalTextureProcessorInputCapacity.set(0);
+ externalShaderProgramInputCapacity.set(0);
currentFrame = null;
pendingFrames.clear();
maybeExecuteAfterFlushTask();
@@ -197,8 +197,8 @@ import java.util.concurrent.atomic.AtomicInteger;
}
@WorkerThread
- private void maybeQueueFrameToExternalTextureProcessor() {
- if (externalTextureProcessorInputCapacity.get() == 0
+ private void maybeQueueFrameToExternalShaderProgram() {
+ if (externalShaderProgramInputCapacity.get() == 0
|| availableFrameCount == 0
|| currentFrame != null) {
return;
@@ -209,28 +209,28 @@ import java.util.concurrent.atomic.AtomicInteger;
this.currentFrame = pendingFrames.peek();
FrameInfo currentFrame = checkStateNotNull(this.currentFrame);
- externalTextureProcessorInputCapacity.decrementAndGet();
+ externalShaderProgramInputCapacity.decrementAndGet();
surfaceTexture.getTransformMatrix(textureTransformMatrix);
- externalTextureProcessor.setTextureTransformMatrix(textureTransformMatrix);
+ externalShaderProgram.setTextureTransformMatrix(textureTransformMatrix);
long frameTimeNs = surfaceTexture.getTimestamp();
long offsetToAddUs = currentFrame.offsetToAddUs;
long streamOffsetUs = currentFrame.streamOffsetUs;
if (streamOffsetUs != previousStreamOffsetUs) {
if (previousStreamOffsetUs != C.TIME_UNSET) {
- externalTextureProcessor.signalEndOfCurrentInputStream();
+ externalShaderProgram.signalEndOfCurrentInputStream();
}
previousStreamOffsetUs = streamOffsetUs;
}
- // Correct the presentation time so that processors don't see the stream offset.
+ // Correct the presentation time so that GlShaderPrograms don't see the stream offset.
long presentationTimeUs = (frameTimeNs / 1000) + offsetToAddUs - streamOffsetUs;
- externalTextureProcessor.queueInputFrame(
+ externalShaderProgram.queueInputFrame(
new TextureInfo(
externalTexId, /* fboId= */ C.INDEX_UNSET, currentFrame.width, currentFrame.height),
presentationTimeUs);
checkStateNotNull(pendingFrames.remove());
if (inputStreamEnded && pendingFrames.isEmpty()) {
- externalTextureProcessor.signalEndOfCurrentInputStream();
+ externalShaderProgram.signalEndOfCurrentInputStream();
}
}
}
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixTextureProcessorWrapper.java b/libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixShaderProgramWrapper.java
similarity index 87%
rename from libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixTextureProcessorWrapper.java
rename to libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixShaderProgramWrapper.java
index bc6ee16cc3..942ee65214 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixTextureProcessorWrapper.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixShaderProgramWrapper.java
@@ -51,19 +51,19 @@ import org.checkerframework.checker.nullness.qual.EnsuresNonNullIf;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
/**
- * Wrapper around a {@link GlTextureProcessor} that writes to the provided output surface and
- * optional debug surface view.
+ * Wrapper around a {@link GlShaderProgram} that writes to the provided output surface and optional
+ * debug surface view.
*
- * The wrapped {@link GlTextureProcessor} applies the {@link GlMatrixTransformation} and {@link
+ * The wrapped {@link GlShaderProgram} applies the {@link GlMatrixTransformation} and {@link
* RgbMatrix} instances passed to the constructor, followed by any transformations needed to convert
* the frames to the dimensions specified by the provided {@link SurfaceInfo}.
*
- * This wrapper is used for the final {@link GlTextureProcessor} instance in the chain of {@link
- * GlTextureProcessor} instances used by {@link FrameProcessor}.
+ * This wrapper is used for the final {@link GlShaderProgram} instance in the chain of {@link
+ * GlShaderProgram} instances used by {@link FrameProcessor}.
*/
-/* package */ final class FinalMatrixTextureProcessorWrapper implements ExternalTextureProcessor {
+/* package */ final class FinalMatrixShaderProgramWrapper implements ExternalShaderProgram {
- private static final String TAG = "FinalProcessorWrapper";
+ private static final String TAG = "FinalShaderWrapper";
private final Context context;
private final ImmutableList Implements {@link FrameCache}.
*/
-/* package */ class FrameCacheTextureProcessor implements GlTextureProcessor {
+/* package */ class FrameCacheShaderProgram implements GlShaderProgram {
private static final String VERTEX_SHADER_TRANSFORMATION_ES2_PATH =
"shaders/vertex_shader_transformation_es2.glsl";
private static final String FRAGMENT_SHADER_TRANSFORMATION_ES2_PATH =
@@ -53,7 +53,7 @@ import java.util.concurrent.Executor;
private Executor errorListenerExecutor;
/** Creates a new instance. */
- public FrameCacheTextureProcessor(Context context, int capacity, boolean useHdr)
+ public FrameCacheShaderProgram(Context context, int capacity, boolean useHdr)
throws FrameProcessingException {
freeOutputTextures = new ArrayDeque<>();
inUseOutputTextures = new ArrayDeque<>();
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/GlEffect.java b/libraries/effect/src/main/java/androidx/media3/effect/GlEffect.java
index 4ddf1f80f7..3d67934e38 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/GlEffect.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/GlEffect.java
@@ -21,24 +21,23 @@ import androidx.media3.common.FrameProcessingException;
import androidx.media3.common.util.UnstableApi;
/**
- * Interface for a video frame effect with a {@link GlTextureProcessor} implementation.
+ * Interface for a video frame effect with a {@link GlShaderProgram} implementation.
*
* Implementations contain information specifying the effect and can be {@linkplain
- * #toGlTextureProcessor(Context, boolean) converted} to a {@link GlTextureProcessor} which applies
- * the effect.
+ * #toGlShaderProgram(Context, boolean) converted} to a {@link GlShaderProgram} which applies the
+ * effect.
*/
@UnstableApi
public interface GlEffect extends Effect {
/**
- * Returns a {@link GlTextureProcessor} that applies the effect.
+ * Returns a {@link GlShaderProgram} that applies the effect.
*
* @param context A {@link Context}.
* @param useHdr Whether input textures come from an HDR source. If {@code true}, colors will be
* in linear RGB BT.2020. If {@code false}, colors will be in linear RGB BT.709.
- * @throws FrameProcessingException If an error occurs while creating the {@link
- * GlTextureProcessor}.
+ * @throws FrameProcessingException If an error occurs while creating the {@link GlShaderProgram}.
*/
- GlTextureProcessor toGlTextureProcessor(Context context, boolean useHdr)
+ GlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
throws FrameProcessingException;
}
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/GlEffectsFrameProcessor.java b/libraries/effect/src/main/java/androidx/media3/effect/GlEffectsFrameProcessor.java
index 886c1f822f..16eb2c74d7 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/GlEffectsFrameProcessor.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/GlEffectsFrameProcessor.java
@@ -152,8 +152,8 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
/**
* Creates the OpenGL context, surfaces, textures, and frame buffers, initializes {@link
- * GlTextureProcessor} instances corresponding to the {@link GlEffect} instances, and returns a
- * new {@code GlEffectsFrameProcessor}.
+ * GlShaderProgram} instances corresponding to the {@link GlEffect} instances, and returns a new
+ * {@code GlEffectsFrameProcessor}.
*
* All {@link Effect} instances must be {@link GlEffect} instances.
*
@@ -199,8 +199,8 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
}
}
- ImmutableList All {@link Effect} instances must be {@link GlEffect} instances.
*
- * @return A non-empty list of {@link GlTextureProcessor} instances to apply in the given order.
- * The first is an {@link ExternalTextureProcessor} and the last is a {@link
- * FinalMatrixTextureProcessorWrapper}.
+ * @return A non-empty list of {@link GlShaderProgram} instances to apply in the given order. The
+ * first is an {@link ExternalShaderProgram} and the last is a {@link
+ * FinalMatrixShaderProgramWrapper}.
*/
- private static ImmutableList This method must be called on the {@linkplain #THREAD_NAME background thread}.
*/
@WorkerThread
- private void releaseTextureProcessorsAndDestroyGlContext()
+ private void releaseShaderProgramsAndDestroyGlContext()
throws GlUtil.GlException, FrameProcessingException {
- for (int i = 0; i < allTextureProcessors.size(); i++) {
- allTextureProcessors.get(i).release();
+ for (int i = 0; i < allShaderPrograms.size(); i++) {
+ allShaderPrograms.get(i).release();
}
GlUtil.destroyEglContext(eglDisplay, eglContext);
}
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/GlMatrixTransformation.java b/libraries/effect/src/main/java/androidx/media3/effect/GlMatrixTransformation.java
index 624ecfbc62..26ba322604 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/GlMatrixTransformation.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/GlMatrixTransformation.java
@@ -53,9 +53,9 @@ public interface GlMatrixTransformation extends GlEffect {
float[] getGlMatrixArray(long presentationTimeUs);
@Override
- default SingleFrameGlTextureProcessor toGlTextureProcessor(Context context, boolean useHdr)
+ default SingleFrameGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
throws FrameProcessingException {
- return MatrixTextureProcessor.create(
+ return MatrixShaderProgram.create(
context,
/* matrixTransformations= */ ImmutableList.of(this),
/* rgbMatrices= */ ImmutableList.of(),
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/GlTextureProcessor.java b/libraries/effect/src/main/java/androidx/media3/effect/GlShaderProgram.java
similarity index 67%
rename from libraries/effect/src/main/java/androidx/media3/effect/GlTextureProcessor.java
rename to libraries/effect/src/main/java/androidx/media3/effect/GlShaderProgram.java
index a23f640cac..a7511c270d 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/GlTextureProcessor.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/GlShaderProgram.java
@@ -22,29 +22,29 @@ import java.util.concurrent.Executor;
/**
* Processes frames from one OpenGL 2D texture to another.
*
- * The {@code GlTextureProcessor} consumes input frames it accepts via {@link
+ * The {@code GlShaderProgram} consumes input frames it accepts via {@link
* #queueInputFrame(TextureInfo, long)} and surrenders each texture back to the caller via its
* {@linkplain InputListener#onInputFrameProcessed(TextureInfo) listener} once the texture's
* contents have been processed.
*
- * The {@code GlTextureProcessor} produces output frames asynchronously and notifies its owner
- * when they are available via its {@linkplain OutputListener#onOutputFrameAvailable(TextureInfo,
- * long) listener}. The {@code GlTextureProcessor} instance's owner must surrender the texture back
- * to the {@code GlTextureProcessor} via {@link #releaseOutputFrame(TextureInfo)} when it has
- * finished processing it.
+ * The {@code GlShaderProgram} produces output frames asynchronously and notifies its owner when
+ * they are available via its {@linkplain OutputListener#onOutputFrameAvailable(TextureInfo, long)
+ * listener}. The {@code GlShaderProgram} instance's owner must surrender the texture back to the
+ * {@code GlShaderProgram} via {@link #releaseOutputFrame(TextureInfo)} when it has finished
+ * processing it.
*
- * {@code GlTextureProcessor} implementations can choose to produce output frames before
- * receiving input frames or process several input frames before producing an output frame. However,
- * {@code GlTextureProcessor} implementations cannot assume that they will receive more than one
- * input frame at a time, so they must process each input frame they accept even if they cannot
- * produce output yet.
+ * {@code GlShaderProgram} implementations can choose to produce output frames before receiving
+ * input frames or process several input frames before producing an output frame. However, {@code
+ * GlShaderProgram} implementations cannot assume that they will receive more than one input frame
+ * at a time, so they must process each input frame they accept even if they cannot produce output
+ * yet.
*
* The methods in this interface must be called on the thread that owns the parent OpenGL
* context. If the implementation uses another OpenGL context, e.g., on another thread, it must
* configure it to share data with the context of thread the interface methods are called on.
*/
@UnstableApi
-public interface GlTextureProcessor {
+public interface GlShaderProgram {
/**
* Listener for input-related frame processing events.
@@ -53,7 +53,7 @@ public interface GlTextureProcessor {
*/
interface InputListener {
/**
- * Called when the {@link GlTextureProcessor} is ready to accept another input frame.
+ * Called when the {@link GlShaderProgram} is ready to accept another input frame.
*
* For each time this method is called, {@link #queueInputFrame(TextureInfo, long)} can be
* called once.
@@ -61,9 +61,9 @@ public interface GlTextureProcessor {
default void onReadyToAcceptInputFrame() {}
/**
- * Called when the {@link GlTextureProcessor} has processed an input frame.
+ * Called when the {@link GlShaderProgram} has processed an input frame.
*
- * The implementation shall not assume the {@link GlTextureProcessor} is {@linkplain
+ * The implementation shall not assume the {@link GlShaderProgram} is {@linkplain
* #onReadyToAcceptInputFrame ready to accept another input frame} when this method is called.
*
* @param inputTexture The {@link TextureInfo} that was used to {@linkplain
@@ -72,9 +72,9 @@ public interface GlTextureProcessor {
default void onInputFrameProcessed(TextureInfo inputTexture) {}
/**
- * Called when the {@link GlTextureProcessor} has been flushed.
+ * Called when the {@link GlShaderProgram} has been flushed.
*
- * The implementation shall not assume the {@link GlTextureProcessor} is {@linkplain
+ * The implementation shall not assume the {@link GlShaderProgram} is {@linkplain
* #onReadyToAcceptInputFrame ready to accept another input frame} when this method is called.
*/
default void onFlush() {}
@@ -87,12 +87,12 @@ public interface GlTextureProcessor {
*/
interface OutputListener {
/**
- * Called when the {@link GlTextureProcessor} has produced an output frame.
+ * Called when the {@link GlShaderProgram} has produced an output frame.
*
* After the listener's owner has processed the output frame, it must call {@link
* #releaseOutputFrame(TextureInfo)}. The output frame should be released as soon as possible,
- * as there is no guarantee that the {@link GlTextureProcessor} will produce further output
- * frames before this output frame is released.
+ * as there is no guarantee that the {@link GlShaderProgram} will produce further output frames
+ * before this output frame is released.
*
* @param outputTexture A {@link TextureInfo} describing the texture containing the output
* frame.
@@ -101,8 +101,8 @@ public interface GlTextureProcessor {
default void onOutputFrameAvailable(TextureInfo outputTexture, long presentationTimeUs) {}
/**
- * Called when the {@link GlTextureProcessor} will not produce further output frames belonging
- * to the current output stream.
+ * Called when the {@link GlShaderProgram} will not produce further output frames belonging to
+ * the current output stream.
*/
default void onCurrentOutputStreamEnded() {}
}
@@ -117,7 +117,7 @@ public interface GlTextureProcessor {
* Called when an exception occurs during asynchronous frame processing.
*
* If an error occurred, consuming and producing further frames will not work as expected and
- * the {@link GlTextureProcessor} should be released.
+ * the {@link GlShaderProgram} should be released.
*/
void onFrameProcessingError(FrameProcessingException e);
}
@@ -150,11 +150,11 @@ public interface GlTextureProcessor {
/**
* Processes an input frame if possible.
*
- * The {@code GlTextureProcessor} owns the accepted frame until it calls {@link
+ * The {@code GlShaderProgram} owns the accepted frame until it calls {@link
* InputListener#onInputFrameProcessed(TextureInfo)}. The caller should not overwrite or release
- * the texture before the {@code GlTextureProcessor} has finished processing it.
+ * the texture before the {@code GlShaderProgram} has finished processing it.
*
- * This method must only be called when the {@code GlTextureProcessor} can {@linkplain
+ * This method must only be called when the {@code GlShaderProgram} can {@linkplain
* InputListener#onReadyToAcceptInputFrame() accept an input frame}.
*
* @param inputTexture A {@link TextureInfo} describing the texture containing the input frame.
@@ -163,13 +163,13 @@ public interface GlTextureProcessor {
void queueInputFrame(TextureInfo inputTexture, long presentationTimeUs);
/**
- * Notifies the texture processor that the frame on the given output texture is no longer used and
- * can be overwritten.
+ * Notifies the {@code GlShaderProgram} that the frame on the given output texture is no longer
+ * used and can be overwritten.
*/
void releaseOutputFrame(TextureInfo outputTexture);
/**
- * Notifies the {@code GlTextureProcessor} that no further input frames belonging to the current
+ * Notifies the {@code GlShaderProgram} that no further input frames belonging to the current
* input stream will be queued.
*
* Input frames that are queued after this method is called belong to a different input stream,
@@ -179,11 +179,11 @@ public interface GlTextureProcessor {
void signalEndOfCurrentInputStream();
/**
- * Flushes the {@code GlTextureProcessor}.
+ * Flushes the {@code GlShaderProgram}.
*
- * The texture processor should reclaim the ownership of its allocated textures, {@linkplain
- * InputListener#onFlush notify} its {@link InputListener} about the flush event, and {@linkplain
- * InputListener#onReadyToAcceptInputFrame report its availability} if necessary.
+ * The {@code GlShaderProgram} should reclaim the ownership of its allocated textures,
+ * {@linkplain InputListener#onFlush notify} its {@link InputListener} about the flush event, and
+ * {@linkplain InputListener#onReadyToAcceptInputFrame report its availability} if necessary.
*/
void flush();
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/HslAdjustment.java b/libraries/effect/src/main/java/androidx/media3/effect/HslAdjustment.java
index 8be8e899ea..36eaf4272c 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/HslAdjustment.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/HslAdjustment.java
@@ -113,8 +113,8 @@ public class HslAdjustment implements GlEffect {
}
@Override
- public SingleFrameGlTextureProcessor toGlTextureProcessor(Context context, boolean useHdr)
+ public SingleFrameGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
throws FrameProcessingException {
- return new HslProcessor(context, /* hslAdjustment= */ this, useHdr);
+ return new HslShaderProgram(context, /* hslAdjustment= */ this, useHdr);
}
}
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/HslProcessor.java b/libraries/effect/src/main/java/androidx/media3/effect/HslShaderProgram.java
similarity index 95%
rename from libraries/effect/src/main/java/androidx/media3/effect/HslProcessor.java
rename to libraries/effect/src/main/java/androidx/media3/effect/HslShaderProgram.java
index 501a725cd1..0244045152 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/HslProcessor.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/HslShaderProgram.java
@@ -27,7 +27,7 @@ import androidx.media3.common.util.Size;
import java.io.IOException;
/** Applies the {@link HslAdjustment} to each frame in the fragment shader. */
-/* package */ final class HslProcessor extends SingleFrameGlTextureProcessor {
+/* package */ final class HslShaderProgram extends SingleFrameGlShaderProgram {
private static final String VERTEX_SHADER_PATH = "shaders/vertex_shader_transformation_es2.glsl";
private static final String FRAGMENT_SHADER_PATH = "shaders/fragment_shader_hsl_es2.glsl";
@@ -42,7 +42,7 @@ import java.io.IOException;
* in linear RGB BT.2020. If {@code false}, colors will be in linear RGB BT.709.
* @throws FrameProcessingException If a problem occurs while reading shader files.
*/
- public HslProcessor(Context context, HslAdjustment hslAdjustment, boolean useHdr)
+ public HslShaderProgram(Context context, HslAdjustment hslAdjustment, boolean useHdr)
throws FrameProcessingException {
super(useHdr);
// TODO(b/241241680): Check if HDR <-> HSL works the same or not.
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/MatrixTextureProcessor.java b/libraries/effect/src/main/java/androidx/media3/effect/MatrixShaderProgram.java
similarity index 96%
rename from libraries/effect/src/main/java/androidx/media3/effect/MatrixTextureProcessor.java
rename to libraries/effect/src/main/java/androidx/media3/effect/MatrixShaderProgram.java
index 3dad757001..f14a96089f 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/MatrixTextureProcessor.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/MatrixShaderProgram.java
@@ -52,8 +52,8 @@ import java.util.List;
*/
@UnstableApi
@SuppressWarnings("FunctionalInterfaceClash") // b/228192298
-/* package */ final class MatrixTextureProcessor extends SingleFrameGlTextureProcessor
- implements ExternalTextureProcessor {
+/* package */ final class MatrixShaderProgram extends SingleFrameGlShaderProgram
+ implements ExternalShaderProgram {
private static final String VERTEX_SHADER_TRANSFORMATION_PATH =
"shaders/vertex_shader_transformation_es2.glsl";
@@ -144,7 +144,7 @@ import java.util.List;
* @throws FrameProcessingException If a problem occurs while reading shader files or an OpenGL
* operation fails or is unsupported.
*/
- public static MatrixTextureProcessor create(
+ public static MatrixShaderProgram create(
Context context,
List Applies the {@linkplain ColorInfo#colorTransfer inputColorInfo EOTF} to convert from
- * electrical color input, to intermediate optical {@link GlTextureProcessor} color output, before
+ * electrical color input, to intermediate optical {@link GlShaderProgram} color output, before
* {@code matrixTransformations} and {@code rgbMatrices} are applied. Also applies the {@linkplain
* ColorInfo#colorTransfer outputColorInfo OETF}, if needed, to convert back to an electrical
* color output.
@@ -188,7 +188,7 @@ import java.util.List;
* @throws FrameProcessingException If a problem occurs while reading shader files or an OpenGL
* operation fails or is unsupported.
*/
- public static MatrixTextureProcessor createWithExternalSampler(
+ public static MatrixShaderProgram createWithExternalSampler(
Context context,
List Applies the {@linkplain ColorInfo#colorTransfer outputColorInfo OETF} to convert from
- * intermediate optical {@link GlTextureProcessor} color input, to electrical color output, after
+ * intermediate optical {@link GlShaderProgram} color input, to electrical color output, after
* {@code matrixTransformations} and {@code rgbMatrices} are applied.
*
* Intermediate optical/linear colors are RGB BT.2020 if {@code outputColorInfo} is {@linkplain
@@ -269,7 +269,7 @@ import java.util.List;
* @throws FrameProcessingException If a problem occurs while reading shader files or an OpenGL
* operation fails or is unsupported.
*/
- public static MatrixTextureProcessor createApplyingOetf(
+ public static MatrixShaderProgram createApplyingOetf(
Context context,
List This method must not be called on {@code MatrixTextureProcessor} instances that output
+ * This method must not be called on {@code MatrixShaderProgram} instances that output
* {@linkplain C#COLOR_TRANSFER_LINEAR linear colors}.
*/
public void setOutputColorTransfer(@C.ColorTransfer int colorTransfer) {
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/OverlayEffect.java b/libraries/effect/src/main/java/androidx/media3/effect/OverlayEffect.java
index bdb2483fa3..1bc21cf267 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/OverlayEffect.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/OverlayEffect.java
@@ -39,8 +39,8 @@ public final class OverlayEffect implements GlEffect {
}
@Override
- public SingleFrameGlTextureProcessor toGlTextureProcessor(Context context, boolean useHdr)
+ public SingleFrameGlShaderProgram toGlShaderProgram(Context context, boolean useHdr)
throws FrameProcessingException {
- return new OverlayTextureProcessor(context, useHdr, overlays);
+ return new OverlayShaderProgram(context, useHdr, overlays);
}
}
diff --git a/libraries/effect/src/main/java/androidx/media3/effect/OverlayTextureProcessor.java b/libraries/effect/src/main/java/androidx/media3/effect/OverlayShaderProgram.java
similarity index 97%
rename from libraries/effect/src/main/java/androidx/media3/effect/OverlayTextureProcessor.java
rename to libraries/effect/src/main/java/androidx/media3/effect/OverlayShaderProgram.java
index 217633bac9..8a0cbe3208 100644
--- a/libraries/effect/src/main/java/androidx/media3/effect/OverlayTextureProcessor.java
+++ b/libraries/effect/src/main/java/androidx/media3/effect/OverlayShaderProgram.java
@@ -29,7 +29,7 @@ import androidx.media3.common.util.Util;
import com.google.common.collect.ImmutableList;
/** Applies zero or more {@link TextureOverlay}s onto each frame. */
-/* package */ final class OverlayTextureProcessor extends SingleFrameGlTextureProcessor {
+/* package */ final class OverlayShaderProgram extends SingleFrameGlShaderProgram {
private static final int MATRIX_OFFSET = 0;
@@ -51,16 +51,16 @@ import com.google.common.collect.ImmutableList;
* in linear RGB BT.2020. If {@code false}, colors will be in linear RGB BT.709.
* @throws FrameProcessingException If a problem occurs while reading shader files.
*/
- public OverlayTextureProcessor(
+ public OverlayShaderProgram(
Context context, boolean useHdr, ImmutableList {@code SingleFrameGlTextureProcessor} implementations must produce exactly one output frame
- * per input frame with the same presentation timestamp. For more flexibility, implement {@link
- * GlTextureProcessor} directly.
+ * {@code SingleFrameGlShaderProgram} implementations must produce exactly one output frame per
+ * input frame with the same presentation timestamp. For more flexibility, implement {@link
+ * GlShaderProgram} directly.
*
* All methods in this class must be called on the thread that owns the OpenGL context.
*/
@UnstableApi
-public abstract class SingleFrameGlTextureProcessor implements GlTextureProcessor {
+public abstract class SingleFrameGlShaderProgram implements GlShaderProgram {
private final boolean useHdr;
@@ -52,12 +52,12 @@ public abstract class SingleFrameGlTextureProcessor implements GlTextureProcesso
private boolean outputTextureInUse;
/**
- * Creates a {@code SingleFrameGlTextureProcessor} instance.
+ * Creates a {@code SingleFrameGlShaderProgram} instance.
*
* @param useHdr Whether input textures come from an HDR source. If {@code true}, colors will be
* in linear RGB BT.2020. If {@code false}, colors will be in linear RGB BT.709.
*/
- public SingleFrameGlTextureProcessor(boolean useHdr) {
+ public SingleFrameGlShaderProgram(boolean useHdr) {
this.useHdr = useHdr;
inputListener = new InputListener() {};
outputListener = new OutputListener() {};
@@ -66,7 +66,7 @@ public abstract class SingleFrameGlTextureProcessor implements GlTextureProcesso
}
/**
- * Configures the texture processor based on the input dimensions.
+ * Configures the instance based on the input dimensions.
*
* This method must be called before {@linkplain #drawFrame(int,long) drawing} the first frame
* and before drawing subsequent frames with different input dimensions.
@@ -81,9 +81,9 @@ public abstract class SingleFrameGlTextureProcessor implements GlTextureProcesso
/**
* Draws one frame.
*
- * This method may only be called after the texture processor has been {@link #configure(int,
- * int) configured}. The caller is responsible for focussing the correct render target before
- * calling this method.
+ * This method may only be called after the shader program has been {@link #configure(int, int)
+ * configured}. The caller is responsible for focussing the correct render target before calling
+ * this method.
*
* A minimal implementation should tell OpenGL to use its shader program, bind the shader
* program's vertex attributes and uniforms, and issue a drawing command.
@@ -118,7 +118,7 @@ public abstract class SingleFrameGlTextureProcessor implements GlTextureProcesso
public final void queueInputFrame(TextureInfo inputTexture, long presentationTimeUs) {
checkState(
!outputTextureInUse,
- "The texture processor does not currently accept input frames. Release prior output frames"
+ "The shader program does not currently accept input frames. Release prior output frames"
+ " first.");
try {
diff --git a/libraries/effect/src/test/java/androidx/media3/effect/ChainingGlTextureProcessorListenerTest.java b/libraries/effect/src/test/java/androidx/media3/effect/ChainingGlShaderProgramListenerTest.java
similarity index 58%
rename from libraries/effect/src/test/java/androidx/media3/effect/ChainingGlTextureProcessorListenerTest.java
rename to libraries/effect/src/test/java/androidx/media3/effect/ChainingGlShaderProgramListenerTest.java
index c3e971ea23..915295360b 100644
--- a/libraries/effect/src/test/java/androidx/media3/effect/ChainingGlTextureProcessorListenerTest.java
+++ b/libraries/effect/src/test/java/androidx/media3/effect/ChainingGlShaderProgramListenerTest.java
@@ -25,9 +25,9 @@ import org.junit.After;
import org.junit.Test;
import org.junit.runner.RunWith;
-/** Tests for {@link ChainingGlTextureProcessorListener}. */
+/** Tests for {@link ChainingGlShaderProgramListener}. */
@RunWith(AndroidJUnit4.class)
-public final class ChainingGlTextureProcessorListenerTest {
+public final class ChainingGlShaderProgramListenerTest {
private static final long EXECUTOR_WAIT_TIME_MS = 100;
private final FrameProcessor.Listener mockFrameProcessorListener =
@@ -35,13 +35,11 @@ public final class ChainingGlTextureProcessorListenerTest {
private final FrameProcessingTaskExecutor frameProcessingTaskExecutor =
new FrameProcessingTaskExecutor(
Util.newSingleThreadExecutor("Test"), mockFrameProcessorListener);
- private final GlTextureProcessor mockProducingGlTextureProcessor = mock(GlTextureProcessor.class);
- private final GlTextureProcessor mockConsumingGlTextureProcessor = mock(GlTextureProcessor.class);
- private final ChainingGlTextureProcessorListener chainingGlTextureProcessorListener =
- new ChainingGlTextureProcessorListener(
- mockProducingGlTextureProcessor,
- mockConsumingGlTextureProcessor,
- frameProcessingTaskExecutor);
+ private final GlShaderProgram mockProducingGlShaderProgram = mock(GlShaderProgram.class);
+ private final GlShaderProgram mockConsumingGlShaderProgram = mock(GlShaderProgram.class);
+ private final ChainingGlShaderProgramListener chainingGlShaderProgramListener =
+ new ChainingGlShaderProgramListener(
+ mockProducingGlShaderProgram, mockConsumingGlShaderProgram, frameProcessingTaskExecutor);
@After
public void release() throws InterruptedException {
@@ -49,47 +47,47 @@ public final class ChainingGlTextureProcessorListenerTest {
}
@Test
- public void onInputFrameProcessed_surrendersFrameToPreviousGlTextureProcessor()
+ public void onInputFrameProcessed_surrendersFrameToPreviousGlShaderProgram()
throws InterruptedException {
TextureInfo texture =
new TextureInfo(/* texId= */ 1, /* fboId= */ 1, /* width= */ 100, /* height= */ 100);
- chainingGlTextureProcessorListener.onInputFrameProcessed(texture);
+ chainingGlShaderProgramListener.onInputFrameProcessed(texture);
Thread.sleep(EXECUTOR_WAIT_TIME_MS);
- verify(mockProducingGlTextureProcessor).releaseOutputFrame(texture);
+ verify(mockProducingGlShaderProgram).releaseOutputFrame(texture);
}
@Test
- public void onOutputFrameAvailable_afterAcceptsInputFrame_passesFrameToNextGlTextureProcessor()
+ public void onOutputFrameAvailable_afterAcceptsInputFrame_passesFrameToNextGlShaderProgram()
throws InterruptedException {
TextureInfo texture =
new TextureInfo(/* texId= */ 1, /* fboId= */ 1, /* width= */ 100, /* height= */ 100);
long presentationTimeUs = 123;
- chainingGlTextureProcessorListener.onReadyToAcceptInputFrame();
- chainingGlTextureProcessorListener.onOutputFrameAvailable(texture, presentationTimeUs);
+ chainingGlShaderProgramListener.onReadyToAcceptInputFrame();
+ chainingGlShaderProgramListener.onOutputFrameAvailable(texture, presentationTimeUs);
Thread.sleep(EXECUTOR_WAIT_TIME_MS);
- verify(mockConsumingGlTextureProcessor).queueInputFrame(texture, presentationTimeUs);
+ verify(mockConsumingGlShaderProgram).queueInputFrame(texture, presentationTimeUs);
}
@Test
- public void onOutputFrameAvailable_beforeAcceptsInputFrame_passesFrameToNextGlTextureProcessor()
+ public void onOutputFrameAvailable_beforeAcceptsInputFrame_passesFrameToNextGlShaderProgram()
throws InterruptedException {
TextureInfo texture =
new TextureInfo(/* texId= */ 1, /* fboId= */ 1, /* width= */ 100, /* height= */ 100);
long presentationTimeUs = 123;
- chainingGlTextureProcessorListener.onOutputFrameAvailable(texture, presentationTimeUs);
- chainingGlTextureProcessorListener.onReadyToAcceptInputFrame();
+ chainingGlShaderProgramListener.onOutputFrameAvailable(texture, presentationTimeUs);
+ chainingGlShaderProgramListener.onReadyToAcceptInputFrame();
Thread.sleep(EXECUTOR_WAIT_TIME_MS);
- verify(mockConsumingGlTextureProcessor).queueInputFrame(texture, presentationTimeUs);
+ verify(mockConsumingGlShaderProgram).queueInputFrame(texture, presentationTimeUs);
}
@Test
- public void onOutputFrameAvailable_twoFrames_passesFirstBeforeSecondToNextGlTextureProcessor()
+ public void onOutputFrameAvailable_twoFrames_passesFirstBeforeSecondToNextGlShaderProgram()
throws InterruptedException {
TextureInfo firstTexture =
new TextureInfo(/* texId= */ 1, /* fboId= */ 1, /* width= */ 100, /* height= */ 100);
@@ -98,25 +96,22 @@ public final class ChainingGlTextureProcessorListenerTest {
new TextureInfo(/* texId= */ 2, /* fboId= */ 2, /* width= */ 100, /* height= */ 100);
long secondPresentationTimeUs = 567;
- chainingGlTextureProcessorListener.onOutputFrameAvailable(
- firstTexture, firstPresentationTimeUs);
- chainingGlTextureProcessorListener.onOutputFrameAvailable(
- secondTexture, secondPresentationTimeUs);
- chainingGlTextureProcessorListener.onReadyToAcceptInputFrame();
- chainingGlTextureProcessorListener.onReadyToAcceptInputFrame();
+ chainingGlShaderProgramListener.onOutputFrameAvailable(firstTexture, firstPresentationTimeUs);
+ chainingGlShaderProgramListener.onOutputFrameAvailable(secondTexture, secondPresentationTimeUs);
+ chainingGlShaderProgramListener.onReadyToAcceptInputFrame();
+ chainingGlShaderProgramListener.onReadyToAcceptInputFrame();
Thread.sleep(EXECUTOR_WAIT_TIME_MS);
- verify(mockConsumingGlTextureProcessor).queueInputFrame(firstTexture, firstPresentationTimeUs);
- verify(mockConsumingGlTextureProcessor)
- .queueInputFrame(secondTexture, secondPresentationTimeUs);
+ verify(mockConsumingGlShaderProgram).queueInputFrame(firstTexture, firstPresentationTimeUs);
+ verify(mockConsumingGlShaderProgram).queueInputFrame(secondTexture, secondPresentationTimeUs);
}
@Test
- public void onOutputStreamEnded_signalsInputStreamEndedToNextGlTextureProcessor()
+ public void onOutputStreamEnded_signalsInputStreamEndedToNextGlShaderProgram()
throws InterruptedException {
- chainingGlTextureProcessorListener.onCurrentOutputStreamEnded();
+ chainingGlShaderProgramListener.onCurrentOutputStreamEnded();
Thread.sleep(EXECUTOR_WAIT_TIME_MS);
- verify(mockConsumingGlTextureProcessor).signalEndOfCurrentInputStream();
+ verify(mockConsumingGlShaderProgram).signalEndOfCurrentInputStream();
}
}
diff --git a/libraries/effect/src/test/java/androidx/media3/effect/ScaleToFitTransformationTest.java b/libraries/effect/src/test/java/androidx/media3/effect/ScaleToFitTransformationTest.java
index 536ff7a656..8bd172de5e 100644
--- a/libraries/effect/src/test/java/androidx/media3/effect/ScaleToFitTransformationTest.java
+++ b/libraries/effect/src/test/java/androidx/media3/effect/ScaleToFitTransformationTest.java
@@ -25,8 +25,8 @@ import org.junit.runner.RunWith;
/**
* Unit tests for {@link ScaleToFitTransformation}.
*
- * See {@code MatrixTextureProcessorPixelTest} for pixel tests testing {@link
- * MatrixTextureProcessor} given a transformation matrix.
+ * See {@code MatrixShaderProgramPixelTest} for pixel tests testing {@link MatrixShaderProgram}
+ * given a transformation matrix.
*/
@RunWith(AndroidJUnit4.class)
public final class ScaleToFitTransformationTest {