GlObjectsProvider


@UnstableApi
public 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 methods

abstract GlTextureInfo
createBuffersForTexture(int texId, int width, int height)

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

abstract EGLContext
createEglContext(
    EGLDisplay eglDisplay,
    @IntRange(from = 2, to = 3) int openGlVersion,
    int[] configAttributes
)

Creates a new EGLContext for the specified EGLDisplay.

abstract EGLSurface
createEglSurface(
    EGLDisplay eglDisplay,
    Object surface,
    @C.ColorTransfer int colorTransfer,
    boolean isEncoderInputSurface
)

Creates a new EGLSurface wrapping the specified surface.

abstract EGLSurface
createFocusedPlaceholderEglSurface(
    EGLContext eglContext,
    EGLDisplay eglDisplay
)

Creates and focuses a placeholder EGLSurface.

abstract void
release(EGLDisplay eglDisplay)

Releases the created objects.

Public methods

createBuffersForTexture

abstract GlTextureInfo createBuffersForTexture(int texId, int width, int height)

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

Parameters
int texId

The identifier of the texture to attach to the buffers.

int width

The width of the texture in pixels.

int height

The height of the texture in pixels.

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

If an error occurs during creation.

createEglContext

abstract EGLContext createEglContext(
    EGLDisplay eglDisplay,
    @IntRange(from = 2, to = 3) int openGlVersion,
    int[] configAttributes
)

Creates a new EGLContext for the specified EGLDisplay.

Parameters
EGLDisplay eglDisplay

The EGLDisplay to create an EGLContext for.

@IntRange(from = 2, to = 3) int openGlVersion

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

int[] configAttributes

The attributes to configure EGL with.

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

If an error occurs during creation.

createEglSurface

abstract EGLSurface createEglSurface(
    EGLDisplay eglDisplay,
    Object surface,
    @C.ColorTransfer int colorTransfer,
    boolean isEncoderInputSurface
)

Creates a new EGLSurface wrapping the specified surface.

Parameters
EGLDisplay eglDisplay

The EGLDisplay to attach the surface to.

Object surface

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

@C.ColorTransfer int colorTransfer

The color transfer characteristics to which the surface is configured.

boolean isEncoderInputSurface

Whether the surface is the input surface of an encoder.

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

If an error occurs during creation.

createFocusedPlaceholderEglSurface

abstract EGLSurface createFocusedPlaceholderEglSurface(
    EGLContext eglContext,
    EGLDisplay eglDisplay
)

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

abstract void release(EGLDisplay eglDisplay)

Releases the created objects.

Parameters
EGLDisplay eglDisplay

The EGLDisplay to release the objects for.