Implement the EGL_KHR_fence_sync in libagl

Implementing this in libagl allows us to start using it for
SurfaceTexture in emulator builds, which is necessary to avoid
corruption in the Browser when using the host-accelerated GL path.

Bug: 6515813
Change-Id: Icafba8687cb5d010d8d42b3866b298d2be984fc9
This commit is contained in:
Jesse Hall 2012-05-22 10:42:56 -07:00
parent cc2b1560e8
commit 83e7c8c431
2 changed files with 78 additions and 0 deletions

View File

@ -796,6 +796,7 @@ static char const * const gVendorString = "Google Inc.";
static char const * const gVersionString = "1.2 Android Driver 1.2.0"; static char const * const gVersionString = "1.2 Android Driver 1.2.0";
static char const * const gClientApiString = "OpenGL_ES"; static char const * const gClientApiString = "OpenGL_ES";
static char const * const gExtensionsString = static char const * const gExtensionsString =
"EGL_KHR_fence_sync "
"EGL_KHR_image_base " "EGL_KHR_image_base "
// "KHR_image_pixmap " // "KHR_image_pixmap "
"EGL_ANDROID_image_native_buffer " "EGL_ANDROID_image_native_buffer "
@ -850,6 +851,14 @@ static const extention_map_t gExtentionMap[] = {
(__eglMustCastToProperFunctionPointerType)&eglCreateImageKHR }, (__eglMustCastToProperFunctionPointerType)&eglCreateImageKHR },
{ "eglDestroyImageKHR", { "eglDestroyImageKHR",
(__eglMustCastToProperFunctionPointerType)&eglDestroyImageKHR }, (__eglMustCastToProperFunctionPointerType)&eglDestroyImageKHR },
{ "eglCreateSyncKHR",
(__eglMustCastToProperFunctionPointerType)&eglCreateSyncKHR },
{ "eglDestroySyncKHR",
(__eglMustCastToProperFunctionPointerType)&eglDestroySyncKHR },
{ "eglClientWaitSyncKHR",
(__eglMustCastToProperFunctionPointerType)&eglClientWaitSyncKHR },
{ "eglGetSyncAttribKHR",
(__eglMustCastToProperFunctionPointerType)&eglGetSyncAttribKHR },
{ "eglSetSwapRectangleANDROID", { "eglSetSwapRectangleANDROID",
(__eglMustCastToProperFunctionPointerType)&eglSetSwapRectangleANDROID }, (__eglMustCastToProperFunctionPointerType)&eglSetSwapRectangleANDROID },
}; };
@ -2056,6 +2065,74 @@ EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img)
return EGL_TRUE; return EGL_TRUE;
} }
// ----------------------------------------------------------------------------
// EGL_KHR_fence_sync
// ----------------------------------------------------------------------------
#define FENCE_SYNC_HANDLE ((EGLSyncKHR)0xFE4CE)
EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type,
const EGLint *attrib_list)
{
if (egl_display_t::is_valid(dpy) == EGL_FALSE) {
return setError(EGL_BAD_DISPLAY, EGL_NO_SYNC_KHR);
}
if (type != EGL_SYNC_FENCE_KHR ||
(attrib_list != NULL && attrib_list[0] != EGL_NONE)) {
return setError(EGL_BAD_ATTRIBUTE, EGL_NO_SYNC_KHR);
}
if (eglGetCurrentContext() == EGL_NO_CONTEXT) {
return setError(EGL_BAD_MATCH, EGL_NO_SYNC_KHR);
}
// AGL is synchronous; nothing to do here.
return FENCE_SYNC_HANDLE;
}
EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync)
{
if (sync != FENCE_SYNC_HANDLE) {
return setError(EGL_BAD_PARAMETER, EGL_FALSE);
}
return EGL_TRUE;
}
EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags,
EGLTimeKHR timeout)
{
if (sync != FENCE_SYNC_HANDLE) {
return setError(EGL_BAD_PARAMETER, EGL_FALSE);
}
return EGL_CONDITION_SATISFIED_KHR;
}
EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync,
EGLint attribute, EGLint *value)
{
if (sync != FENCE_SYNC_HANDLE) {
return setError(EGL_BAD_PARAMETER, EGL_FALSE);
}
switch (attribute) {
case EGL_SYNC_TYPE_KHR:
*value = EGL_SYNC_FENCE_KHR;
return EGL_TRUE;
case EGL_SYNC_STATUS_KHR:
*value = EGL_SIGNALED_KHR;
return EGL_TRUE;
case EGL_SYNC_CONDITION_KHR:
*value = EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR;
return EGL_TRUE;
default:
return setError(EGL_BAD_ATTRIBUTE, EGL_FALSE);
}
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// ANDROID extensions // ANDROID extensions
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -47,6 +47,7 @@ static char const * const gExtensionsString =
// "GL_OES_point_size_array " // TODO // "GL_OES_point_size_array " // TODO
// "GL_OES_point_sprite " // TODO // "GL_OES_point_sprite " // TODO
"GL_OES_EGL_image " // OK "GL_OES_EGL_image " // OK
"GL_OES_EGL_sync " // OK
#ifdef GL_OES_compressed_ETC1_RGB8_texture #ifdef GL_OES_compressed_ETC1_RGB8_texture
"GL_OES_compressed_ETC1_RGB8_texture " // OK "GL_OES_compressed_ETC1_RGB8_texture " // OK
#endif #endif