diff --git a/library/common/src/main/java/com/google/android/exoplayer2/util/GlUtil.java b/library/common/src/main/java/com/google/android/exoplayer2/util/GlUtil.java index 438157576b..c9763d81a0 100644 --- a/library/common/src/main/java/com/google/android/exoplayer2/util/GlUtil.java +++ b/library/common/src/main/java/com/google/android/exoplayer2/util/GlUtil.java @@ -16,6 +16,7 @@ package com.google.android.exoplayer2.util; import static android.opengl.GLU.gluErrorString; +import static com.google.android.exoplayer2.util.Assertions.checkArgument; import static com.google.android.exoplayer2.util.Assertions.checkState; import android.content.Context; @@ -35,6 +36,7 @@ import com.google.android.exoplayer2.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; @@ -56,15 +58,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, @@ -75,7 +69,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, @@ -87,6 +81,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() {} @@ -186,12 +189,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) { @@ -210,25 +208,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. */ @@ -239,19 +257,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); } /** @@ -276,48 +293,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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/ContrastPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/ContrastPixelTest.java
index d74e34a622..9d5bc05e1c 100644
--- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/ContrastPixelTest.java
+++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/CropPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/CropPixelTest.java
index 29767d849b..9f85c86cf0 100644
--- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/CropPixelTest.java
+++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/HslAdjustmentPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/HslAdjustmentPixelTest.java
index f2c310921d..fc67b3b6cb 100644
--- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/HslAdjustmentPixelTest.java
+++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/MatrixTextureProcessorPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/MatrixTextureProcessorPixelTest.java
index acf9545c0d..965fa67443 100644
--- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/MatrixTextureProcessorPixelTest.java
+++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/PresentationPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/PresentationPixelTest.java
index 18287fde9f..4bfe9e05e9 100644
--- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/PresentationPixelTest.java
+++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbAdjustmentPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbAdjustmentPixelTest.java
index c8c0f7d598..754bb72fd2 100644
--- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbAdjustmentPixelTest.java
+++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbFilterPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbFilterPixelTest.java
index 97cf00c0d2..8836e3f002 100644
--- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/RgbFilterPixelTest.java
+++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/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/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/SingleColorLutPixelTest.java b/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/SingleColorLutPixelTest.java
index 7932173e57..1aa735980a 100644
--- a/library/effect/src/androidTest/java/com/google/android/exoplayer2/effect/SingleColorLutPixelTest.java
+++ b/library/effect/src/androidTest/java/com/google/android/exoplayer2/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/library/effect/src/main/java/com/google/android/exoplayer2/effect/FinalMatrixTextureProcessorWrapper.java b/library/effect/src/main/java/com/google/android/exoplayer2/effect/FinalMatrixTextureProcessorWrapper.java
index 58011a5b64..f129a3c959 100644
--- a/library/effect/src/main/java/com/google/android/exoplayer2/effect/FinalMatrixTextureProcessorWrapper.java
+++ b/library/effect/src/main/java/com/google/android/exoplayer2/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/library/effect/src/main/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessor.java b/library/effect/src/main/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessor.java
index 1f1caae18f..4d5ad5ee0e 100644
--- a/library/effect/src/main/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessor.java
+++ b/library/effect/src/main/java/com/google/android/exoplayer2/effect/GlEffectsFrameProcessor.java
@@ -21,7 +21,6 @@ import static com.google.android.exoplayer2.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;
@@ -120,19 +119,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