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 class
GlUtil.GlException
Deprecated.Thrown when an OpenGL error occurs.
-
Field Summary
Fields Modifier and Type Field Description static int[]
EGL_CONFIG_ATTRIBUTES_RGBA_1010102
Deprecated.static int[]
EGL_CONFIG_ATTRIBUTES_RGBA_8888
Deprecated.static int
HOMOGENEOUS_COORDINATE_VECTOR_SIZE
Deprecated.Number of elements in a 3d homogeneous coordinate vector describing a vertex.static float
LENGTH_NDC
Deprecated.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 void
bindTexture(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 void
checkGlError()
Deprecated.Collects all OpenGL errors that occurred since this method was last called and throws aGlUtil.GlException
with the combined error message.static void
checkGlException(boolean expression, String errorMessage)
Deprecated.static void
clearOutputFrame()
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 FloatBuffer
createBuffer(float[] data)
Deprecated.Allocates a FloatBuffer with the given data.static EGLContext
createEglContext(EGLContext sharedContext, EGLDisplay eglDisplay, int openGlVersion, int[] configAttributes)
Deprecated.Creates a newEGLContext
for the specifiedEGLDisplay
.static EGLContext
createEglContext(EGLDisplay eglDisplay)
Deprecated.Creates a newEGLContext
for the specifiedEGLDisplay
.static EGLDisplay
createEglDisplay()
Deprecated.Returns an initialized defaultEGLDisplay
.static EGLSurface
createEglSurface(EGLDisplay eglDisplay, Object surface, @com.google.android.exoplayer2.C.ColorTransfer int colorTransfer, boolean isEncoderInputSurface)
Deprecated.Creates a newEGLSurface
wrapping the specifiedsurface
.static int
createExternalTexture()
Deprecated.Creates a GL_TEXTURE_EXTERNAL_OES with default configuration of GL_LINEAR filtering and GL_CLAMP_TO_EDGE wrapping.static int
createFboForTexture(int texId)
Deprecated.Returns a new framebuffer for the texture.static EGLSurface
createFocusedPlaceholderEglSurface(EGLContext eglContext, EGLDisplay eglDisplay, int[] configAttributes)
Deprecated.Creates and focuses a placeholderEGLSurface
.static int
createTexture(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 void
deleteFbo(int fboId)
Deprecated.Deletes a framebuffer, or silently ignores the method call iffboId
is unused.static void
deleteRbo(int rboId)
Deprecated.Deletes a renderbuffer, or silently ignores the method call ifrboId
is unused.static void
deleteTexture(int textureId)
Deprecated.Deletes a GL texture.static void
destroyEglContext(EGLDisplay eglDisplay, EGLContext eglContext)
Deprecated.static void
destroyEglSurface(EGLDisplay eglDisplay, EGLSurface eglSurface)
Deprecated.static void
focusEglSurface(EGLDisplay eglDisplay, EGLContext eglContext, EGLSurface eglSurface, int width, int height)
Deprecated.Makes the specifiedeglSurface
the render target, using a viewport ofwidth
byheight
pixels.static void
focusFramebuffer(EGLDisplay eglDisplay, EGLContext eglContext, EGLSurface eglSurface, int framebuffer, int width, int height)
Deprecated.Makes the specifiedframebuffer
the render target, using a viewport ofwidth
byheight
pixels.static void
focusFramebufferUsingCurrentContext(int framebuffer, int width, int height)
Deprecated.Makes the specifiedframebuffer
the render target, using a viewport ofwidth
byheight
pixels.static EGLSurface
focusPlaceholderEglSurface(EGLContext eglContext, EGLDisplay eglDisplay)
Deprecated.Creates and focuses a placeholderEGLSurface
.static EGLContext
getCurrentContext()
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 boolean
isBt2020PqExtensionSupported()
Deprecated.Returns whetherEXTENSION_COLORSPACE_BT2020_PQ
is supported.static boolean
isProtectedContentExtensionSupported(Context context)
Deprecated.Returns whether creating a GL context withEXTENSION_PROTECTED_CONTENT
is possible.static boolean
isSurfacelessContextExtensionSupported()
Deprecated.Returns whether theEXTENSION_SURFACELESS_CONTEXT
extension is supported.static boolean
isYuvTargetExtensionSupported()
Deprecated.Returns whether theEXTENSION_YUV_TARGET
extension is supported.static void
setToIdentity(float[] matrix)
Deprecated.Sets the inputmatrix
to 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 inputmatrix
to 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_CONTENT
is 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_CONTEXT
extension is supported.This extension allows passing
EGL14.EGL_NO_SURFACE
for 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_TARGET
extension 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_PQ
is 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 newEGLContext
for the specifiedEGLDisplay
.Configures the
EGLContext
withEGL_CONFIG_ATTRIBUTES_RGBA_8888
and OpenGL ES 2.0.- Parameters:
eglDisplay
- TheEGLDisplay
to create anEGLContext
for.- 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 newEGLContext
for the specifiedEGLDisplay
.- Parameters:
sharedContext
- TheEGLContext
with which to share data.eglDisplay
- TheEGLDisplay
to create anEGLContext
for.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 newEGLSurface
wrapping the specifiedsurface
.The
EGLSurface
will configure with OpenGL ES 2.0.- Parameters:
eglDisplay
- TheEGLDisplay
to 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 thesurface
is configured. The only accepted values areC.COLOR_TRANSFER_SDR
,C.COLOR_TRANSFER_HLG
andC.COLOR_TRANSFER_ST2084
.isEncoderInputSurface
- Whether thesurface
is 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
EGLContext
current when reading and writing to a surface is not required, configured withEGL_CONFIG_ATTRIBUTES_RGBA_8888
.- Parameters:
eglContext
- TheEGLContext
to make current.eglDisplay
- TheEGLDisplay
to attach the surface to.- Returns:
EGL14.EGL_NO_SURFACE
if 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
EGLContext
current when reading and writing to a surface is not required.- Parameters:
eglContext
- TheEGLContext
to make current.eglDisplay
- TheEGLDisplay
to attach the surface to.configAttributes
- The attributes to configure EGL with. AcceptsEGL_CONFIG_ATTRIBUTES_RGBA_1010102
andEGL_CONFIG_ATTRIBUTES_RGBA_8888
.- Returns:
- A placeholder
EGLSurface
that has been focused to allow rendering to take place, orEGL14.EGL_NO_SURFACE
if 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.GlException
Deprecated.Collects all OpenGL errors that occurred since this method was last called and throws aGlUtil.GlException
with the combined error message.- Throws:
GlUtil.GlException
-
clearOutputFrame
public static void clearOutputFrame() throws GlUtil.GlException
Deprecated.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 specifiedeglSurface
the render target, using a viewport ofwidth
byheight
pixels.- 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 specifiedframebuffer
the render target, using a viewport ofwidth
byheight
pixels.- Throws:
GlUtil.GlException
-
focusFramebufferUsingCurrentContext
@RequiresApi(17) public static void focusFramebufferUsingCurrentContext(int framebuffer, int width, int height) throws GlUtil.GlException
Deprecated.Makes the specifiedframebuffer
the render target, using a viewport ofwidth
byheight
pixels.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.GlException
Deprecated.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.GlException
Deprecated.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.GlException
Deprecated.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_2D
for a two-dimensional texture orGLES11Ext.GL_TEXTURE_EXTERNAL_OES
for an external texture.texId
- The texture identifier.- Throws:
GlUtil.GlException
-
createFboForTexture
public static int createFboForTexture(int texId) throws GlUtil.GlException
Deprecated.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.GlException
Deprecated.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.GlException
Deprecated.- Throws:
GlUtil.GlException
-
destroyEglSurface
@RequiresApi(17) public static void destroyEglSurface(@Nullable EGLDisplay eglDisplay, @Nullable EGLSurface eglSurface) throws GlUtil.GlException
Deprecated.- Throws:
GlUtil.GlException
-
deleteFbo
public static void deleteFbo(int fboId) throws GlUtil.GlException
Deprecated.Deletes a framebuffer, or silently ignores the method call iffboId
is unused.- Throws:
GlUtil.GlException
-
deleteRbo
public static void deleteRbo(int rboId) throws GlUtil.GlException
Deprecated.Deletes a renderbuffer, or silently ignores the method call ifrboId
is unused.- Throws:
GlUtil.GlException
-
checkGlException
public static void checkGlException(boolean expression, String errorMessage) throws GlUtil.GlException
Deprecated.- Throws:
GlUtil.GlException
-
-