mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
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 bb215857e5fd0768ce53c7c61ba91c48dab14bd2)
This commit is contained in:
parent
b0ad5c2681
commit
ebc6b67e72
@ -16,6 +16,7 @@
|
|||||||
package androidx.media3.common.util;
|
package androidx.media3.common.util;
|
||||||
|
|
||||||
import static android.opengl.GLU.gluErrorString;
|
import static android.opengl.GLU.gluErrorString;
|
||||||
|
import static androidx.media3.common.util.Assertions.checkArgument;
|
||||||
import static androidx.media3.common.util.Assertions.checkState;
|
import static androidx.media3.common.util.Assertions.checkState;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
@ -35,6 +36,7 @@ import androidx.media3.common.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;
|
||||||
|
|
||||||
@ -57,15 +59,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,
|
||||||
@ -76,7 +70,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,
|
||||||
@ -88,6 +82,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() {}
|
||||||
|
|
||||||
@ -187,12 +190,7 @@ public final class GlUtil {
|
|||||||
try {
|
try {
|
||||||
EGLDisplay eglDisplay = createEglDisplay();
|
EGLDisplay eglDisplay = createEglDisplay();
|
||||||
EGLContext eglContext = createEglContext(eglDisplay);
|
EGLContext eglContext = createEglContext(eglDisplay);
|
||||||
if (GlUtil.isSurfacelessContextExtensionSupported()) {
|
focusPlaceholderEglSurface(eglContext, eglDisplay);
|
||||||
focusEglSurface(
|
|
||||||
eglDisplay, eglContext, EGL14.EGL_NO_SURFACE, /* width= */ 1, /* height= */ 1);
|
|
||||||
} else {
|
|
||||||
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) {
|
||||||
@ -211,25 +209,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.
|
||||||
*/
|
*/
|
||||||
@ -240,19 +258,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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -277,48 +294,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.
|
|
||||||
*
|
*
|
||||||
|
* <p>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.
|
* @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.
|
* @return {@link EGL14#EGL_NO_SURFACE} if supported and a 1x1 pixel buffer surface otherwise.
|
||||||
*/
|
*/
|
||||||
@RequiresApi(17)
|
@RequiresApi(17)
|
||||||
public static EGLSurface createPlaceholderEglSurface(EGLDisplay eglDisplay) throws GlException {
|
public static EGLSurface focusPlaceholderEglSurface(EGLContext eglContext, EGLDisplay eglDisplay)
|
||||||
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)
|
|
||||||
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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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;
|
|||||||
@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;
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 androidx.media3.common.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;
|
||||||
@ -122,19 +121,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(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user