#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include "eglcontext.h"
#include "egldisplay.h"
{ "eglWaitGL", (_EGLProc) eglWaitGL },
{ "eglWaitNative", (_EGLProc) eglWaitNative },
/* Extensions */
+#ifdef EGL_MESA_screen_surface
{ "eglChooseModeMESA", (_EGLProc) eglChooseModeMESA },
{ "eglGetModesMESA", (_EGLProc) eglGetModesMESA },
{ "eglGetModeAttribMESA", (_EGLProc) eglGetModeAttribMESA },
{ "eglQueryScreenSurfaceMESA", (_EGLProc) eglQueryScreenSurfaceMESA },
{ "eglQueryScreenModeMESA", (_EGLProc) eglQueryScreenModeMESA },
{ "eglQueryModeStringMESA", (_EGLProc) eglQueryModeStringMESA },
+#endif /* EGL_MESA_screen_surface */
+#ifdef EGL_VERSION_1_2
+ { "eglBindAPI", (_EGLProc) eglBindAPI },
+ { "eglCreatePbufferFromClientBuffer", (_EGLProc) eglCreatePbufferFromClientBuffer },
+ { "eglQueryAPI", (_EGLProc) eglQueryAPI },
+ { "eglReleaseThread", (_EGLProc) eglReleaseThread },
+ { "eglWaitClient", (_EGLProc) eglWaitClient },
+#endif /* EGL_VERSION_1_2 */
{ NULL, NULL }
};
EGLint i;
}
+/**
+ ** EGL 1.2
+ **/
+
+#ifdef EGL_VERSION_1_2
+
+EGLBoolean
+eglBindAPI(EGLenum api)
+{
+ _EGLThreadInfo *t = _eglGetCurrentThread();
+
+ switch (api) {
+ case EGL_OPENGL_ES_API:
+ if (_eglGlobal.OpenGLESAPISupported) {
+ t->CurrentAPI = api;
+ return EGL_TRUE;
+ }
+ _eglError(EGL_BAD_PARAMETER, "eglBindAPI");
+ return EGL_FALSE;
+ case EGL_OPENVG_API:
+ if (_eglGlobal.OpenVGAPISupported) {
+ t->CurrentAPI = api;
+ return EGL_TRUE;
+ }
+ _eglError(EGL_BAD_PARAMETER, "eglBindAPI");
+ return EGL_FALSE;
+ default:
+ return EGL_FALSE;
+ }
+ return EGL_TRUE;
+}
+
+
+EGLSurface
+eglCreatePbufferFromClientBuffer(EGLDisplay dpy, EGLenum buftype,
+ EGLClientBuffer buffer, EGLConfig config,
+ const EGLint *attrib_list)
+{
+ _EGLDriver *drv = _eglLookupDriver(dpy);
+ return drv->API.CreatePbufferFromClientBuffer(drv, dpy, buftype, buffer,
+ config, attrib_list);
+}
+
+
+EGLenum
+eglQueryAPI(void)
+{
+ /* returns one of EGL_OPENGL_ES_API or EGL_OPENVG_API */
+ _EGLThreadInfo *t = _eglGetCurrentThread();
+ return t->CurrentAPI;
+}
+
+
+EGLBoolean
+eglReleaseThread(void)
+{
+ _EGLThreadInfo *t = _eglGetCurrentThread();
+ EGLDisplay dpy = eglGetCurrentDisplay();
+ if (dpy) {
+ _EGLDriver *drv = _eglLookupDriver(dpy);
+ /* unbind context */
+ (void) drv->API.MakeCurrent(drv, dpy, EGL_NO_SURFACE,
+ EGL_NO_SURFACE, EGL_NO_CONTEXT);
+ }
+ _eglDeleteThreadData(t);
+ return EGL_TRUE;
+}
+EGLBoolean
+eglWaitClient(void)
+{
+ EGLDisplay dpy = eglGetCurrentDisplay();
+ if (dpy != EGL_NO_DISPLAY) {
+ _EGLDriver *drv = _eglLookupDriver(dpy);
+ return drv->API.WaitClient(drv, dpy);
+ }
+ else
+ return EGL_FALSE;
+}
+#endif /* EGL_VERSION_1_2 */
typedef EGLBoolean (*WaitNative_t)(_EGLDriver *drv, EGLDisplay dpy, EGLint engine);
-/* EGL_MESA_screen extension */
+#ifdef EGL_MESA_screen_surface
typedef EGLBoolean (*ChooseModeMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
typedef EGLBoolean (*GetModesMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint mode_size, EGLint *num_mode);
typedef EGLBoolean (*GetModeAttribMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint *value);
typedef EGLBoolean (*QueryScreenSurfaceMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLSurface *surface);
typedef EGLBoolean (*QueryScreenModeMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode);
typedef const char * (*QueryModeStringMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLModeMESA mode);
+#endif /* EGL_MESA_screen_surface */
+
+
+#ifdef EGL_VERSION_1_2
+typedef EGLBoolean (*WaitClient_t)(_EGLDriver *drv, EGLDisplay dpy);
+typedef EGLSurface (*CreatePbufferFromClientBuffer_t)(_EGLDriver *drv, EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint *attrib_list);
+#endif /* EGL_VERSION_1_2 */
+
/**
QueryScreenSurfaceMESA_t QueryScreenSurfaceMESA;
QueryScreenModeMESA_t QueryScreenModeMESA;
QueryModeStringMESA_t QueryModeStringMESA;
+
+#ifdef EGL_VERSION_1_2
+ WaitClient_t WaitClient;
+ CreatePbufferFromClientBuffer_t CreatePbufferFromClientBuffer;
+#endif
};
#endif /* EGLAPI_INCLUDED */
_eglSetConfigAttrib(config, EGL_TRANSPARENT_RED_VALUE, EGL_DONT_CARE);
_eglSetConfigAttrib(config, EGL_TRANSPARENT_GREEN_VALUE, EGL_DONT_CARE);
_eglSetConfigAttrib(config, EGL_TRANSPARENT_BLUE_VALUE, EGL_DONT_CARE);
+#ifdef EGL_VERSION_1_2
+ _eglSetConfigAttrib(config, EGL_COLOR_BUFFER_TYPE, EGL_RGB_BUFFER);
+ _eglSetConfigAttrib(config, EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT);
+#endif /* EGL_VERSION_1_2 */
}
}
for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) {
- if (attrib_list[i] >= EGL_BUFFER_SIZE &&
- attrib_list[i] <= EGL_MAX_SWAP_INTERVAL) {
- EGLint k = attrib_list[i] - FIRST_ATTRIB;
+ const EGLint attr = attrib_list[i];
+ if (attr >= EGL_BUFFER_SIZE &&
+ attr <= EGL_MAX_SWAP_INTERVAL) {
+ EGLint k = attr - FIRST_ATTRIB;
assert(k >= 0);
assert(k < MAX_ATTRIBS);
config->Attrib[k] = attrib_list[++i];
}
+#ifdef EGL_VERSION_1_2
+ else if (attr == EGL_COLOR_BUFFER_TYPE) {
+ EGLint bufType = attrib_list[++i];
+ if (bufType != EGL_RGB_BUFFER && bufType != EGL_LUMINANCE_BUFFER) {
+ _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
+ return EGL_FALSE;
+ }
+ _eglSetConfigAttrib(config, EGL_COLOR_BUFFER_TYPE, bufType);
+ }
+ else if (attr == EGL_RENDERABLE_TYPE) {
+ EGLint renType = attrib_list[++i];
+ if (renType & ~(EGL_OPENGL_ES_BIT | EGL_OPENVG_BIT)) {
+ _eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
+ return EGL_FALSE;
+ }
+ _eglSetConfigAttrib(config, EGL_RENDERABLE_TYPE, renType);
+ }
+ else if (attr == EGL_ALPHA_MASK_SIZE ||
+ attr == EGL_LUMINANCE_SIZE) {
+ EGLint value = attrib_list[++i];
+ _eglSetConfigAttrib(config, attr, value);
+ }
+#endif /* EGL_VERSION_1_2 */
else {
_eglError(EGL_BAD_ATTRIBUTE, "eglChooseConfig");
return EGL_FALSE;
/* This encodes the info from Table 3.5 of the EGL spec, ordered by
* Sort Priority.
+ *
+ * XXX To do: EGL 1.2 attribs
*/
static struct sort_info SortInfo[] = {
{ EGL_CONFIG_CAVEAT, EXACT, SPECIAL },
case EGL_CONFIG_ID:
*value = GET_CONFIG_ATTRIB(c->Config, EGL_CONFIG_ID);
return EGL_TRUE;
+#ifdef EGL_VERSION_1_2
+ case EGL_CONTEXT_CLIENT_TYPE:
+ *value = c->ClientAPI;
+ return EGL_FALSE;
+#endif /* EGL_VERSION_1_2 */
default:
_eglError(EGL_BAD_ATTRIBUTE, "eglQueryContext");
return EGL_FALSE;
EGLBoolean IsBound;
EGLBoolean DeletePending;
+#ifdef EGL_VERSION_1_2
+ EGLint ClientAPI; /* Either EGL_OPENGL_ES_API or EGL_OPENVG_API */
+#endif /* EGL_VERSION_1_2 */
};
drv->API.WaitGL = _eglWaitGL;
drv->API.WaitNative = _eglWaitNative;
- /* EGL_MESA_screen */
+#ifdef EGL_MESA_screen_surface
drv->API.ChooseModeMESA = _eglChooseModeMESA;
drv->API.GetModesMESA = _eglGetModesMESA;
drv->API.GetModeAttribMESA = _eglGetModeAttribMESA;
drv->API.QueryScreenSurfaceMESA = _eglQueryScreenSurfaceMESA;
drv->API.QueryScreenModeMESA = _eglQueryScreenModeMESA;
drv->API.QueryModeStringMESA = _eglQueryModeStringMESA;
+#endif /* EGL_MESA_screen_surface */
+
+#ifdef EGL_VERSION_1_2
+ drv->API.CreatePbufferFromClientBuffer = _eglCreatePbufferFromClientBuffer;
+#endif /* EGL_VERSION_1_2 */
}
case EGL_EXTENSIONS:
_eglUpdateExtensionsString(drv);
return drv->Extensions.String;
+#ifdef EGL_VERSION_1_2
+ case EGL_CLIENT_APIS:
+ /* XXX need to initialize somewhere */
+ return drv->ClientAPIs;
+#endif
default:
_eglError(EGL_BAD_PARAMETER, "eglQueryString");
return NULL;
/* just a placeholder */
(void) drv;
(void) dpy;
- (void) engine;
+ switch (engine) {
+ case EGL_CORE_NATIVE_ENGINE:
+ break;
+ default:
+ _eglError(EGL_BAD_PARAMETER, "eglWaitNative(engine)");
+ return EGL_FALSE;
+ }
+
return EGL_TRUE;
}
int ABIversion;
int APImajor, APIminor; /* returned through eglInitialize */
+ const char *ClientAPIs;
_EGLAPI API;
#include <stdio.h>
+#include <stdlib.h>
#include "eglglobals.h"
_eglGlobal.Surfaces = _eglNewHashTable();
_eglGlobal.FreeScreenHandle = 1;
_eglGlobal.Initialized = EGL_TRUE;
+
+ _eglGlobal.OpenGLESAPISupported = EGL_TRUE;
+ _eglGlobal.OpenVGAPISupported = EGL_FALSE;
+
/* XXX temporary */
- _eglGlobal.ThreadInfo.CurrentContext = EGL_NO_CONTEXT;
- _eglGlobal.ThreadInfo.LastError = EGL_SUCCESS;
+ _eglGlobal.ThreadInfo = _eglNewThreadInfo();
}
}
}
+/**
+ * Allocate and init a new _EGLThreadInfo object.
+ */
+_EGLThreadInfo *
+_eglNewThreadInfo(void)
+{
+ _EGLThreadInfo *t = (_EGLThreadInfo *) calloc(1, sizeof(_EGLThreadInfo));
+ if (t) {
+ t->CurrentContext = EGL_NO_CONTEXT;
+ t->LastError = EGL_SUCCESS;
+ t->CurrentAPI = EGL_NONE;
+ }
+ return t;
+}
+
+
+/**
+ * Delete/free a _EGLThreadInfo object.
+ */
+void
+_eglDeleteThreadData(_EGLThreadInfo *t)
+{
+ free(t);
+}
+
+
+
/**
* Return pointer to calling thread's _EGLThreadInfo object.
* Create a new one if needed.
_EGLThreadInfo *
_eglGetCurrentThread(void)
{
+ _eglInitGlobals();
+
/* XXX temporary */
- return &_eglGlobal.ThreadInfo;
+ return _eglGlobal.ThreadInfo;
}
{
EGLint LastError;
_EGLContext *CurrentContext;
+ EGLenum CurrentAPI;
};
EGLScreenMESA FreeScreenHandle;
- /* XXX temporary */
- _EGLThreadInfo ThreadInfo;
+ /* XXX these may be temporary */
+ EGLBoolean OpenGLESAPISupported;
+ EGLBoolean OpenVGAPISupported;
+
+ /* XXX temporary - should be thread-specific data (TSD) */
+ _EGLThreadInfo *ThreadInfo;
};
_eglDestroyGlobals(void);
+extern _EGLThreadInfo *
+_eglNewThreadInfo(void);
+
+
+extern void
+_eglDeleteThreadData(_EGLThreadInfo *t);
+
+
extern _EGLThreadInfo *
_eglGetCurrentThread(void);
_EGLConfig *conf;
EGLint width = 0, height = 0, largest = 0;
EGLint texFormat = 0, texTarget = 0, mipmapTex = 0;
+ EGLint renderBuffer = EGL_BACK_BUFFER;
+#ifdef EGL_VERSION_1_2
+ EGLint colorspace = EGL_COLORSPACE_sRGB;
+ EGLint alphaFormat = EGL_ALPHA_FORMAT_NONPRE;
+#endif
EGLint i;
switch (type) {
break;
case EGL_PIXMAP_BIT:
func = "eglCreatePixmapSurface";
+ renderBuffer = EGL_SINGLE_BUFFER;
break;
case EGL_PBUFFER_BIT:
func = "eglCreatePBufferSurface";
break;
case EGL_SCREEN_BIT_MESA:
func = "eglCreateScreenSurface";
+ renderBuffer = EGL_SINGLE_BUFFER; /* XXX correct? */
break;
default:
_eglLog(_EGL_WARNING, "Bad type in _eglInitSurface");
return EGL_FALSE;
}
break;
+#ifdef EGL_VERSION_1_2
+ case EGL_RENDER_BUFFER:
+ if (type == EGL_WINDOW_BIT) {
+ renderBuffer = attrib_list[++i];
+ if (renderBuffer != EGL_BACK_BUFFER &&
+ renderBuffer != EGL_SINGLE_BUFFER) {
+ _eglError(EGL_BAD_ATTRIBUTE, func);
+ return EGL_FALSE;
+ }
+ }
+ else {
+ _eglError(EGL_BAD_ATTRIBUTE, func);
+ return EGL_FALSE;
+ }
+ break;
+ case EGL_COLORSPACE:
+ if (type == EGL_WINDOW_BIT ||
+ type == EGL_PBUFFER_BIT ||
+ type == EGL_PIXMAP_BIT) {
+ colorspace = attrib_list[++i];
+ if (colorspace != EGL_COLORSPACE_sRGB &&
+ colorspace != EGL_COLORSPACE_LINEAR) {
+ _eglError(EGL_BAD_ATTRIBUTE, func);
+ return EGL_FALSE;
+ }
+ }
+ else {
+ _eglError(EGL_BAD_ATTRIBUTE, func);
+ return EGL_FALSE;
+ }
+ break;
+ case EGL_ALPHA_FORMAT:
+ if (type == EGL_WINDOW_BIT ||
+ type == EGL_PBUFFER_BIT ||
+ type == EGL_PIXMAP_BIT) {
+ alphaFormat = attrib_list[++i];
+ if (alphaFormat != EGL_ALPHA_FORMAT_NONPRE &&
+ alphaFormat != EGL_ALPHA_FORMAT_PRE) {
+ _eglError(EGL_BAD_ATTRIBUTE, func);
+ return EGL_FALSE;
+ }
+ }
+ else {
+ _eglError(EGL_BAD_ATTRIBUTE, func);
+ return EGL_FALSE;
+ }
+ break;
+
+#endif /* EGL_VERSION_1_2 */
default:
_eglError(EGL_BAD_ATTRIBUTE, func);
return EGL_FALSE;
surf->MipmapTexture = mipmapTex;
surf->MipmapLevel = 0;
surf->SwapInterval = 0;
+#ifdef EGL_VERSION_1_2
+ surf->SwapBehavior = EGL_BUFFER_DESTROYED; /* XXX ok? */
+ surf->HorizontalResolution = EGL_UNKNOWN; /* set by caller */
+ surf->VerticalResolution = EGL_UNKNOWN; /* set by caller */
+ surf->AspectRatio = EGL_UNKNOWN; /* set by caller */
+ surf->RenderBuffer = renderBuffer;
+ surf->AlphaFormat = alphaFormat;
+ surf->Colorspace = colorspace;
+#endif
return EGL_TRUE;
}
case EGL_CONFIG_ID:
*value = GET_CONFIG_ATTRIB(surface->Config, EGL_CONFIG_ID);
return EGL_TRUE;
+ /*XXX case EGL_LARGEST_PBUFFER:*/
+ case EGL_SURFACE_TYPE:
+ *value = surface->Type;
+ return EGL_TRUE;
+#ifdef EGL_VERSION_1_1
case EGL_TEXTURE_FORMAT:
/* texture attributes: only for pbuffers, no error otherwise */
if (surface->Type == EGL_PBUFFER_BIT)
if (surface->Type == EGL_PBUFFER_BIT)
*value = surface->MipmapLevel;
return EGL_TRUE;
- case EGL_SURFACE_TYPE:
- *value = surface->Type;
+#endif /* EGL_VERSION_1_1 */
+#ifdef EGL_VERSION_1_2
+ case EGL_SWAP_BEHAVIOR:
+ *value = surface->SwapBehavior;
+ return EGL_TRUE;
+ case EGL_RENDER_BUFFER:
+ *value = surface->RenderBuffer;
+ return EGL_TRUE;
+ case EGL_PIXEL_ASPECT_RATIO:
+ *value = surface->AspectRatio;
+ return EGL_TRUE;
+ case EGL_HORIZONTAL_RESOLUTION:
+ *value = surface->HorizontalResolution;
return EGL_TRUE;
+ case EGL_VERTICAL_RESOLUTION:
+ *value = surface->VerticalResolution;
+ return EGL_TRUE;
+ case EGL_ALPHA_FORMAT:
+ *value = surface->AlphaFormat;
+ return EGL_TRUE;
+ case EGL_COLORSPACE:
+ *value = surface->Colorspace;
+ return EGL_TRUE;
+#endif /* EGL_VERSION_1_2 */
default:
_eglError(EGL_BAD_ATTRIBUTE, "eglQuerySurface");
return EGL_FALSE;
surf->SwapInterval = interval;
return EGL_TRUE;
}
+
+
+#ifdef EGL_VERSION_1_2
+
+/**
+ * Example function - drivers should do a proper implementation.
+ */
+EGLSurface
+_eglCreatePbufferFromClientBuffer(_EGLDriver *drv, EGLDisplay dpy,
+ EGLenum buftype, EGLClientBuffer buffer,
+ EGLConfig config, const EGLint *attrib_list)
+{
+ if (buftype != EGL_OPENVG_IMAGE) {
+ _eglError(EGL_BAD_PARAMETER, "eglCreatePbufferFromClientBuffer");
+ return ELG_NO_SURFACE;
+ }
+
+ return EGL_NO_SURFACE;
+}
+
+#endif /* EGL_VERSION_1_2 */
/* If type == EGL_SCREEN_BIT: */
EGLint VisibleRefCount; /* number of screens I'm displayed on */
+
+#ifdef EGL_VERSION_1_2
+ EGLint SwapBehavior; /* one of EGL_BUFFER_PRESERVED/DESTROYED */
+ EGLint HorizontalResolution, VerticalResolution;
+ EGLint AspectRatio;
+ EGLint RenderBuffer; /* EGL_BACK_BUFFER or EGL_SINGLE_BUFFER */
+ EGLint AlphaFormat; /* EGL_ALPHA_FORMAT_NONPRE or EGL_ALPHA_FORMAT_PRE */
+ EGLint Colorspace; /* EGL_COLORSPACE_sRGB or EGL_COLORSPACE_LINEAR */
+#endif /* EGL_VERSION_1_2 */
};
_eglSwapInterval(_EGLDriver *drv, EGLDisplay dpy, EGLint interval);
+#ifdef EGL_VERSION_1_2
+
+extern EGLSurface
+_eglCreatePbufferFromClientBuffer(_EGLDriver *drv, EGLDisplay dpy,
+ EGLenum buftype, EGLClientBuffer buffer,
+ EGLConfig config, const EGLint *attrib_list);
+
+#endif /* EGL_VERSION_1_2 */
+
+
+
#endif /* EGLSURFACE_INCLUDED */