diff options
author | Chia-I Wu <[email protected]> | 2010-10-23 02:52:14 +0800 |
---|---|---|
committer | Chia-I Wu <[email protected]> | 2010-10-23 11:20:41 +0800 |
commit | e32ac5b8a963202dcdfb91354f77979765083000 (patch) | |
tree | 4814ea72fe3cda7306a88922f5ffe1810d4811b2 /src/egl/main/eglscreen.c | |
parent | 37213ceacc2d7b309de7641da501282f8f24c8c2 (diff) |
egl: Fix _eglModeLookup.
Internally a mode belongs to a screen. But functions like
eglGetModeAttribMESA treat a mode as a display resource: a mode can be
looked up without a screen. Considering how KMS works, it is better to
stick to the current implementation.
To properly support looking up a mode without a screen, this commit
assigns each mode (of all screens) a unique ID.
Diffstat (limited to 'src/egl/main/eglscreen.c')
-rw-r--r-- | src/egl/main/eglscreen.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c index 0bbead84769..fc3ab322ab0 100644 --- a/src/egl/main/eglscreen.c +++ b/src/egl/main/eglscreen.c @@ -42,7 +42,8 @@ _eglAllocScreenHandle(void) EGLScreenMESA s; _eglLockMutex(&_eglNextScreenHandleMutex); - s = _eglNextScreenHandle++; + s = _eglNextScreenHandle; + _eglNextScreenHandle += _EGL_SCREEN_MAX_MODES; _eglUnlockMutex(&_eglNextScreenHandleMutex); return s; @@ -53,12 +54,19 @@ _eglAllocScreenHandle(void) * Initialize an _EGLScreen object to default values. */ void -_eglInitScreen(_EGLScreen *screen, _EGLDisplay *dpy) +_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; } @@ -70,6 +78,7 @@ EGLScreenMESA _eglLinkScreen(_EGLScreen *screen) { _EGLDisplay *display; + EGLint i; assert(screen && screen->Display); display = screen->Display; @@ -79,7 +88,11 @@ _eglLinkScreen(_EGLScreen *screen) if (!display->Screens) return (EGLScreenMESA) 0; } + 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; |