GlObjectsProvider


@UnstableApi
interface GlObjectsProvider

Known direct subclasses
DefaultGlObjectsProvider

Implementation of GlObjectsProvider that configures an EGLContext to share data with a preexisting sharedEglContext.


Provider to customize the creation and maintenance of GL objects.

Summary

Public functions

GlTextureInfo!
createBuffersForTexture(texId: Int, width: Int, height: Int)

Returns a GlTextureInfo containing the identifiers of the newly created buffers.

EGLContext!
createEglContext(
    eglDisplay: EGLDisplay!,
    openGlVersion: @IntRange(from = 2, to = 3) Int,
    configAttributes: IntArray!
)

Creates a new EGLContext for the specified EGLDisplay.

EGLSurface!
createEglSurface(
    eglDisplay: EGLDisplay!,
    surface: Any!,
    @C.ColorTransfer colorTransfer: Int,
    isEncoderInputSurface: Boolean
)

Creates a new EGLSurface wrapping the specified surface.

EGLSurface!
createFocusedPlaceholderEglSurface(
    eglContext: EGLContext!,
    eglDisplay: EGLDisplay!
)

Creates and focuses a placeholder EGLSurface.

Unit
release(eglDisplay: EGLDisplay!)

Releases the created objects.

Public functions

createBuffersForTexture

fun createBuffersForTexture(texId: Int, width: Int, height: Int): GlTextureInfo!

Returns a GlTextureInfo containing the identifiers of the newly created buffers.

Parameters
texId: Int

The identifier of the texture to attach to the buffers.

width: Int

The width of the texture in pixels.

height: Int

The height of the texture in pixels.

Throws
androidx.media3.common.util.GlUtil.GlException

If an error occurs during creation.

createEglContext

fun createEglContext(
    eglDisplay: EGLDisplay!,
    openGlVersion: @IntRange(from = 2, to = 3) Int,
    configAttributes: IntArray!
): EGLContext!

Creates a new EGLContext for the specified EGLDisplay.

Parameters
eglDisplay: EGLDisplay!

The EGLDisplay to create an EGLContext for.

openGlVersion: @IntRange(from = 2, to = 3) Int

The version of OpenGL ES to configure. Accepts either 2, for OpenGL ES 2.0, or 3, for OpenGL ES 3.0.

configAttributes: IntArray!

The attributes to configure EGL with.

Throws
androidx.media3.common.util.GlUtil.GlException

If an error occurs during creation.

createEglSurface

fun createEglSurface(
    eglDisplay: EGLDisplay!,
    surface: Any!,
    @C.ColorTransfer colorTransfer: Int,
    isEncoderInputSurface: Boolean
): EGLSurface!

Creates a new EGLSurface wrapping the specified surface.

Parameters
eglDisplay: EGLDisplay!

The EGLDisplay to attach the surface to.

surface: Any!

The surface to wrap; must be a surface, surface texture or surface holder.

@C.ColorTransfer colorTransfer: Int

The color transfer characteristics to which the surface is configured.

isEncoderInputSurface: Boolean

Whether the surface is the input surface of an encoder.

Throws
androidx.media3.common.util.GlUtil.GlException

If an error occurs during creation.

createFocusedPlaceholderEglSurface

fun createFocusedPlaceholderEglSurface(
    eglContext: EGLContext!,
    eglDisplay: EGLDisplay!
): EGLSurface!

Creates and focuses a placeholder EGLSurface.

Parameters
eglContext: EGLContext!

The EGLContext to make current.

eglDisplay: EGLDisplay!

The EGLDisplay to attach the surface to.

Returns
EGLSurface!

A placeholder EGLSurface that has been focused to allow rendering to take place, or EGL_NO_SURFACE if the current context supports rendering without a surface.

Throws
androidx.media3.common.util.GlUtil.GlException

If an error occurs during creation.

release

fun release(eglDisplay: EGLDisplay!): Unit

Releases the created objects.

Parameters
eglDisplay: EGLDisplay!

The EGLDisplay to release the objects for.