diff options
Diffstat (limited to 'src/egl/main/eglscreen.c')
-rw-r--r-- | src/egl/main/eglscreen.c | 161 |
1 files changed, 46 insertions, 115 deletions
diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c index 9e39335cc7a..3abe85ff22f 100644 --- a/src/egl/main/eglscreen.c +++ b/src/egl/main/eglscreen.c @@ -18,7 +18,6 @@ #include "egldisplay.h" #include "eglcurrent.h" #include "eglmode.h" -#include "eglconfig.h" #include "eglsurface.h" #include "eglscreen.h" #include "eglmutex.h" @@ -42,7 +41,8 @@ _eglAllocScreenHandle(void) EGLScreenMESA s; _eglLockMutex(&_eglNextScreenHandleMutex); - s = _eglNextScreenHandle++; + s = _eglNextScreenHandle; + _eglNextScreenHandle += _EGL_SCREEN_MAX_MODES; _eglUnlockMutex(&_eglNextScreenHandleMutex); return s; @@ -53,60 +53,80 @@ _eglAllocScreenHandle(void) * Initialize an _EGLScreen object to default values. */ void -_eglInitScreen(_EGLScreen *screen) +_eglInitScreen(_EGLScreen *screen, _EGLDisplay *dpy, EGLint num_modes) { memset(screen, 0, sizeof(_EGLScreen)); + + screen->Display = dpy; + screen->NumModes = num_modes; screen->StepX = 1; screen->StepY = 1; + + if (num_modes > _EGL_SCREEN_MAX_MODES) + num_modes = _EGL_SCREEN_MAX_MODES; + screen->Modes = (_EGLMode *) calloc(num_modes, sizeof(*screen->Modes)); + screen->NumModes = (screen->Modes) ? num_modes : 0; } /** - * 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. */ -_EGLScreen * -_eglLookupScreen(EGLScreenMESA screen, _EGLDisplay *display) +EGLScreenMESA +_eglLinkScreen(_EGLScreen *screen) { + _EGLDisplay *display; EGLint i; - if (!display || !display->Screens) - return NULL; + assert(screen && screen->Display); + display = screen->Display; - for (i = 0; i < display->Screens->Size; i++) { - _EGLScreen *scr = (_EGLScreen *) display->Screens->Elements[i]; - if (scr->Handle == screen) - return scr; + if (!display->Screens) { + display->Screens = _eglCreateArray("Screen", 4); + if (!display->Screens) + return (EGLScreenMESA) 0; } - return NULL; + + screen->Handle = _eglAllocScreenHandle(); + for (i = 0; i < screen->NumModes; i++) + screen->Modes[i].Handle = screen->Handle + i; + + _eglAppendArray(display->Screens, (void *) screen); + + return screen->Handle; } /** - * Add the given _EGLScreen to the display's list of screens. + * Lookup a handle to find the linked config. + * Return NULL if the handle has no corresponding linked config. */ -void -_eglAddScreen(_EGLDisplay *display, _EGLScreen *screen) +_EGLScreen * +_eglLookupScreen(EGLScreenMESA screen, _EGLDisplay *display) { - assert(display); - assert(screen); + EGLint i; - if (!display->Screens) { - display->Screens = _eglCreateArray("Screen", 4); - if (!display->Screens) - return; + if (!display || !display->Screens) + return NULL; + + for (i = 0; i < display->Screens->Size; i++) { + _EGLScreen *scr = (_EGLScreen *) display->Screens->Elements[i]; + if (scr->Handle == screen) { + assert(scr->Display == display); + return scr; + } } - screen->Handle = _eglAllocScreenHandle(); - _eglAppendArray(display->Screens, (void *) screen); + return NULL; } - static EGLBoolean _eglFlattenScreen(void *elem, void *buffer) { _EGLScreen *scr = (_EGLScreen *) elem; EGLScreenMESA *handle = (EGLScreenMESA *) buffer; - *handle = scr->Handle; + *handle = _eglGetScreenHandle(scr); return EGL_TRUE; } @@ -123,66 +143,6 @@ _eglGetScreensMESA(_EGLDriver *drv, _EGLDisplay *display, EGLScreenMESA *screens /** - * Drivers should do a proper implementation. - */ -_EGLSurface * -_eglCreateScreenSurfaceMESA(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf, - const EGLint *attrib_list) -{ - return NULL; -} - - -/** - * Show the given surface on the named screen. - * If surface is EGL_NO_SURFACE, disable the screen's output. - * - * This is just a placeholder function; drivers will always override - * this with code that _really_ shows the surface. - */ -EGLBoolean -_eglShowScreenSurfaceMESA(_EGLDriver *drv, _EGLDisplay *dpy, - _EGLScreen *scrn, _EGLSurface *surf, - _EGLMode *mode) -{ - if (!surf) { - scrn->CurrentSurface = NULL; - } - else { - if (surf->Type != EGL_SCREEN_BIT_MESA) { - _eglError(EGL_BAD_SURFACE, "eglShowSurfaceMESA"); - return EGL_FALSE; - } - if (surf->Width < mode->Width || surf->Height < mode->Height) { - _eglError(EGL_BAD_SURFACE, - "eglShowSurfaceMESA(surface smaller than screen size)"); - return EGL_FALSE; - } - - scrn->CurrentSurface = surf; - scrn->CurrentMode = mode; - } - 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. */ EGLBoolean @@ -242,33 +202,4 @@ _eglQueryScreenMESA(_EGLDriver *drv, _EGLDisplay *dpy, _EGLScreen *scrn, } -/** - * 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 */ |