HDR: Remove unused EGL_GL_COLORSPACE_KHR attribute.

PiperOrigin-RevId: 459106221
This commit is contained in:
huangdarwin 2022-07-05 18:47:29 +00:00 committed by Rohit Singh
parent 7d2eb76019
commit 1869855c90
3 changed files with 20 additions and 31 deletions

View File

@ -64,9 +64,6 @@ public final class GlUtil {
// https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_surfaceless_context.txt // https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_surfaceless_context.txt
private static final String EXTENSION_SURFACELESS_CONTEXT = "EGL_KHR_surfaceless_context"; private static final String EXTENSION_SURFACELESS_CONTEXT = "EGL_KHR_surfaceless_context";
// https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_gl_colorspace.txt
private static final int EGL_GL_COLORSPACE_KHR = 0x309D;
private static final int[] EGL_WINDOW_SURFACE_ATTRIBUTES_NONE = new int[] {EGL14.EGL_NONE}; private static final int[] EGL_WINDOW_SURFACE_ATTRIBUTES_NONE = new int[] {EGL14.EGL_NONE};
private static final int[] EGL_CONFIG_ATTRIBUTES_RGBA_8888 = private static final int[] EGL_CONFIG_ATTRIBUTES_RGBA_8888 =
new int[] { new int[] {
@ -208,14 +205,13 @@ public final class GlUtil {
} }
/** /**
* Returns a new {@link EGLSurface} wrapping the specified {@code surface}, for HDR rendering with * Returns a new RGBA 1010102 {@link EGLSurface} wrapping the specified {@code surface}.
* Rec. 2020 color primaries.
* *
* @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.
*/ */
@RequiresApi(17) @RequiresApi(17)
public static EGLSurface getEglSurfaceBt2020(EGLDisplay eglDisplay, Object surface) public static EGLSurface getEglSurfaceRgba1010102(EGLDisplay eglDisplay, Object surface)
throws GlException { throws GlException {
return Api17.getEglSurface( return Api17.getEglSurface(
eglDisplay, eglDisplay,
@ -230,18 +226,19 @@ public final class GlUtil {
* @param eglDisplay The {@link EGLDisplay} to attach the surface to. * @param eglDisplay The {@link EGLDisplay} to attach the surface to.
* @param width The width of the pixel buffer. * @param width The width of the pixel buffer.
* @param height The height of the pixel buffer. * @param height The height of the pixel buffer.
* @param configAttributes EGL configuration attributes. Valid arguments include {@link
* #EGL_CONFIG_ATTRIBUTES_RGBA_8888} and {@link #EGL_CONFIG_ATTRIBUTES_RGBA_1010102}.
*/ */
@RequiresApi(17) @RequiresApi(17)
private static EGLSurface createPbufferSurface(EGLDisplay eglDisplay, int width, int height) private static EGLSurface createPbufferSurface(
throws GlException { EGLDisplay eglDisplay, int width, int height, int[] configAttributes) throws GlException {
int[] pbufferAttributes = int[] pbufferAttributes =
new int[] { new int[] {
EGL14.EGL_WIDTH, width, EGL14.EGL_WIDTH, width,
EGL14.EGL_HEIGHT, height, EGL14.EGL_HEIGHT, height,
EGL14.EGL_NONE EGL14.EGL_NONE
}; };
return Api17.createEglPbufferSurface( return Api17.createEglPbufferSurface(eglDisplay, configAttributes, pbufferAttributes);
eglDisplay, EGL_CONFIG_ATTRIBUTES_RGBA_8888, pbufferAttributes);
} }
/** /**
@ -255,7 +252,8 @@ public final class GlUtil {
public static EGLSurface createPlaceholderEglSurface(EGLDisplay eglDisplay) throws GlException { public static EGLSurface createPlaceholderEglSurface(EGLDisplay eglDisplay) throws GlException {
return isSurfacelessContextExtensionSupported() return isSurfacelessContextExtensionSupported()
? EGL14.EGL_NO_SURFACE ? EGL14.EGL_NO_SURFACE
: createPbufferSurface(eglDisplay, /* width= */ 1, /* height= */ 1); : createPbufferSurface(
eglDisplay, /* width= */ 1, /* height= */ 1, EGL_CONFIG_ATTRIBUTES_RGBA_8888);
} }
/** /**
@ -267,33 +265,24 @@ public final class GlUtil {
@RequiresApi(17) @RequiresApi(17)
public static void focusPlaceholderEglSurface(EGLContext eglContext, EGLDisplay eglDisplay) public static void focusPlaceholderEglSurface(EGLContext eglContext, EGLDisplay eglDisplay)
throws GlException { throws GlException {
EGLSurface eglSurface = createPbufferSurface(eglDisplay, /* width= */ 1, /* height= */ 1); EGLSurface eglSurface =
createPbufferSurface(
eglDisplay, /* width= */ 1, /* height= */ 1, EGL_CONFIG_ATTRIBUTES_RGBA_8888);
focusEglSurface(eglDisplay, eglContext, eglSurface, /* width= */ 1, /* height= */ 1); focusEglSurface(eglDisplay, eglContext, eglSurface, /* width= */ 1, /* height= */ 1);
} }
/** /**
* Creates and focuses a new {@link EGLSurface} wrapping a 1x1 pixel buffer, for HDR rendering * Creates and focuses a new RGBA 1010102 {@link EGLSurface} wrapping a 1x1 pixel buffer.
* with Rec. 2020 color primaries.
* *
* @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.
*/ */
@RequiresApi(17) @RequiresApi(17)
public static void focusPlaceholderEglSurfaceBt2020(EGLContext eglContext, EGLDisplay eglDisplay) public static void focusPlaceholderEglSurfaceRgba1010102(
throws GlException { EGLContext eglContext, EGLDisplay eglDisplay) throws GlException {
int[] pbufferAttributes =
new int[] {
EGL14.EGL_WIDTH,
/* width= */ 1,
EGL14.EGL_HEIGHT,
/* height= */ 1,
// TODO(b/227624622): Figure out if we can remove the EGL_GL_COLORSPACE_KHR item.
EGL_GL_COLORSPACE_KHR,
EGL14.EGL_NONE
};
EGLSurface eglSurface = EGLSurface eglSurface =
Api17.createEglPbufferSurface( createPbufferSurface(
eglDisplay, EGL_CONFIG_ATTRIBUTES_RGBA_1010102, pbufferAttributes); eglDisplay, /* width= */ 1, /* height= */ 1, EGL_CONFIG_ATTRIBUTES_RGBA_1010102);
focusEglSurface(eglDisplay, eglContext, eglSurface, /* width= */ 1, /* height= */ 1); focusEglSurface(eglDisplay, eglContext, eglSurface, /* width= */ 1, /* height= */ 1);
} }

View File

@ -195,7 +195,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@Nullable EGLSurface outputEglSurface = this.outputEglSurface; @Nullable EGLSurface outputEglSurface = this.outputEglSurface;
if (outputEglSurface == null) { // This means that outputSurfaceInfo changed. if (outputEglSurface == null) { // This means that outputSurfaceInfo changed.
if (useHdr) { if (useHdr) {
outputEglSurface = GlUtil.getEglSurfaceBt2020(eglDisplay, outputSurfaceInfo.surface); outputEglSurface = GlUtil.getEglSurfaceRgba1010102(eglDisplay, outputSurfaceInfo.surface);
} else { } else {
outputEglSurface = GlUtil.getEglSurface(eglDisplay, outputSurfaceInfo.surface); outputEglSurface = GlUtil.getEglSurface(eglDisplay, outputSurfaceInfo.surface);
} }
@ -317,7 +317,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
if (eglSurface == null) { if (eglSurface == null) {
if (useHdr) { if (useHdr) {
eglSurface = GlUtil.getEglSurfaceBt2020(eglDisplay, surface); eglSurface = GlUtil.getEglSurfaceRgba1010102(eglDisplay, surface);
} else { } else {
eglSurface = GlUtil.getEglSurface(eglDisplay, surface); eglSurface = GlUtil.getEglSurface(eglDisplay, surface);
} }

View File

@ -121,7 +121,7 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
GlUtil.focusEglSurface( GlUtil.focusEglSurface(
eglDisplay, eglContext, EGL14.EGL_NO_SURFACE, /* width= */ 1, /* height= */ 1); eglDisplay, eglContext, EGL14.EGL_NO_SURFACE, /* width= */ 1, /* height= */ 1);
} else if (useHdr) { } else if (useHdr) {
GlUtil.focusPlaceholderEglSurfaceBt2020(eglContext, eglDisplay); GlUtil.focusPlaceholderEglSurfaceRgba1010102(eglContext, eglDisplay);
} else { } else {
GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay); GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay);
} }