Commit 0b0101e5 by huangdarwin Committed by microkatz

HDR: Support RGBA_1010102 in GlUtil as a parameter.

Make it easier to support use of RGBA_101012 rather than RGBA_8888 for EGL
contexts, displays, and surfaces.

This tangentially supports adding HDR tests, by slightly simplifying the color
selection logic we'd have to add in HDR tests.

PiperOrigin-RevId: 482219428
(cherry picked from commit 9e1adee4)
parent f42d18f2
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.util; package com.google.android.exoplayer2.util;
import static android.opengl.GLU.gluErrorString; 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 static com.google.android.exoplayer2.util.Assertions.checkState;
import android.content.Context; import android.content.Context;
...@@ -35,6 +36,7 @@ import com.google.android.exoplayer2.C; ...@@ -35,6 +36,7 @@ import com.google.android.exoplayer2.C;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.util.Arrays;
import java.util.List; import java.util.List;
import javax.microedition.khronos.egl.EGL10; import javax.microedition.khronos.egl.EGL10;
...@@ -56,15 +58,7 @@ public final class GlUtil { ...@@ -56,15 +58,7 @@ public final class GlUtil {
/** Length of the normalized device coordinate (NDC) space, which spans from -1 to 1. */ /** Length of the normalized device coordinate (NDC) space, which spans from -1 to 1. */
public static final float LENGTH_NDC = 2f; public static final float LENGTH_NDC = 2f;
// https://www.khronos.org/registry/EGL/extensions/EXT/EGL_EXT_protected_content.txt public static final int[] EGL_CONFIG_ATTRIBUTES_RGBA_8888 =
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 =
new int[] { new int[] {
EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
EGL14.EGL_RED_SIZE, /* redSize= */ 8, EGL14.EGL_RED_SIZE, /* redSize= */ 8,
...@@ -75,7 +69,7 @@ public final class GlUtil { ...@@ -75,7 +69,7 @@ public final class GlUtil {
EGL14.EGL_STENCIL_SIZE, /* stencilSize= */ 0, EGL14.EGL_STENCIL_SIZE, /* stencilSize= */ 0,
EGL14.EGL_NONE EGL14.EGL_NONE
}; };
private static final int[] EGL_CONFIG_ATTRIBUTES_RGBA_1010102 = public static final int[] EGL_CONFIG_ATTRIBUTES_RGBA_1010102 =
new int[] { new int[] {
EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT, EGL14.EGL_RENDERABLE_TYPE, EGL14.EGL_OPENGL_ES2_BIT,
EGL14.EGL_RED_SIZE, /* redSize= */ 10, EGL14.EGL_RED_SIZE, /* redSize= */ 10,
...@@ -87,6 +81,15 @@ public final class GlUtil { ...@@ -87,6 +81,15 @@ public final class GlUtil {
EGL14.EGL_NONE 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. */ /** Class only contains static methods. */
private GlUtil() {} private GlUtil() {}
...@@ -186,12 +189,7 @@ public final class GlUtil { ...@@ -186,12 +189,7 @@ public final class GlUtil {
try { try {
EGLDisplay eglDisplay = createEglDisplay(); EGLDisplay eglDisplay = createEglDisplay();
EGLContext eglContext = createEglContext(eglDisplay); 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); glExtensions = GLES20.glGetString(GLES20.GL_EXTENSIONS);
destroyEglContext(eglDisplay, eglContext); destroyEglContext(eglDisplay, eglContext);
} catch (GlException e) { } catch (GlException e) {
...@@ -210,25 +208,45 @@ public final class GlUtil { ...@@ -210,25 +208,45 @@ public final class GlUtil {
return Api17.createEglDisplay(); return Api17.createEglDisplay();
} }
/** Returns a new {@link EGLContext} for the specified {@link EGLDisplay}. */ /**
* Creates a new {@link EGLContext} for the specified {@link EGLDisplay}.
*
* <p>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) @RequiresApi(17)
public static EGLContext createEglContext(EGLDisplay eglDisplay) throws GlException { 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 * Creates a new {@link EGLContext} for the specified {@link EGLDisplay}.
* RGBA 1010102 config. *
* @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) @RequiresApi(17)
public static EGLContext createEglContextEs3Rgba1010102(EGLDisplay eglDisplay) public static EGLContext createEglContext(EGLDisplay eglDisplay, int[] configAttributes)
throws GlException { 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}. * Returns a new {@link EGLSurface} wrapping the specified {@code surface}.
* *
* <p>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 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 surface The surface to wrap; must be a surface, surface texture or surface holder.
*/ */
...@@ -239,19 +257,18 @@ public final class GlUtil { ...@@ -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 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 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) @RequiresApi(17)
public static EGLSurface getEglSurfaceRgba1010102(EGLDisplay eglDisplay, Object surface) public static EGLSurface getEglSurface(
throws GlException { EGLDisplay eglDisplay, Object surface, int[] configAttributes) throws GlException {
return Api17.getEglSurface( return Api17.getEglSurface(
eglDisplay, eglDisplay, surface, configAttributes, EGL_WINDOW_SURFACE_ATTRIBUTES_NONE);
surface,
EGL_CONFIG_ATTRIBUTES_RGBA_1010102,
EGL_WINDOW_SURFACE_ATTRIBUTES_NONE);
} }
/** /**
...@@ -276,48 +293,46 @@ public final class GlUtil { ...@@ -276,48 +293,46 @@ public final class GlUtil {
} }
/** /**
* Returns a placeholder {@link EGLSurface} to use when reading and writing to the surface is not * Creates and focuses a placeholder {@link EGLSurface}.
* required.
* *
* @param eglDisplay The {@link EGLDisplay} to attach the surface to. * <p>This makes a {@link EGLContext} current when reading and writing to a surface is not
* @return {@link EGL14#EGL_NO_SURFACE} if supported and a 1x1 pixel buffer surface otherwise. * required, configured with {@link #EGL_CONFIG_ATTRIBUTES_RGBA_8888}.
*/
@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 eglContext The {@link EGLContext} to make current.
* @param eglDisplay The {@link EGLDisplay} to attach the surface to. * @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) @RequiresApi(17)
public static void focusPlaceholderEglSurface(EGLContext eglContext, EGLDisplay eglDisplay) public static EGLSurface focusPlaceholderEglSurface(EGLContext eglContext, EGLDisplay eglDisplay)
throws GlException { throws GlException {
EGLSurface eglSurface = return createFocusedPlaceholderEglSurface(
createPbufferSurface( eglContext, eglDisplay, EGL_CONFIG_ATTRIBUTES_RGBA_8888);
eglDisplay, /* width= */ 1, /* height= */ 1, EGL_CONFIG_ATTRIBUTES_RGBA_8888);
focusEglSurface(eglDisplay, eglContext, eglSurface, /* width= */ 1, /* height= */ 1);
} }
/** /**
* Creates and focuses a new RGBA 1010102 {@link EGLSurface} wrapping a 1x1 pixel buffer. * Creates and focuses a placeholder {@link EGLSurface}.
*
* <p>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 eglContext The {@link EGLContext} to make current.
* @param eglDisplay The {@link EGLDisplay} to attach the surface to. * @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) @RequiresApi(17)
public static void focusPlaceholderEglSurfaceRgba1010102( public static EGLSurface createFocusedPlaceholderEglSurface(
EGLContext eglContext, EGLDisplay eglDisplay) throws GlException { EGLContext eglContext, EGLDisplay eglDisplay, int[] configAttributes) throws GlException {
EGLSurface eglSurface = EGLSurface eglSurface =
createPbufferSurface( isSurfacelessContextExtensionSupported()
eglDisplay, /* width= */ 1, /* height= */ 1, EGL_CONFIG_ATTRIBUTES_RGBA_1010102); ? EGL14.EGL_NO_SURFACE
: createPbufferSurface(eglDisplay, /* width= */ 1, /* height= */ 1, configAttributes);
focusEglSurface(eglDisplay, eglContext, eglSurface, /* width= */ 1, /* height= */ 1); focusEglSurface(eglDisplay, eglContext, eglSurface, /* width= */ 1, /* height= */ 1);
return eglSurface;
} }
/** /**
......
...@@ -79,13 +79,11 @@ public class ContrastPixelTest { ...@@ -79,13 +79,11 @@ public class ContrastPixelTest {
public void createGlObjects() throws Exception { public void createGlObjects() throws Exception {
eglDisplay = GlUtil.createEglDisplay(); eglDisplay = GlUtil.createEglDisplay();
eglContext = GlUtil.createEglContext(eglDisplay); eglContext = GlUtil.createEglContext(eglDisplay);
placeholderEglSurface = GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay);
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
inputWidth = inputBitmap.getWidth(); inputWidth = inputBitmap.getWidth();
inputHeight = inputBitmap.getHeight(); inputHeight = inputBitmap.getHeight();
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
inputTexId = createGlTextureFromBitmap(inputBitmap); inputTexId = createGlTextureFromBitmap(inputBitmap);
} }
......
...@@ -72,11 +72,11 @@ public final class CropPixelTest { ...@@ -72,11 +72,11 @@ public final class CropPixelTest {
public void createGlObjects() throws IOException, GlUtil.GlException { public void createGlObjects() throws IOException, GlUtil.GlException {
eglDisplay = GlUtil.createEglDisplay(); eglDisplay = GlUtil.createEglDisplay();
eglContext = GlUtil.createEglContext(eglDisplay); eglContext = GlUtil.createEglContext(eglDisplay);
placeholderEglSurface = GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay);
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
inputWidth = inputBitmap.getWidth(); inputWidth = inputBitmap.getWidth();
inputHeight = inputBitmap.getHeight(); inputHeight = inputBitmap.getHeight();
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
inputTexId = createGlTextureFromBitmap(inputBitmap); inputTexId = createGlTextureFromBitmap(inputBitmap);
} }
......
...@@ -84,11 +84,11 @@ public final class HslAdjustmentPixelTest { ...@@ -84,11 +84,11 @@ public final class HslAdjustmentPixelTest {
public void createGlObjects() throws IOException, GlUtil.GlException { public void createGlObjects() throws IOException, GlUtil.GlException {
eglDisplay = GlUtil.createEglDisplay(); eglDisplay = GlUtil.createEglDisplay();
eglContext = GlUtil.createEglContext(eglDisplay); eglContext = GlUtil.createEglContext(eglDisplay);
placeholderEglSurface = GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay);
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
inputWidth = inputBitmap.getWidth(); inputWidth = inputBitmap.getWidth();
inputHeight = inputBitmap.getHeight(); inputHeight = inputBitmap.getHeight();
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
inputTexId = createGlTextureFromBitmap(inputBitmap); inputTexId = createGlTextureFromBitmap(inputBitmap);
int outputTexId = int outputTexId =
......
...@@ -72,11 +72,11 @@ public final class MatrixTextureProcessorPixelTest { ...@@ -72,11 +72,11 @@ public final class MatrixTextureProcessorPixelTest {
public void createGlObjects() throws IOException, GlUtil.GlException { public void createGlObjects() throws IOException, GlUtil.GlException {
eglDisplay = GlUtil.createEglDisplay(); eglDisplay = GlUtil.createEglDisplay();
eglContext = GlUtil.createEglContext(eglDisplay); eglContext = GlUtil.createEglContext(eglDisplay);
EGLSurface placeholderEglSurface = GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay);
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
inputWidth = inputBitmap.getWidth(); inputWidth = inputBitmap.getWidth();
inputHeight = inputBitmap.getHeight(); inputHeight = inputBitmap.getHeight();
EGLSurface placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
inputTexId = createGlTextureFromBitmap(inputBitmap); inputTexId = createGlTextureFromBitmap(inputBitmap);
int outputTexId = int outputTexId =
GlUtil.createTexture(inputWidth, inputHeight, /* useHighPrecisionColorComponents= */ false); GlUtil.createTexture(inputWidth, inputHeight, /* useHighPrecisionColorComponents= */ false);
......
...@@ -81,11 +81,11 @@ public final class PresentationPixelTest { ...@@ -81,11 +81,11 @@ public final class PresentationPixelTest {
public void createGlObjects() throws IOException, GlUtil.GlException { public void createGlObjects() throws IOException, GlUtil.GlException {
eglDisplay = GlUtil.createEglDisplay(); eglDisplay = GlUtil.createEglDisplay();
eglContext = GlUtil.createEglContext(eglDisplay); eglContext = GlUtil.createEglContext(eglDisplay);
placeholderEglSurface = GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay);
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
inputWidth = inputBitmap.getWidth(); inputWidth = inputBitmap.getWidth();
inputHeight = inputBitmap.getHeight(); inputHeight = inputBitmap.getHeight();
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
inputTexId = createGlTextureFromBitmap(inputBitmap); inputTexId = createGlTextureFromBitmap(inputBitmap);
} }
......
...@@ -78,11 +78,11 @@ public final class RgbAdjustmentPixelTest { ...@@ -78,11 +78,11 @@ public final class RgbAdjustmentPixelTest {
public void createGlObjects() throws IOException, GlUtil.GlException { public void createGlObjects() throws IOException, GlUtil.GlException {
eglDisplay = GlUtil.createEglDisplay(); eglDisplay = GlUtil.createEglDisplay();
eglContext = GlUtil.createEglContext(eglDisplay); eglContext = GlUtil.createEglContext(eglDisplay);
placeholderEglSurface = GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay);
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
inputWidth = inputBitmap.getWidth(); inputWidth = inputBitmap.getWidth();
inputHeight = inputBitmap.getHeight(); inputHeight = inputBitmap.getHeight();
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
inputTexId = createGlTextureFromBitmap(inputBitmap); inputTexId = createGlTextureFromBitmap(inputBitmap);
int outputTexId = int outputTexId =
......
...@@ -73,11 +73,11 @@ public final class RgbFilterPixelTest { ...@@ -73,11 +73,11 @@ public final class RgbFilterPixelTest {
public void createGlObjects() throws IOException, GlUtil.GlException { public void createGlObjects() throws IOException, GlUtil.GlException {
eglDisplay = GlUtil.createEglDisplay(); eglDisplay = GlUtil.createEglDisplay();
eglContext = GlUtil.createEglContext(eglDisplay); eglContext = GlUtil.createEglContext(eglDisplay);
placeholderEglSurface = GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay);
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
inputWidth = inputBitmap.getWidth(); inputWidth = inputBitmap.getWidth();
inputHeight = inputBitmap.getHeight(); inputHeight = inputBitmap.getHeight();
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
inputTexId = createGlTextureFromBitmap(inputBitmap); inputTexId = createGlTextureFromBitmap(inputBitmap);
int outputTexId = int outputTexId =
......
...@@ -78,13 +78,11 @@ public class SingleColorLutPixelTest { ...@@ -78,13 +78,11 @@ public class SingleColorLutPixelTest {
public void createGlObjects() throws Exception { public void createGlObjects() throws Exception {
eglDisplay = GlUtil.createEglDisplay(); eglDisplay = GlUtil.createEglDisplay();
eglContext = GlUtil.createEglContext(eglDisplay); eglContext = GlUtil.createEglContext(eglDisplay);
placeholderEglSurface = GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay);
Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH); Bitmap inputBitmap = readBitmap(ORIGINAL_PNG_ASSET_PATH);
inputWidth = inputBitmap.getWidth(); inputWidth = inputBitmap.getWidth();
inputHeight = inputBitmap.getHeight(); inputHeight = inputBitmap.getHeight();
placeholderEglSurface = GlUtil.createPlaceholderEglSurface(eglDisplay);
GlUtil.focusEglSurface(eglDisplay, eglContext, placeholderEglSurface, inputWidth, inputHeight);
inputTexId = createGlTextureFromBitmap(inputBitmap); inputTexId = createGlTextureFromBitmap(inputBitmap);
} }
......
...@@ -317,11 +317,14 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -317,11 +317,14 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@Nullable EGLSurface outputEglSurface = this.outputEglSurface; @Nullable EGLSurface outputEglSurface = this.outputEglSurface;
if (outputEglSurface == null) { if (outputEglSurface == null) {
boolean colorInfoIsHdr = ColorInfo.isTransferHdr(colorInfo); boolean colorInfoIsHdr = ColorInfo.isTransferHdr(colorInfo);
if (colorInfoIsHdr) {
outputEglSurface = GlUtil.getEglSurfaceRgba1010102(eglDisplay, outputSurfaceInfo.surface); outputEglSurface =
} else { GlUtil.getEglSurface(
outputEglSurface = GlUtil.getEglSurface(eglDisplay, outputSurfaceInfo.surface); eglDisplay,
} outputSurfaceInfo.surface,
colorInfoIsHdr
? GlUtil.EGL_CONFIG_ATTRIBUTES_RGBA_1010102
: GlUtil.EGL_CONFIG_ATTRIBUTES_RGBA_8888);
@Nullable @Nullable
SurfaceView debugSurfaceView = SurfaceView debugSurfaceView =
...@@ -443,11 +446,13 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull; ...@@ -443,11 +446,13 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
} }
if (eglSurface == null) { if (eglSurface == null) {
if (useHdr) { eglSurface =
eglSurface = GlUtil.getEglSurfaceRgba1010102(eglDisplay, surface); GlUtil.getEglSurface(
} else { eglDisplay,
eglSurface = GlUtil.getEglSurface(eglDisplay, surface); surface,
} useHdr
? GlUtil.EGL_CONFIG_ATTRIBUTES_RGBA_1010102
: GlUtil.EGL_CONFIG_ATTRIBUTES_RGBA_8888);
} }
EGLSurface eglSurface = this.eglSurface; EGLSurface eglSurface = this.eglSurface;
GlUtil.focusEglSurface(eglDisplay, eglContext, eglSurface, width, height); GlUtil.focusEglSurface(eglDisplay, eglContext, eglSurface, width, height);
......
...@@ -21,7 +21,6 @@ import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull; ...@@ -21,7 +21,6 @@ import static com.google.android.exoplayer2.util.Assertions.checkStateNotNull;
import static com.google.common.collect.Iterables.getLast; import static com.google.common.collect.Iterables.getLast;
import android.content.Context; import android.content.Context;
import android.opengl.EGL14;
import android.opengl.EGLContext; import android.opengl.EGLContext;
import android.opengl.EGLDisplay; import android.opengl.EGLDisplay;
import android.view.Surface; import android.view.Surface;
...@@ -120,19 +119,10 @@ public final class GlEffectsFrameProcessor implements FrameProcessor { ...@@ -120,19 +119,10 @@ public final class GlEffectsFrameProcessor implements FrameProcessor {
// configure based on the color info from the decoder output media format instead. // configure based on the color info from the decoder output media format instead.
boolean useHdr = ColorInfo.isTransferHdr(colorInfo); boolean useHdr = ColorInfo.isTransferHdr(colorInfo);
EGLDisplay eglDisplay = GlUtil.createEglDisplay(); EGLDisplay eglDisplay = GlUtil.createEglDisplay();
EGLContext eglContext = int[] configAttributes =
useHdr useHdr ? GlUtil.EGL_CONFIG_ATTRIBUTES_RGBA_1010102 : GlUtil.EGL_CONFIG_ATTRIBUTES_RGBA_8888;
? GlUtil.createEglContextEs3Rgba1010102(eglDisplay) EGLContext eglContext = GlUtil.createEglContext(eglDisplay, configAttributes);
: GlUtil.createEglContext(eglDisplay); GlUtil.createFocusedPlaceholderEglSurface(eglContext, eglDisplay, configAttributes);
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);
}
ImmutableList<GlTextureProcessor> textureProcessors = ImmutableList<GlTextureProcessor> textureProcessors =
getGlTextureProcessorsForGlEffects( getGlTextureProcessorsForGlEffects(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment