Skip to content

Commit

Permalink
HDR: Remove unused EGL_GL_COLORSPACE_KHR attribute.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 459106221
  • Loading branch information
dway123 authored and rohitjoins committed Jul 7, 2022
1 parent d5b02e7 commit bbbb009
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ public GlException(String message) {
// 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/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_CONFIG_ATTRIBUTES_RGBA_8888 =
new int[] {
Expand Down Expand Up @@ -207,14 +204,13 @@ public static EGLSurface getEglSurface(EGLDisplay eglDisplay, Object surface) th
}

/**
* Returns a new {@link EGLSurface} wrapping the specified {@code surface}, for HDR rendering with
* Rec. 2020 color primaries.
* Returns a new RGBA 1010102 {@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.
*/
@RequiresApi(17)
public static EGLSurface getEglSurfaceBt2020(EGLDisplay eglDisplay, Object surface)
public static EGLSurface getEglSurfaceRgba1010102(EGLDisplay eglDisplay, Object surface)
throws GlException {
return Api17.getEglSurface(
eglDisplay,
Expand All @@ -229,18 +225,19 @@ public static EGLSurface getEglSurfaceBt2020(EGLDisplay eglDisplay, Object surfa
* @param eglDisplay The {@link EGLDisplay} to attach the surface to.
* @param width The width 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)
private static EGLSurface createPbufferSurface(EGLDisplay eglDisplay, int width, int height)
throws GlException {
private static EGLSurface createPbufferSurface(
EGLDisplay eglDisplay, int width, int height, int[] configAttributes) throws GlException {
int[] pbufferAttributes =
new int[] {
EGL14.EGL_WIDTH, width,
EGL14.EGL_HEIGHT, height,
EGL14.EGL_NONE
};
return Api17.createEglPbufferSurface(
eglDisplay, EGL_CONFIG_ATTRIBUTES_RGBA_8888, pbufferAttributes);
return Api17.createEglPbufferSurface(eglDisplay, configAttributes, pbufferAttributes);
}

/**
Expand All @@ -254,7 +251,8 @@ private static EGLSurface createPbufferSurface(EGLDisplay eglDisplay, int width,
public static EGLSurface createPlaceholderEglSurface(EGLDisplay eglDisplay) throws GlException {
return isSurfacelessContextExtensionSupported()
? EGL14.EGL_NO_SURFACE
: createPbufferSurface(eglDisplay, /* width= */ 1, /* height= */ 1);
: createPbufferSurface(
eglDisplay, /* width= */ 1, /* height= */ 1, EGL_CONFIG_ATTRIBUTES_RGBA_8888);
}

/**
Expand All @@ -266,33 +264,24 @@ public static EGLSurface createPlaceholderEglSurface(EGLDisplay eglDisplay) thro
@RequiresApi(17)
public static void focusPlaceholderEglSurface(EGLContext eglContext, EGLDisplay eglDisplay)
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);
}

/**
* Creates and focuses a new {@link EGLSurface} wrapping a 1x1 pixel buffer, for HDR rendering
* with Rec. 2020 color primaries.
* Creates and focuses a new RGBA 1010102 {@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 focusPlaceholderEglSurfaceBt2020(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
};
public static void focusPlaceholderEglSurfaceRgba1010102(
EGLContext eglContext, EGLDisplay eglDisplay) throws GlException {
EGLSurface eglSurface =
Api17.createEglPbufferSurface(
eglDisplay, EGL_CONFIG_ATTRIBUTES_RGBA_1010102, pbufferAttributes);
createPbufferSurface(
eglDisplay, /* width= */ 1, /* height= */ 1, EGL_CONFIG_ATTRIBUTES_RGBA_1010102);
focusEglSurface(eglDisplay, eglContext, eglSurface, /* width= */ 1, /* height= */ 1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ private synchronized boolean ensureConfigured(int inputWidth, int inputHeight)
@Nullable EGLSurface outputEglSurface = this.outputEglSurface;
if (outputEglSurface == null) { // This means that outputSurfaceInfo changed.
if (useHdr) {
outputEglSurface = GlUtil.getEglSurfaceBt2020(eglDisplay, outputSurfaceInfo.surface);
outputEglSurface = GlUtil.getEglSurfaceRgba1010102(eglDisplay, outputSurfaceInfo.surface);
} else {
outputEglSurface = GlUtil.getEglSurface(eglDisplay, outputSurfaceInfo.surface);
}
Expand Down Expand Up @@ -317,7 +317,7 @@ public synchronized void maybeRenderToSurfaceView(FrameProcessingTask renderingT

if (eglSurface == null) {
if (useHdr) {
eglSurface = GlUtil.getEglSurfaceBt2020(eglDisplay, surface);
eglSurface = GlUtil.getEglSurfaceRgba1010102(eglDisplay, surface);
} else {
eglSurface = GlUtil.getEglSurface(eglDisplay, surface);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ private static GlEffectsFrameProcessor createOpenGlObjectsAndFrameProcessor(
GlUtil.focusEglSurface(
eglDisplay, eglContext, EGL14.EGL_NO_SURFACE, /* width= */ 1, /* height= */ 1);
} else if (useHdr) {
GlUtil.focusPlaceholderEglSurfaceBt2020(eglContext, eglDisplay);
GlUtil.focusPlaceholderEglSurfaceRgba1010102(eglContext, eglDisplay);
} else {
GlUtil.focusPlaceholderEglSurface(eglContext, eglDisplay);
}
Expand Down

0 comments on commit bbbb009

Please sign in to comment.