EGLSpec
interface EGLSpec
Interface for accessing various EGL facilities independent of EGL versions. That is each EGL version implements this specification.
EGLSpec is not thread safe and is up to the caller of these methods to guarantee thread safety.
Summary
Public companion functions |
|
|---|---|
String |
getStatusString(error: Int)Return a string representation of the corresponding EGL status code. |
Public functions |
|
|---|---|
Int |
eglClientWaitSyncKHR(sync: EGLSyncKHR, flags: Int, timeoutNanos: Long)Blocks the calling thread until the specified sync object is signalled or until |
EGLContext |
eglCreateContext(config: EGLConfig)Create an EGLContext with the default display. |
EGLImageKHR? |
@RequiresApi(value = 26)Creates an EGLImage from the provided |
EGLSurface |
eglCreatePBufferSurface(Create a Pixel Buffer surface with the corresponding |
EGLSyncKHR? |
eglCreateSyncKHR(type: Int, attributes: EGLConfigAttributes?)Creates a sync object of the specified type associated with the specified display, and returns a handle to the new object. |
EGLSurface |
eglCreateWindowSurface(Creates an on screen EGL window surface from the given |
Unit |
eglDestroyContext(eglContext: EGLContext)Destroy the given EGLContext generated in |
Boolean |
eglDestroyImageKHR(image: EGLImageKHR)Destroy the given |
Boolean |
eglDestroySurface(surface: EGLSurface)Destroys an EGL surface. |
Boolean |
eglDestroySyncKHR(sync: EGLSyncKHR)Destroys the given sync object associated with the specified display |
EGLSurface |
Return the current surface used for drawing pixels. |
EGLSurface |
Return the current surface used for reading or copying pixels. |
Int |
Returns the error of the last called EGL function in the current thread. |
Boolean |
eglGetSyncAttribKHR(Query attributes of the provided sync object. |
EGLVersion |
Initialize the EGL implementation and return the major and minor version of the EGL implementation through |
Boolean |
eglMakeCurrent(Binds the current context to the given draw and read surfaces. |
String |
eglQueryString(nameId: Int)Query for the capabilities associated with the given eglDisplay. |
Boolean |
eglQuerySurface(Query the EGL attributes of the provided surface |
Boolean |
eglSwapBuffers(surface: EGLSurface)Post EGL surface color buffer to a native window |
open String |
Convenience method to obtain the corresponding error string from the error code obtained from |
EGLConfig? |
loadConfig(configAttributes: EGLConfigAttributes)Load a corresponding EGLConfig from the provided |
Public companion functions
getStatusString
fun getStatusString(error: Int): String
Return a string representation of the corresponding EGL status code. If the provided error value is not an EGL status code, the hex representation is returned instead
Public functions
eglClientWaitSyncKHR
fun eglClientWaitSyncKHR(sync: EGLSyncKHR, flags: Int, timeoutNanos: Long): Int
Blocks the calling thread until the specified sync object is signalled or until timeoutNanos nanoseconds have passed. More than one eglClientWaitSyncKHR may be outstanding on the same sync at any given time. When there are multiple threads blocked on the same sync and the sync object has signalled, all such threads are released, but the order in which they are released is not defined.
If the value of timeoutNanos is zero, then eglClientWaitSyncKHR simply tests the current status of sync. If the value of timeoutNanos is the special value EGL_FOREVER_KHR, then eglClientWaitSyncKHR does not time out. For all other values, timeoutNanos is adjusted to the closest value allowed by the implementation-dependent timeout accuracy, which may be substantially longer than one nanosecond.
eglClientWaitSyncKHR returns one of three status values describing the reason for returning. A return value of EGL_TIMEOUT_EXPIRED_KHR indicates that the specified timeout period expired before sync was signalled, or if timeoutNanos is zero, indicates that sync is not signaled. A return value of EGL_CONDITION_SATISFIED_KHR indicates that sync was signaled before the timeout expired, which includes the case when sync was already signaled when eglClientWaitSyncKHR was called. If an error occurs then an error is generated and EGL_FALSE is returned.
If the sync object being blocked upon will not be signaled in finite time (for example by an associated fence command issued previously, but not yet flushed to the graphics pipeline), then eglClientWaitSyncKHR may wait forever. To help prevent this behavior, if the EGL_SYNC_FLUSH_COMMANDS_BIT_KHR is set on the flags parameter and the sync is unsignaled when eglClientWaitSyncKHR is called, then the equivalent flush will be performed for the current EGL context before blocking on sync. If no context is current bound for the API, the EGL_SYNC_FLUSH_COMMANDS_BIT_KHR bit is ignored.
| Parameters | |
|---|---|
sync: EGLSyncKHR |
EGLSyncKHR object to wait on |
flags: Int |
Optional flags to provide to handle flushing of pending commands |
timeoutNanos: Long |
Optional timeout value to wait before this method returns, measured in nanoseconds. This value is always consumed as an unsigned long value so even negative values will be converted to their unsigned equivalent. |
| Returns | |
|---|---|
Int |
Result code indicating the status of the wait request. Either |
eglCreateContext
fun eglCreateContext(config: EGLConfig): EGLContext
Create an EGLContext with the default display. If createContext fails to create a rendering context, EGL_NO_CONTEXT is returned
| Parameters | |
|---|---|
config: EGLConfig |
|
eglCreateImageFromHardwareBuffer
@RequiresApi(value = 26)
fun eglCreateImageFromHardwareBuffer(hardwareBuffer: HardwareBuffer): EGLImageKHR?
Creates an EGLImage from the provided HardwareBuffer. This handles internally creating an EGLClientBuffer and an EGLImageKHR from the client buffer.
When this EGLImageKHR instance is no longer necessary, consumers should be sure to call the corresponding method eglDestroyImageKHR to deallocate the resource.
| Parameters | |
|---|---|
hardwareBuffer: HardwareBuffer |
Backing |
| Returns | |
|---|---|
EGLImageKHR? |
an This can return null if the EGL_ANDROID_image_native_buffer and EGL_KHR_image_base extensions are not supported or if allocation of the buffer fails. See www.khronos.org/registry/EGL/extensions/ANDROID/EGL_ANDROID_get_native_client_buffer.txt |
eglCreatePBufferSurface
fun eglCreatePBufferSurface(
config: EGLConfig,
configAttributes: EGLConfigAttributes?
): EGLSurface
Create a Pixel Buffer surface with the corresponding EGLConfigAttributes. Accepted attributes are defined as part of the OpenGL specification here: https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglCreatePbufferSurface.xhtml
If a pixel buffer surface could not be created, EGL14.EGL_NO_SURFACE is returned.
| Parameters | |
|---|---|
config: EGLConfig |
Specifies the EGL Frame buffer configuration that defines the frame buffer resource available to the surface |
configAttributes: EGLConfigAttributes? |
Optional list of attributes for the pixel buffer surface |
eglCreateSyncKHR
fun eglCreateSyncKHR(type: Int, attributes: EGLConfigAttributes?): EGLSyncKHR?
Creates a sync object of the specified type associated with the specified display, and returns a handle to the new object. The configuration of the returned EGLSyncKHR object is specified by the provided attributes.
Consumers should ensure that the EGL_KHR_fence_sync EGL extension is supported before invoking this method otherwise a null EGLSyncFenceKHR object is returned.
When the EGLSyncKHR instance is no longer necessary, consumers are encouraged to call eglDestroySyncKHR to deallocate this resource.
See: https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_fence_sync.txt
| Parameters | |
|---|---|
type: Int |
Indicates the type of sync object that is returned |
attributes: EGLConfigAttributes? |
Specifies the configuration of the sync object returned |
| Returns | |
|---|---|
EGLSyncKHR? |
the |
eglCreateWindowSurface
fun eglCreateWindowSurface(
config: EGLConfig,
surface: Surface,
configAttributes: EGLConfigAttributes?
): EGLSurface
Creates an on screen EGL window surface from the given Surface and returns a handle to it.
See https://khronos.org/registry/EGL/sdk/docs/man/html/eglCreateWindowSurface.xhtml
| Parameters | |
|---|---|
config: EGLConfig |
Specifies the EGL frame buffer configuration that defines the frame buffer resource available to the surface |
surface: Surface |
Android surface to consume rendered content |
configAttributes: EGLConfigAttributes? |
Optional list of attributes for the specified surface |
eglDestroyContext
fun eglDestroyContext(eglContext: EGLContext): Unit
Destroy the given EGLContext generated in eglCreateContext
See https://khronos.org/registry/EGL/sdk/docs/man/html/eglDestroyContext.xhtml
| Parameters | |
|---|---|
eglContext: EGLContext |
EGL rendering context to be destroyed |
eglDestroyImageKHR
fun eglDestroyImageKHR(image: EGLImageKHR): Boolean
Destroy the given EGLImageKHR instance. Once destroyed, the image may not be used to create any additional EGLImageKHR target resources within any client API contexts, although existing EGLImageKHR siblings may continue to be used. true is returned if DestroyImageKHR succeeds, false indicates failure. This can return false if the corresponding EGLContext is not valid.
See: https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_image_base.txt
| Parameters | |
|---|---|
image: EGLImageKHR |
EGLImageKHR to be destroyed |
| Returns | |
|---|---|
Boolean |
|
eglDestroySurface
fun eglDestroySurface(surface: EGLSurface): Boolean
Destroys an EGL surface.
If the EGL surface is not current to any thread, eglDestroySurface destroys it immediately. Otherwise, surface is destroyed when it becomes not current to any thread. Furthermore, resources associated with a pbuffer surface are not released until all color buffers of that pbuffer bound to a texture object have been released. Deferral of surface destruction would still return true as deferral does not indicate a failure condition
| Returns | |
|---|---|
Boolean |
|
eglDestroySyncKHR
fun eglDestroySyncKHR(sync: EGLSyncKHR): Boolean
Destroys the given sync object associated with the specified display
Consumers should ensure that the EGL_KHR_fence_sync EGL extension is supported before invoking this method otherwise a null EGLSyncFenceKHR object is returned. See: https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_fence_sync.txt
| Parameters | |
|---|---|
sync: EGLSyncKHR |
Fence object to be destroyed |
| Returns | |
|---|---|
Boolean |
|
eglGetCurrentDrawSurface
fun eglGetCurrentDrawSurface(): EGLSurface
Return the current surface used for drawing pixels. If no context is current, EGL14.EGL_NO_SURFACE is returned.
eglGetCurrentReadSurface
fun eglGetCurrentReadSurface(): EGLSurface
Return the current surface used for reading or copying pixels. If no context is current, EGL14.EGL_NO_SURFACE is returned
eglGetError
fun eglGetError(): Int
Returns the error of the last called EGL function in the current thread. Initially, the error is set to EGL_SUCCESS. When an EGL function could potentially generate several different errors (for example, when passed both a bad attribute name, and a bad attribute value for a legal attribute name), the implementation may choose to generate any one of the applicable errors.
See https://khronos.org/registry/EGL/sdk/docs/man/html/eglGetError.xhtml for more information and error codes that could potentially be returned
eglGetSyncAttribKHR
fun eglGetSyncAttribKHR(
sync: EGLSyncKHR,
attribute: Int,
value: IntArray,
offset: Int
): Boolean
Query attributes of the provided sync object. Accepted attributes to query depend on the type of sync object. If no errors are generated, this returns true and the value of the queried attribute is stored in the value array at the offset position. If this method returns false, the provided value array is unmodified.
See: https://www.khronos.org/registry/EGL/extensions/KHR/EGL_KHR_fence_sync.txt
| Parameters | |
|---|---|
sync: EGLSyncKHR |
EGLSyncKHR object to query attributes |
attribute: Int |
Corresponding EGLSyncKHR attribute to query on |
value: IntArray |
Integer array used to store the result of the query |
offset: Int |
Index within the value array to store the result of the attribute query |
| Returns | |
|---|---|
Boolean |
|
eglInitialize
fun eglInitialize(): EGLVersion
Initialize the EGL implementation and return the major and minor version of the EGL implementation through EGLVersion. If initialization fails, this returns EGLVersion.Unknown
eglMakeCurrent
fun eglMakeCurrent(
context: EGLContext,
drawSurface: EGLSurface,
readSurface: EGLSurface
): Boolean
Binds the current context to the given draw and read surfaces. The draw surface is used for all operations except for any pixel data read back or copy operations which are taken from the read surface.
The same EGLSurface may be specified for both draw and read surfaces.
See https://www.khronos.org/registry/EGL/sdk/docs/man/html/eglMakeCurrent.xhtml for more information
| Parameters | |
|---|---|
context: EGLContext |
EGL rendering context to be attached to the surfaces |
drawSurface: EGLSurface |
EGLSurface to draw pixels into. |
readSurface: EGLSurface |
EGLSurface used for read/copy operations. |
eglQueryString
fun eglQueryString(nameId: Int): String
Query for the capabilities associated with the given eglDisplay. The result contains a space separated list of the capabilities.
| Parameters | |
|---|---|
nameId: Int |
identifier for the EGL string to query |
eglQuerySurface
fun eglQuerySurface(
surface: EGLSurface,
attribute: Int,
result: IntArray,
offset: Int
): Boolean
Query the EGL attributes of the provided surface
| Parameters | |
|---|---|
surface: EGLSurface |
EGLSurface to be queried |
attribute: Int |
EGL attribute to query on the given EGL Surface |
result: IntArray |
Int array to store the result of the query |
offset: Int |
Index within |
eglSwapBuffers
fun eglSwapBuffers(surface: EGLSurface): Boolean
Post EGL surface color buffer to a native window
See https://khronos.org/registry/EGL/sdk/docs/man/html/eglSwapBuffers.xhtml
| Parameters | |
|---|---|
surface: EGLSurface |
Specifies the EGL drawing surface whose buffers are to be swapped |
| Returns | |
|---|---|
Boolean |
|
getErrorMessage
open fun getErrorMessage(): String
Convenience method to obtain the corresponding error string from the error code obtained from EGLSpec.eglGetError
loadConfig
fun loadConfig(configAttributes: EGLConfigAttributes): EGLConfig?
Load a corresponding EGLConfig from the provided EGLConfigAttributes If the EGLConfig could not be loaded, null is returned
| Parameters | |
|---|---|
configAttributes: EGLConfigAttributes |
Desired |
| Returns | |
|---|---|
EGLConfig? |
the |