Class GlUtil
- java.lang.Object
-
- com.google.android.exoplayer2.util.GlUtil
-
@Deprecated public final class GlUtil extends Object
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.OpenGL ES utilities.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGlUtil.GlExceptionDeprecated.Thrown when an OpenGL error occurs.
-
Field Summary
Fields Modifier and Type Field Description static int[]EGL_CONFIG_ATTRIBUTES_RGBA_1010102Deprecated.static int[]EGL_CONFIG_ATTRIBUTES_RGBA_8888Deprecated.static intHOMOGENEOUS_COORDINATE_VECTOR_SIZEDeprecated.Number of elements in a 3d homogeneous coordinate vector describing a vertex.static floatLENGTH_NDCDeprecated.Length of the normalized device coordinate (NDC) space, which spans from -1 to 1.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static voidbindTexture(int textureTarget, int texId)Deprecated.Binds the texture of the given type with default configuration of GL_LINEAR filtering and GL_CLAMP_TO_EDGE wrapping.static voidcheckGlError()Deprecated.Collects all OpenGL errors that occurred since this method was last called and throws aGlUtil.GlExceptionwith the combined error message.static voidcheckGlException(boolean expression, String errorMessage)Deprecated.static voidclearOutputFrame()Deprecated.Fills the pixels in the current output render target with (r=0, g=0, b=0, a=0).static float[]create4x4IdentityMatrix()Deprecated.Creates a 4x4 identity matrix.static FloatBuffercreateBuffer(float[] data)Deprecated.Allocates a FloatBuffer with the given data.static EGLContextcreateEglContext(EGLContext sharedContext, EGLDisplay eglDisplay, int openGlVersion, int[] configAttributes)Deprecated.Creates a newEGLContextfor the specifiedEGLDisplay.static EGLContextcreateEglContext(EGLDisplay eglDisplay)Deprecated.Creates a newEGLContextfor the specifiedEGLDisplay.static EGLDisplaycreateEglDisplay()Deprecated.Returns an initialized defaultEGLDisplay.static EGLSurfacecreateEglSurface(EGLDisplay eglDisplay, Object surface, @com.google.android.exoplayer2.C.ColorTransfer int colorTransfer, boolean isEncoderInputSurface)Deprecated.Creates a newEGLSurfacewrapping the specifiedsurface.static intcreateExternalTexture()Deprecated.Creates a GL_TEXTURE_EXTERNAL_OES with default configuration of GL_LINEAR filtering and GL_CLAMP_TO_EDGE wrapping.static intcreateFboForTexture(int texId)Deprecated.Returns a new framebuffer for the texture.static EGLSurfacecreateFocusedPlaceholderEglSurface(EGLContext eglContext, EGLDisplay eglDisplay, int[] configAttributes)Deprecated.Creates and focuses a placeholderEGLSurface.static intcreateTexture(int width, int height, boolean useHighPrecisionColorComponents)Deprecated.Allocates a new RGBA texture with the specified dimensions and color component precision.static float[]createVertexBuffer(List<float[]> vertexList)Deprecated.Flattens the list of 4 element NDC coordinate vectors into a buffer.static voiddeleteFbo(int fboId)Deprecated.Deletes a framebuffer, or silently ignores the method call iffboIdis unused.static voiddeleteRbo(int rboId)Deprecated.Deletes a renderbuffer, or silently ignores the method call ifrboIdis unused.static voiddeleteTexture(int textureId)Deprecated.Deletes a GL texture.static voiddestroyEglContext(EGLDisplay eglDisplay, EGLContext eglContext)Deprecated.static voiddestroyEglSurface(EGLDisplay eglDisplay, EGLSurface eglSurface)Deprecated.static voidfocusEglSurface(EGLDisplay eglDisplay, EGLContext eglContext, EGLSurface eglSurface, int width, int height)Deprecated.Makes the specifiedeglSurfacethe render target, using a viewport ofwidthbyheightpixels.static voidfocusFramebuffer(EGLDisplay eglDisplay, EGLContext eglContext, EGLSurface eglSurface, int framebuffer, int width, int height)Deprecated.Makes the specifiedframebufferthe render target, using a viewport ofwidthbyheightpixels.static voidfocusFramebufferUsingCurrentContext(int framebuffer, int width, int height)Deprecated.Makes the specifiedframebufferthe render target, using a viewport ofwidthbyheightpixels.static EGLSurfacefocusPlaceholderEglSurface(EGLContext eglContext, EGLDisplay eglDisplay)Deprecated.Creates and focuses a placeholderEGLSurface.static EGLContextgetCurrentContext()Deprecated.Gets the currentcontext.static float[]getNormalizedCoordinateBounds()Deprecated.Bounds of normalized device coordinates, commonly used for defining viewport boundaries.static float[]getTextureCoordinateBounds()Deprecated.Typical bounds used for sampling from textures.static booleanisBt2020PqExtensionSupported()Deprecated.Returns whetherEXTENSION_COLORSPACE_BT2020_PQis supported.static booleanisProtectedContentExtensionSupported(Context context)Deprecated.Returns whether creating a GL context withEXTENSION_PROTECTED_CONTENTis possible.static booleanisSurfacelessContextExtensionSupported()Deprecated.Returns whether theEXTENSION_SURFACELESS_CONTEXTextension is supported.static booleanisYuvTargetExtensionSupported()Deprecated.Returns whether theEXTENSION_YUV_TARGETextension is supported.static voidsetToIdentity(float[] matrix)Deprecated.Sets the inputmatrixto an identity matrix.
-
-
-
Field Detail
-
HOMOGENEOUS_COORDINATE_VECTOR_SIZE
public static final int HOMOGENEOUS_COORDINATE_VECTOR_SIZE
Deprecated.Number of elements in a 3d homogeneous coordinate vector describing a vertex.- See Also:
- Constant Field Values
-
LENGTH_NDC
public static final float LENGTH_NDC
Deprecated.Length of the normalized device coordinate (NDC) space, which spans from -1 to 1.- See Also:
- Constant Field Values
-
EGL_CONFIG_ATTRIBUTES_RGBA_8888
public static final int[] EGL_CONFIG_ATTRIBUTES_RGBA_8888
Deprecated.
-
EGL_CONFIG_ATTRIBUTES_RGBA_1010102
public static final int[] EGL_CONFIG_ATTRIBUTES_RGBA_1010102
Deprecated.
-
-
Method Detail
-
getNormalizedCoordinateBounds
public static float[] getNormalizedCoordinateBounds()
Deprecated.Bounds of normalized device coordinates, commonly used for defining viewport boundaries.
-
getTextureCoordinateBounds
public static float[] getTextureCoordinateBounds()
Deprecated.Typical bounds used for sampling from textures.
-
create4x4IdentityMatrix
public static float[] create4x4IdentityMatrix()
Deprecated.Creates a 4x4 identity matrix.
-
setToIdentity
public static void setToIdentity(float[] matrix)
Deprecated.Sets the inputmatrixto an identity matrix.
-
createVertexBuffer
public static float[] createVertexBuffer(List<float[]> vertexList)
Deprecated.Flattens the list of 4 element NDC coordinate vectors into a buffer.
-
isProtectedContentExtensionSupported
public static boolean isProtectedContentExtensionSupported(Context context)
Deprecated.Returns whether creating a GL context withEXTENSION_PROTECTED_CONTENTis possible.If
true, the device supports a protected output path for DRM content when using GL.
-
isSurfacelessContextExtensionSupported
public static boolean isSurfacelessContextExtensionSupported()
Deprecated.Returns whether theEXTENSION_SURFACELESS_CONTEXTextension is supported.This extension allows passing
EGL14.EGL_NO_SURFACEfor both the write and read surfaces in a call toEGL14.eglMakeCurrent(EGLDisplay, EGLSurface, EGLSurface, EGLContext).
-
isYuvTargetExtensionSupported
public static boolean isYuvTargetExtensionSupported()
Deprecated.Returns whether theEXTENSION_YUV_TARGETextension is supported.This extension allows sampling raw YUV values from an external texture, which is required for HDR input.
-
isBt2020PqExtensionSupported
public static boolean isBt2020PqExtensionSupported()
Deprecated.Returns whetherEXTENSION_COLORSPACE_BT2020_PQis supported.
-
createEglDisplay
@RequiresApi(17) public static EGLDisplay createEglDisplay() throws GlUtil.GlException
Deprecated.Returns an initialized defaultEGLDisplay.- Throws:
GlUtil.GlException
-
createEglContext
@RequiresApi(17) public static EGLContext createEglContext(EGLDisplay eglDisplay) throws GlUtil.GlException
Deprecated.Creates a newEGLContextfor the specifiedEGLDisplay.Configures the
EGLContextwithEGL_CONFIG_ATTRIBUTES_RGBA_8888and OpenGL ES 2.0.- Parameters:
eglDisplay- TheEGLDisplayto create anEGLContextfor.- Throws:
GlUtil.GlException
-
createEglContext
@RequiresApi(17) public static EGLContext createEglContext(EGLContext sharedContext, EGLDisplay eglDisplay, @IntRange(from=2L,to=3L) int openGlVersion, int[] configAttributes) throws GlUtil.GlException
Deprecated.Creates a newEGLContextfor the specifiedEGLDisplay.- Parameters:
sharedContext- TheEGLContextwith which to share data.eglDisplay- TheEGLDisplayto create anEGLContextfor.openGlVersion- The version of OpenGL ES to configure. Accepts either2, for OpenGL ES 2.0, or3, for OpenGL ES 3.0.configAttributes- The attributes to configure EGL with. Accepts eitherEGL_CONFIG_ATTRIBUTES_RGBA_1010102, orEGL_CONFIG_ATTRIBUTES_RGBA_8888.- Throws:
GlUtil.GlException
-
createEglSurface
@RequiresApi(17) public static EGLSurface createEglSurface(EGLDisplay eglDisplay, Object surface, @com.google.android.exoplayer2.C.ColorTransfer int colorTransfer, boolean isEncoderInputSurface) throws GlUtil.GlException
Deprecated.Creates a newEGLSurfacewrapping the specifiedsurface.The
EGLSurfacewill configure with OpenGL ES 2.0.- Parameters:
eglDisplay- TheEGLDisplayto attach the surface to.surface- The surface to wrap; must be a surface, surface texture or surface holder.colorTransfer- The color transfer characteristics to which thesurfaceis configured. The only accepted values areC.COLOR_TRANSFER_SDR,C.COLOR_TRANSFER_HLGandC.COLOR_TRANSFER_ST2084.isEncoderInputSurface- Whether thesurfaceis the input surface of an encoder.- Throws:
GlUtil.GlException
-
focusPlaceholderEglSurface
@RequiresApi(17) public static EGLSurface focusPlaceholderEglSurface(EGLContext eglContext, EGLDisplay eglDisplay) throws GlUtil.GlException
Deprecated.Creates and focuses a placeholderEGLSurface.This makes a
EGLContextcurrent when reading and writing to a surface is not required, configured withEGL_CONFIG_ATTRIBUTES_RGBA_8888.- Parameters:
eglContext- TheEGLContextto make current.eglDisplay- TheEGLDisplayto attach the surface to.- Returns:
EGL14.EGL_NO_SURFACEif supported and a 1x1 pixel buffer surface otherwise.- Throws:
GlUtil.GlException
-
createFocusedPlaceholderEglSurface
@RequiresApi(17) public static EGLSurface createFocusedPlaceholderEglSurface(EGLContext eglContext, EGLDisplay eglDisplay, int[] configAttributes) throws GlUtil.GlException
Deprecated.Creates and focuses a placeholderEGLSurface.This makes a
EGLContextcurrent when reading and writing to a surface is not required.- Parameters:
eglContext- TheEGLContextto make current.eglDisplay- TheEGLDisplayto attach the surface to.configAttributes- The attributes to configure EGL with. AcceptsEGL_CONFIG_ATTRIBUTES_RGBA_1010102andEGL_CONFIG_ATTRIBUTES_RGBA_8888.- Returns:
- A placeholder
EGLSurfacethat has been focused to allow rendering to take place, orEGL14.EGL_NO_SURFACEif the current context supports rendering without a surface. - Throws:
GlUtil.GlException
-
getCurrentContext
public static EGLContext getCurrentContext()
Deprecated.Gets the currentcontext.
-
checkGlError
public static void checkGlError() throws GlUtil.GlExceptionDeprecated.Collects all OpenGL errors that occurred since this method was last called and throws aGlUtil.GlExceptionwith the combined error message.- Throws:
GlUtil.GlException
-
clearOutputFrame
public static void clearOutputFrame() throws GlUtil.GlExceptionDeprecated.Fills the pixels in the current output render target with (r=0, g=0, b=0, a=0).- Throws:
GlUtil.GlException
-
focusEglSurface
@RequiresApi(17) public static void focusEglSurface(EGLDisplay eglDisplay, EGLContext eglContext, EGLSurface eglSurface, int width, int height) throws GlUtil.GlException
Deprecated.Makes the specifiedeglSurfacethe render target, using a viewport ofwidthbyheightpixels.- Throws:
GlUtil.GlException
-
focusFramebuffer
@RequiresApi(17) public static void focusFramebuffer(EGLDisplay eglDisplay, EGLContext eglContext, EGLSurface eglSurface, int framebuffer, int width, int height) throws GlUtil.GlException
Deprecated.Makes the specifiedframebufferthe render target, using a viewport ofwidthbyheightpixels.- Throws:
GlUtil.GlException
-
focusFramebufferUsingCurrentContext
@RequiresApi(17) public static void focusFramebufferUsingCurrentContext(int framebuffer, int width, int height) throws GlUtil.GlExceptionDeprecated.Makes the specifiedframebufferthe render target, using a viewport ofwidthbyheightpixels.The caller must ensure that there is a current OpenGL context before calling this method.
- Parameters:
framebuffer- The identifier of the framebuffer object to bind as the output render target.width- The viewport width, in pixels.height- The viewport height, in pixels.- Throws:
GlUtil.GlException
-
createBuffer
public static FloatBuffer createBuffer(float[] data)
Deprecated.Allocates a FloatBuffer with the given data.- Parameters:
data- Used to initialize the new buffer.
-
createExternalTexture
public static int createExternalTexture() throws GlUtil.GlExceptionDeprecated.Creates a GL_TEXTURE_EXTERNAL_OES with default configuration of GL_LINEAR filtering and GL_CLAMP_TO_EDGE wrapping.- Throws:
GlUtil.GlException
-
createTexture
public static int createTexture(int width, int height, boolean useHighPrecisionColorComponents) throws GlUtil.GlExceptionDeprecated.Allocates a new RGBA texture with the specified dimensions and color component precision.- Parameters:
width- The width of the new texture in pixels.height- The height of the new texture in pixels.useHighPrecisionColorComponents- Iffalse, uses colors with 8-bit unsigned bytes. Iftrue, use 16-bit (half-precision) floating-point.- Returns:
- The texture identifier for the newly-allocated texture.
- Throws:
GlUtil.GlException- If the texture allocation fails.
-
bindTexture
public static void bindTexture(int textureTarget, int texId) throws GlUtil.GlExceptionDeprecated.Binds the texture of the given type with default configuration of GL_LINEAR filtering and GL_CLAMP_TO_EDGE wrapping.- Parameters:
textureTarget- The target to which the texture is bound, e.g.GLES20.GL_TEXTURE_2Dfor a two-dimensional texture orGLES11Ext.GL_TEXTURE_EXTERNAL_OESfor an external texture.texId- The texture identifier.- Throws:
GlUtil.GlException
-
createFboForTexture
public static int createFboForTexture(int texId) throws GlUtil.GlExceptionDeprecated.Returns a new framebuffer for the texture.- Parameters:
texId- The identifier of the texture to attach to the framebuffer.- Throws:
GlUtil.GlException
-
deleteTexture
public static void deleteTexture(int textureId) throws GlUtil.GlExceptionDeprecated.Deletes a GL texture.- Parameters:
textureId- The ID of the texture to delete.- Throws:
GlUtil.GlException
-
destroyEglContext
@RequiresApi(17) public static void destroyEglContext(@Nullable EGLDisplay eglDisplay, @Nullable EGLContext eglContext) throws GlUtil.GlExceptionDeprecated.- Throws:
GlUtil.GlException
-
destroyEglSurface
@RequiresApi(17) public static void destroyEglSurface(@Nullable EGLDisplay eglDisplay, @Nullable EGLSurface eglSurface) throws GlUtil.GlExceptionDeprecated.- Throws:
GlUtil.GlException
-
deleteFbo
public static void deleteFbo(int fboId) throws GlUtil.GlExceptionDeprecated.Deletes a framebuffer, or silently ignores the method call iffboIdis unused.- Throws:
GlUtil.GlException
-
deleteRbo
public static void deleteRbo(int rboId) throws GlUtil.GlExceptionDeprecated.Deletes a renderbuffer, or silently ignores the method call ifrboIdis unused.- Throws:
GlUtil.GlException
-
checkGlException
public static void checkGlException(boolean expression, String errorMessage) throws GlUtil.GlExceptionDeprecated.- Throws:
GlUtil.GlException
-
-