#include "eglscreen.h"
+/**
+ * Return a new screen handle/ID.
+ * NOTE: we never reuse these!
+ */
+EGLScreenMESA
+_eglAllocScreenHandle(void)
+{
+ EGLScreenMESA s = _eglGlobal.FreeScreenHandle;
+ _eglGlobal.FreeScreenHandle++;
+ return s;
+}
+
+
/**
* Initialize an _EGLScreen object to default values.
*/
void
_eglInitScreen(_EGLScreen *screen)
{
- /* just init to zero for now */
memset(screen, 0, sizeof(_EGLScreen));
+ screen->StepX = 1;
+ screen->StepY = 1;
}
/**
- * Initialize the given _EGLSurface object. Do error checking.
- * Assign it an EGLSurface handle and insert into hash table.
- * \return EGLSurface handle or EGL_NO_SURFACE if error.
+ * Example function - drivers should do a proper implementation.
*/
EGLSurface
-_eglInitScreenSurface(_EGLSurface *surf, _EGLDriver *drv, EGLDisplay dpy,
- EGLConfig config, const EGLint *attrib_list)
+_eglCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
+ const EGLint *attrib_list)
{
- EGLint width = 0, height = 0;
- EGLint i;
-
- for (i = 0; attrib_list && attrib_list[i] != EGL_NONE; i++) {
- switch (attrib_list[i]) {
- case EGL_WIDTH:
- width = attrib_list[++i];
- break;
- case EGL_HEIGHT:
- height = attrib_list[++i];
- break;
- default:
- _eglError(EGL_BAD_ATTRIBUTE, "eglCreateScreenSurfaceMESA");
- return EGL_NO_SURFACE;
- }
- }
+#if 0 /* THIS IS JUST EXAMPLE CODE */
+ _EGLSurface *surf;
+ _EGLConfig *conf;
- if (width <= 0 || height <= 0) {
- _eglError(EGL_BAD_ATTRIBUTE,
- "eglCreateScreenSurfaceMESA(width or height)");
+ conf = _eglLookupConfig(drv, dpy, config);
+ if (!conf) {
+ _eglError(EGL_BAD_CONFIG, "eglCreateScreenSurfaceMESA");
return EGL_NO_SURFACE;
}
- _eglInitSurface(surf);
- surf->Width = width;
- surf->Height = height;
- surf->Type = EGL_SCREEN_BIT_MESA;
- surf->Config = _eglLookupConfig(drv, dpy, config);
-
- /* insert into hash table */
- _eglSaveSurface(surf);
- assert(surf->Handle);
-
- return surf->Handle;
-}
-
+ surf = (_EGLSurface *) calloc(1, sizeof(_EGLSurface));
+ if (!surf)
+ return EGL_NO_SURFACE;
-/**
- * Create a drawing surface which can be directly displayed on a screen.
- */
-EGLSurface
-_eglCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
- const EGLint *attrib_list)
-{
- _EGLSurface *surf;
- EGLSurface surface;
-
- surf = (_EGLSurface *) malloc(sizeof(_EGLSurface));
- surface = _eglInitScreenSurface(surf, drv, dpy, config, attrib_list);
- if (surface == EGL_NO_SURFACE)
+ if (!_eglInitSurface(drv, surf, EGL_SCREEN_BIT_MESA,
+ conf, attrib_list)) {
free(surf);
+ return EGL_NO_SURFACE;
+ }
- return surface;
+ return _eglLinkSurface(surf, _eglLookupDisplay(dpy));
+#endif
+ return EGL_NO_SURFACE;
}
* this with code that _really_ shows the surface.
*/
EGLBoolean
-_eglShowSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
- EGLSurface surface, EGLModeMESA m)
+_eglShowScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy,
+ EGLScreenMESA screen, EGLSurface surface,
+ EGLModeMESA m)
{
_EGLScreen *scrn = _eglLookupScreen(dpy, screen);
_EGLMode *mode = _eglLookupMode(dpy, m);
if (surface == EGL_NO_SURFACE) {
scrn->CurrentSurface = NULL;
- } else {
+ }
+ else {
_EGLSurface *surf = _eglLookupSurface(surface);
if (!surf || surf->Type != EGL_SCREEN_BIT_MESA) {
_eglError(EGL_BAD_SURFACE, "eglShowSurfaceMESA");
value[0] = scrn->OriginX;
value[1] = scrn->OriginY;
break;
+ case EGL_SCREEN_POSITION_GRANULARITY_MESA:
+ value[0] = scrn->StepX;
+ value[1] = scrn->StepY;
+ break;
default:
_eglError(EGL_BAD_ATTRIBUTE, "eglQueryScreenMESA");
return EGL_FALSE;
}
+/**
+ * Delete the modes associated with given screen.
+ */
void
_eglDestroyScreenModes(_EGLScreen *scrn)
{
- free(scrn->Modes);
+ EGLint i;
+ for (i = 0; i < scrn->NumModes; i++) {
+ if (scrn->Modes[i].Name)
+ free((char *) scrn->Modes[i].Name); /* cast away const */
+ }
+ if (scrn->Modes)
+ free(scrn->Modes);
+ scrn->Modes = NULL;
+ scrn->NumModes = 0;
}