summaryrefslogtreecommitdiffstats
path: root/src/egl/main/eglmode.c
diff options
context:
space:
mode:
authorBrian Paul <[email protected]>2005-05-04 03:33:21 +0000
committerBrian Paul <[email protected]>2005-05-04 03:33:21 +0000
commitc22990c29a5cdff89e6e3914aa565acc88a6a407 (patch)
tree5f8d766790274560d6e5be12c75877480beb798d /src/egl/main/eglmode.c
parent3aeae2068510a369ba5c90ae1355d0b0ed89d5f5 (diff)
sync with latest EGL_MESA_screen_surface spec (EGLScreenMESA handles)
Diffstat (limited to 'src/egl/main/eglmode.c')
-rw-r--r--src/egl/main/eglmode.c56
1 files changed, 52 insertions, 4 deletions
diff --git a/src/egl/main/eglmode.c b/src/egl/main/eglmode.c
index 201ddb17f71..857fa380c6e 100644
--- a/src/egl/main/eglmode.c
+++ b/src/egl/main/eglmode.c
@@ -1,3 +1,5 @@
+#include <assert.h>
+#include <stdlib.h>
#include "egldisplay.h"
#include "egldriver.h"
#include "eglmode.h"
@@ -8,30 +10,76 @@
#define MIN2(A, B) (((A) < (B)) ? (A) : (B))
+/**
+ * Given an EGLModeMESA handle, return the corresponding _EGLMode object
+ * or null if non-existant.
+ */
_EGLMode *
_eglLookupMode(EGLDisplay dpy, EGLModeMESA mode)
{
const _EGLDisplay *disp = _eglLookupDisplay(dpy);
EGLint scrnum;
+ /* loop over all screens on the display */
for (scrnum = 0; scrnum < disp->NumScreens; scrnum++) {
- const _EGLScreen *scrn = disp->Screens + scrnum;
+ const _EGLScreen *scrn = disp->Screens[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;
}
}
}
+
return NULL;
}
/**
+ * 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 *
+_eglAddMode(_EGLScreen *screen, EGLint width, EGLint height,
+ EGLint depth, EGLint refreshRate)
+{
+ EGLint n;
+ _EGLMode *newModes;
+
+ assert(screen);
+ assert(width > 0);
+ assert(height > 0);
+ assert(depth > 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].Depth = depth;
+ screen->Modes[n].RefreshRate = refreshRate;
+ screen->Modes[n].Stereo = EGL_FALSE;
+ screen->NumModes++;
+ return screen->Modes + n;
+ }
+ else {
+ return NULL;
+ }
+}
+
+
+
+/**
* Search for the EGLMode that best matches the given attribute list.
*/
EGLBoolean
-_eglChooseModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
+_eglChooseModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
const EGLint *attrib_list, EGLModeMESA *modes,
EGLint modes_size, EGLint *num_modes)
{
@@ -70,10 +118,10 @@ _eglChooseModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
* Return all possible modes for the given screen
*/
EGLBoolean
-_eglGetModesMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
+_eglGetModesMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes)
{
- _EGLScreen *scrn = _eglLookupScreen(dpy, screen_number);
+ _EGLScreen *scrn = _eglLookupScreen(dpy, screen);
EGLint i;
if (!scrn) {