From e32ac5b8a963202dcdfb91354f77979765083000 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Sat, 23 Oct 2010 02:52:14 +0800 Subject: 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. --- src/egl/main/eglmode.c | 58 +++++++++++--------------------------------------- 1 file changed, 13 insertions(+), 45 deletions(-) (limited to 'src/egl/main/eglmode.c') diff --git a/src/egl/main/eglmode.c b/src/egl/main/eglmode.c index ed107d5d7a7..29d7964386e 100644 --- a/src/egl/main/eglmode.c +++ b/src/egl/main/eglmode.c @@ -31,56 +31,24 @@ _eglLookupMode(EGLModeMESA mode, _EGLDisplay *disp) /* loop over all screens on the display */ for (scrnum = 0; scrnum < disp->Screens->Size; scrnum++) { const _EGLScreen *scrn = disp->Screens->Elements[scrnum]; - EGLint i; - /* search list of modes for handle */ - for (i = 0; i < scrn->NumModes; i++) { - if (scrn->Modes[i].Handle == mode) { - return scrn->Modes + i; - } - } - } + EGLint idx; - return NULL; -} + /* + * the mode ids of a screen ranges from scrn->Handle to scrn->Handle + + * scrn->NumModes + */ + if (mode >= scrn->Handle && + mode < scrn->Handle + _EGL_SCREEN_MAX_MODES) { + idx = mode - scrn->Handle; + assert(idx < scrn->NumModes && scrn->Modes[idx].Handle == mode); -/** - * Add a new mode with the given attributes (width, height, depth, refreshRate) - * to the given screen. - * Assign a new mode ID/handle to the mode as well. - * \return pointer to the new _EGLMode - */ -_EGLMode * -_eglAddNewMode(_EGLScreen *screen, EGLint width, EGLint height, - EGLint refreshRate, const char *name) -{ - EGLint n; - _EGLMode *newModes; - - assert(screen); - assert(width > 0); - assert(height > 0); - assert(refreshRate > 0); - - n = screen->NumModes; - newModes = (_EGLMode *) realloc(screen->Modes, (n+1) * sizeof(_EGLMode)); - if (newModes) { - screen->Modes = newModes; - screen->Modes[n].Handle = n + 1; - screen->Modes[n].Width = width; - screen->Modes[n].Height = height; - screen->Modes[n].RefreshRate = refreshRate; - screen->Modes[n].Optimal = EGL_FALSE; - screen->Modes[n].Interlaced = EGL_FALSE; - screen->Modes[n].Name = _eglstrdup(name); - screen->NumModes++; - return screen->Modes + n; - } - else { - return NULL; + return &scrn->Modes[idx]; + } } -} + return NULL; +} /** -- cgit v1.2.3 From 1b92eb1a4b73c647ab42ac97809466bba8720d7b Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Wed, 27 Oct 2010 09:51:11 -0700 Subject: egl: Remove unnecessary headers. --- src/egl/main/eglimage.c | 1 - src/egl/main/eglmode.c | 2 -- src/egl/main/eglscreen.c | 1 - 3 files changed, 4 deletions(-) (limited to 'src/egl/main/eglmode.c') diff --git a/src/egl/main/eglimage.c b/src/egl/main/eglimage.c index 9625d2ae84b..6d4ee4e08b9 100644 --- a/src/egl/main/eglimage.c +++ b/src/egl/main/eglimage.c @@ -2,7 +2,6 @@ #include #include "eglimage.h" -#include "eglcurrent.h" #include "egllog.h" diff --git a/src/egl/main/eglmode.c b/src/egl/main/eglmode.c index 29d7964386e..a9653496c32 100644 --- a/src/egl/main/eglmode.c +++ b/src/egl/main/eglmode.c @@ -3,11 +3,9 @@ #include #include "egldisplay.h" -#include "egldriver.h" #include "eglmode.h" #include "eglcurrent.h" #include "eglscreen.h" -#include "eglstring.h" #ifdef EGL_MESA_screen_surface diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c index fc3ab322ab0..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" -- cgit v1.2.3