library / com.otaliastudios.opengl.surface / EglWindowSurface

EglWindowSurface

open class EglWindowSurface : EglSurface

Recordable EGL window surface. It's good practice to explicitly release() the surface, preferably from a finally block.

Constructors

<init>

EglWindowSurface(eglCore: EglCore, surface: Surface, releaseSurface: Boolean = false)

Set releaseSurface to true if you want the Surface to be released when release() is called. This is convenient, but can interfere with framework classes that expect to manage the Surface themselves (e.g. if you release a SurfaceView's Surface, the surfaceDestroyed() callback won't fire).

EglWindowSurface(eglCore: EglCore, surfaceTexture: SurfaceTexture)

Associates an EGL surface with the SurfaceTexture.

Inherited Properties

eglCore

var eglCore: EglCore

eglSurface

var eglSurface: EGLSurface

Functions

release

open fun release(): Unit

Releases any resources associated with the EGL surface. Does not require that the surface's EGL context be current.

swapBuffers

fun swapBuffers(): Boolean

Calls eglSwapBuffers. Use this to "publish" the current frame. Returns false on failure.

Inherited Functions

getHeight

fun getHeight(): Int

Returns the surface's height, in pixels.

getWidth

fun getWidth(): Int

Returns the surface's width, in pixels.

isCurrent

fun isCurrent(): Boolean

Whether this surface is current on the attached EglCore.

makeCurrent

fun makeCurrent(): Unit

Makes our EGL context and surface current.

fun makeCurrent(readSurface: EglSurface): Unit

Makes our EGL context and surface current for drawing, using the supplied surface for reading.

makeNothingCurrent

fun makeNothingCurrent(): Unit

Makes no surface current for the attached eglCore.

setHeight

fun setHeight(height: Int): Unit

Can be called by subclasses whose height is guaranteed to never change, so we can cache this value. For window surfaces, this should not be called.

setPresentationTime

fun setPresentationTime(nsecs: Long): Unit

Sends the presentation time stamp to EGL. nsecs is the timestamp in nanoseconds.

setWidth

fun setWidth(width: Int): Unit

Can be called by subclasses whose width is guaranteed to never change, so we can cache this value. For window surfaces, this should not be called.

toByteArray

fun toByteArray(format: CompressFormat = Bitmap.CompressFormat.PNG): ByteArray

Saves the EGL surface to given format. Expects that this object's EGL surface is current.

toFile

fun toFile(file: File, format: CompressFormat = Bitmap.CompressFormat.PNG): Unit

Saves the EGL surface to a file. Expects that this object's EGL surface is current.

toOutputStream

fun toOutputStream(stream: OutputStream, format: CompressFormat = Bitmap.CompressFormat.PNG): Unit

Saves the EGL surface to the given output stream. Expects that this object's EGL surface is current.