summaryrefslogtreecommitdiffstats
path: root/src/egl/main/eglmode.c
diff options
context:
space:
mode:
authorChristian König <[email protected]>2010-10-28 20:24:56 +0200
committerChristian König <[email protected]>2010-10-28 20:24:56 +0200
commit41ed47d6b8fb6c032e2907ef2e49e414c26f35c1 (patch)
tree8cf267ee3ac5d8b530dd70a28a0d568344aa8304 /src/egl/main/eglmode.c
parent97a7cf230a70c64fff300931ae7c00aa00449c97 (diff)
parent5479fa34d9acebd55f68c23a278cf382d0e84248 (diff)
Merge branch 'master' of ssh://git.freedesktop.org/git/mesa/mesa into pipe-video
Conflicts: src/gallium/include/pipe/p_format.h
Diffstat (limited to 'src/egl/main/eglmode.c')
-rw-r--r--src/egl/main/eglmode.c60
1 files changed, 13 insertions, 47 deletions
diff --git a/src/egl/main/eglmode.c b/src/egl/main/eglmode.c
index ed107d5d7a7..a9653496c32 100644
--- a/src/egl/main/eglmode.c
+++ b/src/egl/main/eglmode.c
@@ -3,11 +3,9 @@
#include <string.h>
#include "egldisplay.h"
-#include "egldriver.h"
#include "eglmode.h"
#include "eglcurrent.h"
#include "eglscreen.h"
-#include "eglstring.h"
#ifdef EGL_MESA_screen_surface
@@ -31,56 +29,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;
+}
/**