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 2e2c149ef3..b260925f70 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 @@ -16,6 +16,7 @@ package androidx.media3.common.util; import static android.opengl.GLU.gluErrorString; +import static androidx.media3.common.util.Assertions.checkArgument; import static androidx.media3.common.util.Assertions.checkState; import android.content.Context; @@ -35,6 +36,7 @@ import androidx.media3.common.C; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; +import java.util.Arrays; import java.util.List; import javax.microedition.khronos.egl.EGL10; @@ -57,15 +59,7 @@ public final class GlUtil { /** Length of the normalized device coordinate (NDC) space, which spans from -1 to 1. */ public static final float LENGTH_NDC = 2f; - // https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_protected_content.txt - private static final String EXTENSION_PROTECTED_CONTENT = "EGL_EXT_protected_content"; - // https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_surfaceless_context.txt - private static final String EXTENSION_SURFACELESS_CONTEXT = "EGL_KHR_surfaceless_context"; - // https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_YUV_target.txt - private static final String EXTENSION_YUV_TARGET = "GL_EXT_YUV_target"; - - private static final int[] EGL_WINDOW_SURFACE_ATTRIBUTES_NONE = new int[] {EGL14.EGL_NONE}; - private static final int[] EGL_CONFIG_ATTRIBUTES_RGBA_8888 = + public static final int[] EGL_CONFIG_ATTRIBUTES_RGBA_8888 = new int[] { EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL14.EGL_RED_SIZE, /* redSize= */ 8, @@ -76,7 +70,7 @@ public final class GlUtil { EGL14.EGL_STENCIL_SIZE, /* stencilSize= */ 0, EGL14.EGL_NONE }; - private static final int[] EGL_CONFIG_ATTRIBUTES_RGBA_1010102 = + public static final int[] EGL_CONFIG_ATTRIBUTES_RGBA_1010102 = new int[] { EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL14.EGL_RED_SIZE, /* redSize= */ 10, @@ -88,6 +82,15 @@ public final class GlUtil { EGL14.EGL_NONE }; + // https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_protected_content.txt + private static final String EXTENSION_PROTECTED_CONTENT = "EGL_EXT_protected_content"; + // https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_surfaceless_context.txt + private static final String EXTENSION_SURFACELESS_CONTEXT = "EGL_KHR_surfaceless_context"; + // https://www.khronos.org/registry/OpenGL/extensions/EXT/EXT_YUV_target.txt + private static final String EXTENSION_YUV_TARGET = "GL_EXT_YUV_target"; + + private static final int[] EGL_WINDOW_SURFACE_ATTRIBUTES_NONE = new int[] {EGL14.EGL_NONE}; + /** Class only contains static methods. */ private GlUtil() {} @@ -187,12 +190,7 @@ public final class GlUtil { try { EGLDisplay eglDisplay = createEglDisplay(); EGLContext eglContext = createEglContext(eglDisplay); - if (GlUtil.isSurfacelessContextExtensionSupported()) { - focusEglSurface( - eglDisplay, eglContext, EGL14.EGL_NO_SURFACE, /* width= */ 1, /* height= */ 1); - } else { - focusPlaceholderEglSurface(eglContext, eglDisplay); - } + focusPlaceholderEglSurface(eglContext, eglDisplay); glExtensions = GLES20.glGetString(GLES20.GL_EXTENSIONS); destroyEglContext(eglDisplay, eglContext); } catch (GlException e) { @@ -211,25 +209,45 @@ public final class GlUtil { return Api17.createEglDisplay(); } - /** Returns a new {@link EGLContext} for the specified {@link EGLDisplay}. */ + /** + * Creates a new {@link EGLContext} for the specified {@link EGLDisplay}. + * + *

Configures the {@link EGLContext} with {@link #EGL_CONFIG_ATTRIBUTES_RGBA_8888} and OpenGL + * ES 2.0. + * + * @param eglDisplay The {@link EGLDisplay} to create an {@link EGLContext} for. + */ @RequiresApi(17) public static EGLContext createEglContext(EGLDisplay eglDisplay) throws GlException { - return Api17.createEglContext(eglDisplay, /* version= */ 2, EGL_CONFIG_ATTRIBUTES_RGBA_8888); + return createEglContext(eglDisplay, EGL_CONFIG_ATTRIBUTES_RGBA_8888); } /** - * Returns a new {@link EGLContext} for the specified {@link EGLDisplay}, requesting ES 3 and an - * RGBA 1010102 config. + * Creates a new {@link EGLContext} for the specified {@link EGLDisplay}. + * + * @param eglDisplay The {@link EGLDisplay} to create an {@link EGLContext} for. + * @param configAttributes The attributes to configure EGL with. Accepts either {@link + * #EGL_CONFIG_ATTRIBUTES_RGBA_1010102}, which will request OpenGL ES 3.0, or {@link + * #EGL_CONFIG_ATTRIBUTES_RGBA_8888}, which will request OpenGL ES 2.0. */ @RequiresApi(17) - public static EGLContext createEglContextEs3Rgba1010102(EGLDisplay eglDisplay) + public static EGLContext createEglContext(EGLDisplay eglDisplay, int[] configAttributes) throws GlException { - return Api17.createEglContext(eglDisplay, /* version= */ 3, EGL_CONFIG_ATTRIBUTES_RGBA_1010102); + checkArgument( + Arrays.equals(configAttributes, EGL_CONFIG_ATTRIBUTES_RGBA_8888) + || Arrays.equals(configAttributes, EGL_CONFIG_ATTRIBUTES_RGBA_1010102)); + return Api17.createEglContext( + eglDisplay, + /* version= */ Arrays.equals(configAttributes, EGL_CONFIG_ATTRIBUTES_RGBA_1010102) ? 3 : 2, + configAttributes); } /** * Returns a new {@link EGLSurface} wrapping the specified {@code surface}. * + *

The {@link EGLSurface} will configure with {@link #EGL_CONFIG_ATTRIBUTES_RGBA_8888} and + * OpenGL ES 2.0. + * * @param eglDisplay The {@link EGLDisplay} to attach the surface to. * @param surface The surface to wrap; must be a surface, surface texture or surface holder. */ @@ -240,19 +258,18 @@ public final class GlUtil { } /** - * Returns a new RGBA 1010102 {@link EGLSurface} wrapping the specified {@code surface}. + * Returns a new {@link EGLSurface} wrapping the specified {@code surface}. * * @param eglDisplay The {@link EGLDisplay} to attach the surface to. * @param surface The surface to wrap; must be a surface, surface texture or surface holder. + * @param configAttributes The attributes to configure EGL with. Accepts {@link + * #EGL_CONFIG_ATTRIBUTES_RGBA_1010102} and {@link #EGL_CONFIG_ATTRIBUTES_RGBA_8888}. */ @RequiresApi(17) - public static EGLSurface getEglSurfaceRgba1010102(EGLDisplay eglDisplay, Object surface) - throws GlException { + public static EGLSurface getEglSurface( + EGLDisplay eglDisplay, Object surface, int[] configAttributes) throws GlException { return Api17.getEglSurface( - eglDisplay, - surface, - EGL_CONFIG_ATTRIBUTES_RGBA_1010102, - EGL_WINDOW_SURFACE_ATTRIBUTES_NONE); + eglDisplay, surface, configAttributes, EGL_WINDOW_SURFACE_ATTRIBUTES_NONE); } /** @@ -277,48 +294,46 @@ public final class GlUtil { } /** - * Returns a placeholder {@link EGLSurface} to use when reading and writing to the surface is not - * required. + * Creates and focuses a placeholder {@link EGLSurface}. * + *

This makes a {@link EGLContext} current when reading and writing to a surface is not + * required, configured with {@link #EGL_CONFIG_ATTRIBUTES_RGBA_8888}. + * + * @param eglContext The {@link EGLContext} to make current. * @param eglDisplay The {@link EGLDisplay} to attach the surface to. * @return {@link EGL14#EGL_NO_SURFACE} if supported and a 1x1 pixel buffer surface otherwise. */ @RequiresApi(17) - public static EGLSurface createPlaceholderEglSurface(EGLDisplay eglDisplay) throws GlException { - return isSurfacelessContextExtensionSupported() - ? EGL14.EGL_NO_SURFACE - : createPbufferSurface( - eglDisplay, /* width= */ 1, /* height= */ 1, EGL_CONFIG_ATTRIBUTES_RGBA_8888); - } - - /** - * Creates and focuses a new {@link EGLSurface} wrapping a 1x1 pixel buffer. - * - * @param eglContext The {@link EGLContext} to make current. - * @param eglDisplay The {@link EGLDisplay} to attach the surface to. - */ - @RequiresApi(17) - public static void focusPlaceholderEglSurface(EGLContext eglContext, EGLDisplay eglDisplay) + public static EGLSurface focusPlaceholderEglSurface(EGLContext eglContext, EGLDisplay eglDisplay) throws GlException { - EGLSurface eglSurface = - createPbufferSurface( - eglDisplay, /* width= */ 1, /* height= */ 1, EGL_CONFIG_ATTRIBUTES_RGBA_8888); - focusEglSurface(eglDisplay, eglContext, eglSurface, /* width= */ 1, /* height= */ 1); + return createFocusedPlaceholderEglSurface( + eglContext, eglDisplay, EGL_CONFIG_ATTRIBUTES_RGBA_8888); } /** - * Creates and focuses a new RGBA 1010102 {@link EGLSurface} wrapping a 1x1 pixel buffer. + * Creates and focuses a placeholder {@link EGLSurface}. + * + *

This makes a {@link EGLContext} current when reading and writing to a surface is not + * required. * * @param eglContext The {@link EGLContext} to make current. * @param eglDisplay The {@link EGLDisplay} to attach the surface to. + * @param configAttributes The attributes to configure EGL with. Accepts {@link + * #EGL_CONFIG_ATTRIBUTES_RGBA_1010102} and {@link #EGL_CONFIG_ATTRIBUTES_RGBA_8888}. + * @return A placeholder {@link EGLSurface} that has been focused to allow rendering to take + * place, or {@link EGL14#EGL_NO_SURFACE} if the current context supports rendering without a + * surface. */ @RequiresApi(17) - public static void focusPlaceholderEglSurfaceRgba1010102( - EGLContext eglContext, EGLDisplay eglDisplay) throws GlException { + public static EGLSurface createFocusedPlaceholderEglSurface( + EGLContext eglContext, EGLDisplay eglDisplay, int[] configAttributes) throws GlException { EGLSurface eglSurface = - createPbufferSurface( - eglDisplay, /* width= */ 1, /* height= */ 1, EGL_CONFIG_ATTRIBUTES_RGBA_1010102); + isSurfacelessContextExtensionSupported() + ? EGL14.EGL_NO_SURFACE + : createPbufferSurface(eglDisplay, /* width= */ 1, /* height= */ 1, configAttributes); + focusEglSurface(eglDisplay, eglContext, eglSurface, /* width= */ 1, /* height= */ 1); + return eglSurface; } /** 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 69cb2daae2..229a9b9cf4 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/ContrastPixelTest.java @@ -79,13 +79,11 @@ public class ContrastPixelTest { public void createGlObjects() throws Exception { eglDisplay = GlUtil.createEglDisplay(); eglContext = GlUtil.createEglContext(eglDisplay); + placeholderEglSurface = GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay); Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); inputWidth = inputBitmap.getWidth(); inputHeight = inputBitmap.getHeight(); - - placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); - GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight); inputTexId = createGlTextureFromBitmap(inputBitmap); } 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 f37d265a2f..c89d1fa972 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/CropPixelTest.java @@ -72,11 +72,11 @@ public final class CropPixelTest { public void createGlObjects() throws IOException, GlUtil.GlException { eglDisplay = GlUtil.createEglDisplay(); eglContext = GlUtil.createEglContext(eglDisplay); + placeholderEglSurface = GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay); + Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); inputWidth = inputBitmap.getWidth(); inputHeight = inputBitmap.getHeight(); - placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); - GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight); inputTexId = createGlTextureFromBitmap(inputBitmap); } 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 f4b46f76e9..aac4efe92f 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/HslAdjustmentPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/HslAdjustmentPixelTest.java @@ -84,11 +84,11 @@ public final class HslAdjustmentPixelTest { public void createGlObjects() throws IOException, GlUtil.GlException { eglDisplay = GlUtil.createEglDisplay(); eglContext = GlUtil.createEglContext(eglDisplay); + placeholderEglSurface = GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay); + Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); inputWidth = inputBitmap.getWidth(); inputHeight = inputBitmap.getHeight(); - placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); - GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight); inputTexId = createGlTextureFromBitmap(inputBitmap); int outputTexId = diff --git a/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixTextureProcessorPixelTest.java b/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixTextureProcessorPixelTest.java index 464efdac41..d6e32d5699 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixTextureProcessorPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/MatrixTextureProcessorPixelTest.java @@ -72,11 +72,11 @@ public final class MatrixTextureProcessorPixelTest { public void createGlObjects() throws IOException, GlUtil.GlException { eglDisplay = GlUtil.createEglDisplay(); eglContext = GlUtil.createEglContext(eglDisplay); + EGLSurface placeholderEglSurface = GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay); + Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); inputWidth = inputBitmap.getWidth(); inputHeight = inputBitmap.getHeight(); - EGLSurface placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); - GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight); inputTexId = createGlTextureFromBitmap(inputBitmap); int outputTexId = GlUtil.createTexture(inputWidth, inputHeight, /* useHighPrecisionColorComponents= */ false); 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 89a31e1675..d97cbf8fea 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/PresentationPixelTest.java @@ -81,11 +81,11 @@ public final class PresentationPixelTest { public void createGlObjects() throws IOException, GlUtil.GlException { eglDisplay = GlUtil.createEglDisplay(); eglContext = GlUtil.createEglContext(eglDisplay); + placeholderEglSurface = GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay); + Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); inputWidth = inputBitmap.getWidth(); inputHeight = inputBitmap.getHeight(); - placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); - GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight); inputTexId = createGlTextureFromBitmap(inputBitmap); } 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 940a42e57a..b58ba9fd42 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbAdjustmentPixelTest.java @@ -78,11 +78,11 @@ public final class RgbAdjustmentPixelTest { public void createGlObjects() throws IOException, GlUtil.GlException { eglDisplay = GlUtil.createEglDisplay(); eglContext = GlUtil.createEglContext(eglDisplay); + placeholderEglSurface = GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay); + Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); inputWidth = inputBitmap.getWidth(); inputHeight = inputBitmap.getHeight(); - placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); - GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight); inputTexId = createGlTextureFromBitmap(inputBitmap); int outputTexId = 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 2ca88cfc1d..1e85afd1b9 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/RgbFilterPixelTest.java @@ -73,11 +73,11 @@ public final class RgbFilterPixelTest { public void createGlObjects() throws IOException, GlUtil.GlException { eglDisplay = GlUtil.createEglDisplay(); eglContext = GlUtil.createEglContext(eglDisplay); + placeholderEglSurface = GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay); + Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); inputWidth = inputBitmap.getWidth(); inputHeight = inputBitmap.getHeight(); - placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); - GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight); inputTexId = createGlTextureFromBitmap(inputBitmap); int outputTexId = 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 cee6811736..ec7f0781e0 100644 --- a/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java +++ b/libraries/effect/src/androidTest/java/androidx/media3/effect/SingleColorLutPixelTest.java @@ -78,13 +78,11 @@ public class SingleColorLutPixelTest { public void createGlObjects() throws Exception { eglDisplay = GlUtil.createEglDisplay(); eglContext = GlUtil.createEglContext(eglDisplay); + placeholderEglSurface = GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay); Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); inputWidth = inputBitmap.getWidth(); inputHeight = inputBitmap.getHeight(); - - placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay); - GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight); inputTexId = createGlTextureFromBitmap(inputBitmap); } diff --git a/libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixTextureProcessorWrapper.java b/libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixTextureProcessorWrapper.java index 49af8e1e67..6304e493ab 100644 --- a/libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixTextureProcessorWrapper.java +++ b/libraries/effect/src/main/java/androidx/media3/effect/FinalMatrixTextureProcessorWrapper.java @@ -317,11 +317,14 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; @Nullable EGLSurface outputEglSurface = this.outputEglSurface; if (outputEglSurface == null) { boolean colorInfoIsHdr = ColorInfo.isTransferHdr(colorInfo); - if (colorInfoIsHdr) { - outputEglSurface = GlUtil.getEglSurfaceRgba1010102(eglDisplay, outputSurfaceInfo.surface); - } else { - outputEglSurface = GlUtil.getEglSurface(eglDisplay, outputSurfaceInfo.surface); - } + + outputEglSurface = + GlUtil.getEglSurface( + eglDisplay, + outputSurfaceInfo.surface, + colorInfoIsHdr + ? GlUtil.EGL_CONFIG_ATTRIBUTES_RGBA_1010102 + : GlUtil.EGL_CONFIG_ATTRIBUTES_RGBA_8888); @Nullable SurfaceView debugSurfaceView = @@ -443,11 +446,13 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; } if (eglSurface == null) { - if (useHdr) { - eglSurface = GlUtil.getEglSurfaceRgba1010102(eglDisplay, surface); - } else { - eglSurface = GlUtil.getEglSurface(eglDisplay, surface); - } + eglSurface = + GlUtil.getEglSurface( + eglDisplay, + surface, + useHdr + ? GlUtil.EGL_CONFIG_ATTRIBUTES_RGBA_1010102 + : GlUtil.EGL_CONFIG_ATTRIBUTES_RGBA_8888); } EGLSurface eglSurface = this.eglSurface; GlUtil.focusEglSurface(eglDisplay, eglContext, eglSurface, width, height); 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 ac90870d66..943e3eb1ff 100644 --- a/libraries/effect/src/main/java/androidx/media3/effect/GlEffectsFrameProcessor.java +++ b/libraries/effect/src/main/java/androidx/media3/effect/GlEffectsFrameProcessor.java @@ -21,7 +21,6 @@ import static androidx.media3.common.util.Assertions.checkStateNotNull; import static com.google.common.collect.Iterables.getLast; import android.content.Context; -import android.opengl.EGL14; import android.opengl.EGLContext; import android.opengl.EGLDisplay; import android.view.Surface; @@ -122,19 +121,10 @@ public final class GlEffectsFrameProcessor implements FrameProcessor { // configure based on the color info from the decoder output media format instead. boolean useHdr = ColorInfo.isTransferHdr(colorInfo); EGLDisplay eglDisplay = GlUtil.createEglDisplay(); - EGLContext eglContext = - useHdr - ? GlUtil.createEglContextEs3Rgba1010102(eglDisplay) - : GlUtil.createEglContext(eglDisplay); - - if (GlUtil.isSurfacelessContextExtensionSupported()) { - GlUtil.focusEglSurface( - eglDisplay, eglContext, EGL14.EGL_NO_SURFACE, /* width= */ 1, /* height= */ 1); - } else if (useHdr) { - GlUtil.focusPlaceholderEglSurfaceRgba1010102(eglContext, eglDisplay); - } else { - GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay); - } + int[] configAttributes = + useHdr ? GlUtil.EGL_CONFIG_ATTRIBUTES_RGBA_1010102 : GlUtil.EGL_CONFIG_ATTRIBUTES_RGBA_8888; + EGLContext eglContext = GlUtil.createEglContext(eglDisplay, configAttributes); + GlUtil.createFocusedPlaceholderEglSurface(eglContext, eglDisplay, configAttributes); ImmutableList textureProcessors = getGlTextureProcessorsForGlEffects(