* Initialize an _EGLScreen object to default values.
*/
void
-_eglInitScreen(_EGLScreen *screen)
+_eglInitScreen(_EGLScreen *screen, _EGLDisplay *dpy)
{
memset(screen, 0, sizeof(_EGLScreen));
+ screen->Display = dpy;
screen->StepX = 1;
screen->StepY = 1;
}
/**
- * Given a public screen handle, return the internal _EGLScreen object.
+ * Link a screen to its display and return the handle of the link.
+ * The handle can be passed to client directly.
+ */
+EGLScreenMESA
+_eglLinkScreen(_EGLScreen *screen)
+{
+ _EGLDisplay *display;
+
+ assert(screen && screen->Display);
+ display = screen->Display;
+
+ if (!display->Screens) {
+ display->Screens = _eglCreateArray("Screen", 4);
+ if (!display->Screens)
+ return (EGLScreenMESA) 0;
+ }
+ screen->Handle = _eglAllocScreenHandle();
+ _eglAppendArray(display->Screens, (void *) screen);
+
+ return screen->Handle;
+}
+
+
+/**
+ * Lookup a handle to find the linked config.
+ * Return NULL if the handle has no corresponding linked config.
*/
_EGLScreen *
_eglLookupScreen(EGLScreenMESA screen, _EGLDisplay *display)
for (i = 0; i < display->Screens->Size; i++) {
_EGLScreen *scr = (_EGLScreen *) display->Screens->Elements[i];
- if (scr->Handle == screen)
+ if (scr->Handle == screen) {
+ assert(scr->Display == display);
return scr;
+ }
}
return NULL;
}
-/**
- * Add the given _EGLScreen to the display's list of screens.
- */
-void
-_eglAddScreen(_EGLDisplay *display, _EGLScreen *screen)
-{
- assert(display);
- assert(screen);
-
- if (!display->Screens) {
- display->Screens = _eglCreateArray("Screen", 4);
- if (!display->Screens)
- return;
- }
- screen->Handle = _eglAllocScreenHandle();
- _eglAppendArray(display->Screens, (void *) screen);
-}
-
-
-
static EGLBoolean
_eglFlattenScreen(void *elem, void *buffer)
{
_EGLScreen *scr = (_EGLScreen *) elem;
EGLScreenMESA *handle = (EGLScreenMESA *) buffer;
- *handle = scr->Handle;
+ *handle = _eglGetScreenHandle(scr);
return EGL_TRUE;
}
}
-/**
- * Set a screen's current display mode.
- * Note: mode = EGL_NO_MODE is valid (turns off the screen)
- *
- * This is just a placeholder function; drivers will always override
- * this with code that _really_ sets the mode.
- */
-EGLBoolean
-_eglScreenModeMESA(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *scrn,
- _EGLMode *m)
-{
- scrn->CurrentMode = m;
- return EGL_TRUE;
-}
-
-
/**
* Set a screen's surface origin.
*/
}
-/**
- * Delete the modes associated with given screen.
- */
-void
-_eglDestroyScreenModes(_EGLScreen *scrn)
-{
- 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;
-}
-
-
-/**
- * Default fallback routine - drivers should usually override this.
- */
-void
-_eglDestroyScreen(_EGLScreen *scrn)
-{
- _eglDestroyScreenModes(scrn);
- free(scrn);
-}
-
-
#endif /* EGL_MESA_screen_surface */
*/
struct _egl_screen
{
+ _EGLDisplay *Display;
+
EGLScreenMESA Handle; /* The public/opaque handle which names this object */
_EGLMode *CurrentMode;
PUBLIC void
-_eglInitScreen(_EGLScreen *screen);
+_eglInitScreen(_EGLScreen *screen, _EGLDisplay *dpy);
+
+
+PUBLIC EGLScreenMESA
+_eglLinkScreen(_EGLScreen *screen);
extern _EGLScreen *
_eglLookupScreen(EGLScreenMESA screen, _EGLDisplay *dpy);
-PUBLIC void
-_eglAddScreen(_EGLDisplay *display, _EGLScreen *screen);
+/**
+ * Return the handle of a linked screen.
+ */
+static INLINE EGLScreenMESA
+_eglGetScreenHandle(_EGLScreen *screen)
+{
+ return (screen) ? screen->Handle : (EGLScreenMESA) 0;
+}
extern EGLBoolean
_eglGetScreensMESA(_EGLDriver *drv, _EGLDisplay *dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens);
-extern EGLBoolean
-_eglScreenModeMESA(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *scrn, _EGLMode *m);
-
-
extern EGLBoolean
_eglScreenPositionMESA(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *scrn, EGLint x, EGLint y);
-extern EGLBoolean
-_eglQueryDisplayMESA(_EGLDriver *drv, _EGLDisplay *dpy, EGLint attribute, EGLint *value);
-
-
extern EGLBoolean
_eglQueryScreenSurfaceMESA(_EGLDriver *drv, _EGLDisplay *dpy,
_EGLScreen *scrn, _EGLSurface **surface);
_eglQueryScreenMESA(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *scrn, EGLint attribute, EGLint *value);
-extern void
-_eglDestroyScreenModes(_EGLScreen *scrn);
-
-
-PUBLIC void
-_eglDestroyScreen(_EGLScreen *scrn);
-
-
#endif /* EGL_MESA_screen_surface */