From bbbb009608c9b2fa951d664f4e2478c2cac61459 Mon Sep 17 00:00:00 2001 From: huangdarwin Date: Tue, 5 Jul 2022 18:47:29 +0000 Subject: [PATCH] HDR: Remove unused EGL_GL_COLORSPACE_KHR attribute. PiperOrigin-RevId: 459106221 --- .../android/exoplayer2/util/GlUtil.java | 45 +++++++------------ ...lMatrixTransformationProcessorWrapper.java | 4 +- .../transformer/GlEffectsFrameProcessor.java | 2 +- 3 files changed, 20 insertions(+), 31 deletions(-) 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 8bb7fbfa51f..f01b291ee9d 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 @@ -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[] { @@ -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, @@ -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); } /** @@ -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); } /** @@ -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); } diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/FinalMatrixTransformationProcessorWrapper.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/FinalMatrixTransformationProcessorWrapper.java index 03de47336e4..129717f59b5 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/FinalMatrixTransformationProcessorWrapper.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/FinalMatrixTransformationProcessorWrapper.java @@ -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); } @@ -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); } diff --git a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/GlEffectsFrameProcessor.java b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/GlEffectsFrameProcessor.java index 8c85913f494..29a68c63d46 100644 --- a/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/GlEffectsFrameProcessor.java +++ b/library/transformer/src/main/java/com/google/android/exoplayer2/transformer/GlEffectsFrameProcessor.java @@ -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); }