aboutsummaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/drivers/demo/demo.c63
-rw-r--r--src/egl/main/eglapi.c42
-rw-r--r--src/egl/main/eglconfig.c26
-rw-r--r--src/egl/main/eglconfig.h4
-rw-r--r--src/egl/main/egldisplay.h2
-rw-r--r--src/egl/main/egldriver.c9
-rw-r--r--src/egl/main/egldriver.h19
-rw-r--r--src/egl/main/eglglobals.c14
-rw-r--r--src/egl/main/eglglobals.h6
-rw-r--r--src/egl/main/eglmode.c56
-rw-r--r--src/egl/main/eglmode.h15
-rw-r--r--src/egl/main/eglscreen.c120
-rw-r--r--src/egl/main/eglscreen.h28
13 files changed, 285 insertions, 119 deletions
diff --git a/src/egl/drivers/demo/demo.c b/src/egl/drivers/demo/demo.c
index 041884b40a0..e5164d657f7 100644
--- a/src/egl/drivers/demo/demo.c
+++ b/src/egl/drivers/demo/demo.c
@@ -55,51 +55,34 @@ demoInitialize(_EGLDriver *drv, EGLDisplay dpy, EGLint *major, EGLint *minor)
_EGLScreen *scrn;
EGLint i;
- disp->NumScreens = 1;
- disp->Screens = (_EGLScreen *) calloc(disp->NumScreens, sizeof(_EGLScreen));
- scrn = disp->Screens + 0;
- scrn->NumModes = 4;
- scrn->Modes = (_EGLMode *) calloc(scrn->NumModes, sizeof(_EGLMode));
- scrn->Modes[0].Width = 1600;
- scrn->Modes[0].Height = 1200;
- scrn->Modes[0].Depth = 32;
- scrn->Modes[0].RefreshRate = 72 * 1000;
- scrn->Modes[1].Width = 1280;
- scrn->Modes[1].Height = 1024;
- scrn->Modes[1].Depth = 32;
- scrn->Modes[1].RefreshRate = 72 * 1000;
- scrn->Modes[2].Width = 1280;
- scrn->Modes[2].Height = 1024;
- scrn->Modes[2].Depth = 16;
- scrn->Modes[2].RefreshRate = 72 * 1000;
- scrn->Modes[3].Width = 1024;
- scrn->Modes[3].Height = 768;
- scrn->Modes[3].Depth = 16;
- scrn->Modes[3].RefreshRate = 72 * 1000;
- for (i = 0; i < scrn->NumModes; i++)
- scrn->Modes[i].Handle = i + 1;
-
- /* Create list of visual configs - this is a silly example */
- disp->NumConfigs = 4;
- disp->Configs = (_EGLConfig *) calloc(disp->NumConfigs, sizeof(_EGLConfig));
- for (i = 0; i < disp->NumConfigs; i++) {
- _EGLConfig *config = disp->Configs + i;
- _eglInitConfig(config, i + 1);
- SET_CONFIG_ATTRIB(config, EGL_RED_SIZE, 8);
- SET_CONFIG_ATTRIB(config, EGL_GREEN_SIZE, 8);
- SET_CONFIG_ATTRIB(config, EGL_BLUE_SIZE, 8);
- SET_CONFIG_ATTRIB(config, EGL_ALPHA_SIZE, 8);
- SET_CONFIG_ATTRIB(config, EGL_BUFFER_SIZE, 32);
-
+ /* Create a screen */
+ scrn = _eglNewScreen();
+ _eglAddScreen(disp, scrn);
+
+ /* Create the screen's modes - silly example */
+ _eglAddMode(scrn, 1600, 1200, 32, 72 * 1000);
+ _eglAddMode(scrn, 1280, 1024, 32, 72 * 1000);
+ _eglAddMode(scrn, 1280, 1024, 16, 72 * 1000);
+ _eglAddMode(scrn, 1024, 768, 32, 72 * 1000);
+
+ /* Create the display's visual configs - silly example */
+ for (i = 0; i < 4; i++) {
+ _EGLConfig config;
+ _eglInitConfig(&config, i + 1);
+ SET_CONFIG_ATTRIB(&config, EGL_RED_SIZE, 8);
+ SET_CONFIG_ATTRIB(&config, EGL_GREEN_SIZE, 8);
+ SET_CONFIG_ATTRIB(&config, EGL_BLUE_SIZE, 8);
+ SET_CONFIG_ATTRIB(&config, EGL_ALPHA_SIZE, 8);
+ SET_CONFIG_ATTRIB(&config, EGL_BUFFER_SIZE, 32);
if (i & 1) {
- SET_CONFIG_ATTRIB(config, EGL_DEPTH_SIZE, 32);
+ SET_CONFIG_ATTRIB(&config, EGL_DEPTH_SIZE, 32);
}
if (i & 2) {
- SET_CONFIG_ATTRIB(config, EGL_STENCIL_SIZE, 8);
+ SET_CONFIG_ATTRIB(&config, EGL_STENCIL_SIZE, 8);
}
-
- SET_CONFIG_ATTRIB(config, EGL_SURFACE_TYPE,
+ SET_CONFIG_ATTRIB(&config, EGL_SURFACE_TYPE,
(EGL_WINDOW_BIT | EGL_PIXMAP_BIT | EGL_PBUFFER_BIT));
+ _eglAddConfig(disp, &config);
}
drv->Initialized = EGL_TRUE;
diff --git a/src/egl/main/eglapi.c b/src/egl/main/eglapi.c
index d9c8845aa49..b0bd1eed6cf 100644
--- a/src/egl/main/eglapi.c
+++ b/src/egl/main/eglapi.c
@@ -370,24 +370,24 @@ void (* APIENTRY eglGetProcAddress(const char *procname))()
*/
EGLBoolean APIENTRY
-eglChooseModeMESA(EGLDisplay dpy, EGLint screen_number,
+eglChooseModeMESA(EGLDisplay dpy, EGLScreenMESA screen,
const EGLint *attrib_list, EGLModeMESA *modes,
EGLint modes_size, EGLint *num_modes)
{
_EGLDriver *drv = _eglLookupDriver(dpy);
if (drv)
- return drv->ChooseModeMESA(drv, dpy, screen_number, attrib_list, modes, modes_size, num_modes);
+ return drv->ChooseModeMESA(drv, dpy, screen, attrib_list, modes, modes_size, num_modes);
else
return EGL_FALSE;
}
EGLBoolean APIENTRY
-eglGetModesMESA(EGLDisplay dpy, EGLint screen_number, EGLModeMESA *modes, EGLint mode_size, EGLint *num_mode)
+eglGetModesMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint mode_size, EGLint *num_mode)
{
_EGLDriver *drv = _eglLookupDriver(dpy);
if (drv)
- return drv->GetModesMESA(drv, dpy, screen_number, modes, mode_size, num_mode);
+ return drv->GetModesMESA(drv, dpy, screen, modes, mode_size, num_mode);
else
return EGL_FALSE;
}
@@ -404,57 +404,47 @@ eglGetModeAttribMESA(EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint
}
-EGLSurface
-eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
-{
- return EGL_FALSE;
-}
-
-
EGLBoolean
-eglShowSurfaceMESA(EGLDisplay dpy, EGLint screen, EGLSurface surface)
+eglGetScreensMESA(EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens)
{
- return EGL_FALSE;
-}
-
-
-EGLBoolean
-eglScreenModeMESA(EGLDisplay dpy, EGLint screen_number, EGLModeMESA mode)
-{
- return EGL_FALSE;
+ _EGLDriver *drv = _eglLookupDriver(dpy);
+ if (drv)
+ return drv->GetScreensMESA(drv, dpy, screens, max_screens, num_screens);
+ else
+ return EGL_FALSE;
}
-EGLBoolean
-eglScreenAttribsMESA(EGLDisplay dpy, EGLint screen, const EGLint *attrib_list)
+EGLSurface
+eglCreateScreenSurfaceMESA(EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list)
{
return EGL_FALSE;
}
EGLBoolean
-eglQueryDisplayMESA(EGLDisplay dpy, EGLint attribute, EGLint *value)
+eglShowSurfaceMESA(EGLDisplay dpy, EGLint screen, EGLSurface surface)
{
return EGL_FALSE;
}
EGLBoolean
-eglQueryScreenSurfaceMESA(EGLDisplay dpy, EGLint screen_number, EGLSurface *surface)
+eglScreenModeMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA mode)
{
return EGL_FALSE;
}
EGLBoolean
-eglQueryScreenModeMESA(EGLDisplay dpy, EGLint screen_number, EGLModeMESA *mode)
+eglQueryScreenSurfaceMESA(EGLDisplay dpy, EGLScreenMESA screen, EGLSurface *surface)
{
return EGL_FALSE;
}
EGLBoolean
-eglQueryScreenMESA( EGLDisplay dpy, EGLint screen_number, EGLint attribute, EGLint *value)
+eglQueryScreenMESA( EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value)
{
return EGL_FALSE;
}
diff --git a/src/egl/main/eglconfig.c b/src/egl/main/eglconfig.c
index 765e2e3dbeb..0fb7e260723 100644
--- a/src/egl/main/eglconfig.c
+++ b/src/egl/main/eglconfig.c
@@ -1,3 +1,4 @@
+#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "eglconfig.h"
@@ -51,6 +52,31 @@ _eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config)
}
+/**
+ * Add the given _EGLConifg to the given display.
+ */
+_EGLConfig *
+_eglAddConfig(_EGLDisplay *display, const _EGLConfig *config)
+{
+ _EGLConfig *newConfigs;
+ EGLint n;
+
+ n = display->NumConfigs;
+
+ newConfigs = (_EGLConfig *) realloc(display->Configs,
+ (n + 1) * sizeof(_EGLConfig));
+ if (newConfigs) {
+ display->Configs = newConfigs;
+ display->Configs[n] = *config; /* copy struct */
+ display->NumConfigs++;
+ return display->Configs + n;
+ }
+ else {
+ return NULL;
+ }
+}
+
+
/**
* Parse the attrib_list to fill in the fields of the given _egl_config
diff --git a/src/egl/main/eglconfig.h b/src/egl/main/eglconfig.h
index 0bd0ce650a9..874edcdfb6f 100644
--- a/src/egl/main/eglconfig.h
+++ b/src/egl/main/eglconfig.h
@@ -29,6 +29,10 @@ extern _EGLConfig *
_eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config);
+extern _EGLConfig *
+_eglAddConfig(_EGLDisplay *display, const _EGLConfig *config);
+
+
extern EGLBoolean
_eglParseConfigAttribs(_EGLConfig *config, const EGLint *attrib_list);
diff --git a/src/egl/main/egldisplay.h b/src/egl/main/egldisplay.h
index a2831e65a46..55555e67d8a 100644
--- a/src/egl/main/egldisplay.h
+++ b/src/egl/main/egldisplay.h
@@ -13,7 +13,7 @@ struct _egl_display
_EGLDriver *Driver;
EGLint NumScreens;
- _EGLScreen *Screens; /* array [NumScreens] */
+ _EGLScreen **Screens; /* array [NumScreens] */
EGLint NumConfigs;
_EGLConfig *Configs; /* array [NumConfigs] */
diff --git a/src/egl/main/egldriver.c b/src/egl/main/egldriver.c
index 5b65b80ea4b..870c06205c6 100644
--- a/src/egl/main/egldriver.c
+++ b/src/egl/main/egldriver.c
@@ -8,6 +8,7 @@
#include "egldriver.h"
#include "eglglobals.h"
#include "eglmode.h"
+#include "eglscreen.h"
#include "eglsurface.h"
@@ -181,8 +182,16 @@ _eglInitDriverFallbacks(_EGLDriver *drv)
drv->WaitNative = _eglWaitNative;
/* EGL_MESA_screen */
+ drv->ChooseModeMESA = _eglChooseModeMESA;
drv->GetModesMESA = _eglGetModesMESA;
drv->GetModeAttribMESA = _eglGetModeAttribMESA;
+ drv->GetScreensMESA = _eglGetScreensMESA;
+ drv->CreateScreenSurfaceMESA = _eglCreateScreenSurfaceMESA;
+ drv->ShowSurfaceMESA = _eglShowSurfaceMESA;
+ drv->ScreenPositionMESA = _eglScreenPositionMESA;
+ drv->QueryScreenMESA = _eglQueryScreenMESA;
+ drv->QueryScreenSurfaceMESA = _eglQueryScreenSurfaceMESA;
+ drv->QueryScreenModeMESA = _eglQueryScreenModeMESA;
}
diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h
index 4ced7941d36..e93155967d6 100644
--- a/src/egl/main/egldriver.h
+++ b/src/egl/main/egldriver.h
@@ -40,10 +40,16 @@ typedef EGLBoolean (*WaitNative_t)(_EGLDriver *drv, EGLDisplay dpy, EGLint engin
/* EGL_MESA_screen extension */
-typedef EGLBoolean (*ChooseModeMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
-typedef EGLBoolean (*GetModesMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number, EGLModeMESA *modes, EGLint mode_size, EGLint *num_mode);
+typedef EGLBoolean (*ChooseModeMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, const EGLint *attrib_list, EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
+typedef EGLBoolean (*GetModesMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *modes, EGLint mode_size, EGLint *num_mode);
typedef EGLBoolean (*GetModeAttribMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLModeMESA mode, EGLint attribute, EGLint *value);
-
+typedef EGLBoolean (*GetScreensMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens);
+typedef EGLSurface (*CreateScreenSurfaceMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, const EGLint *attrib_list);
+typedef EGLBoolean (*ShowSurfaceMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLSurface surface);
+typedef EGLBoolean (*ScreenPositionMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y);
+typedef EGLBoolean (*QueryScreenMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value);
+typedef EGLBoolean (*QueryScreenSurfaceMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLSurface *surface);
+typedef EGLBoolean (*QueryScreenModeMESA_t)(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode);
@@ -96,6 +102,13 @@ struct _egl_driver
ChooseModeMESA_t ChooseModeMESA;
GetModesMESA_t GetModesMESA;
GetModeAttribMESA_t GetModeAttribMESA;
+ GetScreensMESA_t GetScreensMESA;
+ CreateScreenSurfaceMESA_t CreateScreenSurfaceMESA;
+ ShowSurfaceMESA_t ShowSurfaceMESA;
+ ScreenPositionMESA_t ScreenPositionMESA;
+ QueryScreenMESA_t QueryScreenMESA;
+ QueryScreenSurfaceMESA_t QueryScreenSurfaceMESA;
+ QueryScreenModeMESA_t QueryScreenModeMESA;
};
diff --git a/src/egl/main/eglglobals.c b/src/egl/main/eglglobals.c
index 102e5506206..6265b07529a 100644
--- a/src/egl/main/eglglobals.c
+++ b/src/egl/main/eglglobals.c
@@ -16,6 +16,7 @@ _eglInitGlobals(void)
_eglGlobal.Displays = _eglNewHashTable();
_eglGlobal.Contexts = _eglNewHashTable();
_eglGlobal.Surfaces = _eglNewHashTable();
+ _eglGlobal.FreeScreenHandle = 1;
_eglGlobal.CurrentContext = EGL_NO_CONTEXT;
_eglGlobal.LastError = EGL_SUCCESS;
_eglGlobal.Initialized = EGL_TRUE;
@@ -49,3 +50,16 @@ _eglError(EGLint errCode, const char *msg)
fprintf(stderr, "EGL Error 0x%x in %s\n", errCode, msg);
}
}
+
+
+/**
+ * Return a new screen handle/ID.
+ * NOTE: we never reuse these!
+ */
+EGLScreenMESA
+_eglAllocScreenHandle(void)
+{
+ EGLScreenMESA s = _eglGlobal.FreeScreenHandle;
+ _eglGlobal.FreeScreenHandle++;
+ return s;
+}
diff --git a/src/egl/main/eglglobals.h b/src/egl/main/eglglobals.h
index fbf2813f7ae..1a6f12d174e 100644
--- a/src/egl/main/eglglobals.h
+++ b/src/egl/main/eglglobals.h
@@ -13,6 +13,8 @@ struct _egl_global
_EGLHashtable *Contexts;
_EGLHashtable *Surfaces;
+ EGLScreenMESA FreeScreenHandle;
+
EGLint LastError;
/* XXX this should be per-thread someday */
@@ -35,4 +37,8 @@ extern void
_eglError(EGLint errCode, const char *msg);
+extern EGLScreenMESA
+_eglAllocScreenHandle(void);
+
+
#endif /* EGLGLOBALS_INCLUDED */
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) {
diff --git a/src/egl/main/eglmode.h b/src/egl/main/eglmode.h
index b3c268d1fb2..fa6d8e48fc1 100644
--- a/src/egl/main/eglmode.h
+++ b/src/egl/main/eglmode.h
@@ -3,9 +3,13 @@
#include "egltypedefs.h"
+
+/**
+ * Data structure which corresponds to an EGLModeMESA.
+ */
struct _egl_mode
{
- EGLConfig Handle; /* the public/opaque handle which names this mode */
+ EGLModeMESA Handle; /* the public/opaque handle which names this mode */
EGLint Width, Height; /* size in pixels */
EGLint Depth; /* bits per pixel */
EGLint RefreshRate; /* rate * 1000.0 */
@@ -21,14 +25,19 @@ extern _EGLMode *
_eglLookupMode(EGLDisplay dpy, EGLModeMESA mode);
+extern _EGLMode *
+_eglAddMode(_EGLScreen *screen, EGLint width, EGLint height,
+ EGLint depth, EGLint refreshRate);
+
+
extern 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);
extern EGLBoolean
-_eglGetModesMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
+_eglGetModesMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
EGLModeMESA *modes, EGLint modes_size, EGLint *num_modes);
diff --git a/src/egl/main/eglscreen.c b/src/egl/main/eglscreen.c
index c3c1a479847..66baa319529 100644
--- a/src/egl/main/eglscreen.c
+++ b/src/egl/main/eglscreen.c
@@ -2,14 +2,13 @@
* Ideas for screen management extension to EGL.
*
* Each EGLDisplay has one or more screens (CRTs, Flat Panels, etc).
- * The number of screens can be queried with eglQueryDisplay(EGL_SCREEN_COUNT).
+ * The screens' handles can be obtained with eglGetScreensMESA().
*
* A new kind of EGLSurface is possible- one which can be directly scanned
* out on a screen. Such a surface is created with eglCreateScreenSurface().
*
* To actually display a screen surface on a screen, the eglShowSurface()
* function is called.
- *
*/
#include <assert.h>
@@ -21,16 +20,84 @@
#include "eglscreen.h"
+/**
+ * Return a new _EGLScreen object.
+ */
+_EGLScreen *
+_eglNewScreen(void)
+{
+ return (_EGLScreen *) calloc(1, sizeof(_EGLScreen));
+}
+
+
+/**
+ * Given a public screen handle, return the internal _EGLScreen object.
+ */
_EGLScreen *
-_eglLookupScreen(EGLDisplay dpy, GLint screenNumber)
+_eglLookupScreen(EGLDisplay dpy, EGLScreenMESA screen)
{
- _EGLDisplay *disp = _eglLookupDisplay(dpy);
- if (!disp || screenNumber < 0 || screenNumber >= disp->NumScreens) {
+ EGLint i;
+ _EGLDisplay *display = _eglLookupDisplay(dpy);
+
+ if (!display)
return NULL;
+
+ for (i = 0; i < display->NumScreens; i++) {
+ if (display->Screens[i]->Handle == screen)
+ return display->Screens[i];
+ }
+ return NULL;
+}
+
+
+/**
+ * Add the given _EGLScreen to the display's list of screens.
+ */
+void
+_eglAddScreen(_EGLDisplay *display, _EGLScreen *screen)
+{
+ EGLint n;
+
+ assert(display);
+ assert(screen);
+
+ screen->Handle = _eglAllocScreenHandle();
+ n = display->NumScreens;
+ display->Screens = realloc(display->Screens, (n+1) * sizeof(_EGLScreen *));
+ display->Screens[n] = screen;
+ display->NumScreens++;
+}
+
+
+
+EGLBoolean
+_eglGetScreensMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA *screens,
+ EGLint max_screens, EGLint *num_screens)
+{
+ _EGLDisplay *display = _eglLookupDisplay(dpy);
+ EGLint n;
+
+ if (!display) {
+ _eglError(EGL_BAD_DISPLAY, "eglGetScreensMESA");
+ return EGL_FALSE;
+ }
+
+ if (display->NumScreens > max_screens) {
+ n = max_screens;
}
else {
- return disp->Screens + screenNumber;
+ n = display->NumScreens;
}
+
+ if (screens) {
+ EGLint i;
+ for (i = 0; i < n; i++)
+ screens[i] = display->Screens[i]->Handle;
+ }
+ if (num_screens)
+ *num_screens = n;
+
+ return EGL_TRUE;
}
@@ -87,10 +154,10 @@ _eglCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config,
* this with code that _really_ shows the surface.
*/
EGLBoolean
-_eglShowSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
+_eglShowSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
EGLSurface surface)
{
- _EGLScreen *scrn = _eglLookupScreen(dpy, screen_number);
+ _EGLScreen *scrn = _eglLookupScreen(dpy, screen);
_EGLMode *mode;
if (!scrn) {
@@ -139,10 +206,10 @@ _eglShowSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
* this with code that _really_ sets the mode.
*/
EGLBoolean
-_eglScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
+_eglScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
EGLModeMESA mode)
{
- _EGLScreen *scrn = _eglLookupScreen(dpy, screen_number);
+ _EGLScreen *scrn = _eglLookupScreen(dpy, screen);
if (!scrn) {
_eglError(EGL_BAD_SCREEN_MESA, "eglScreenModeMESA");
@@ -160,9 +227,9 @@ _eglScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
*/
EGLBoolean
_eglScreenPositionMESA(_EGLDriver *drv, EGLDisplay dpy,
- EGLint screen_number, EGLint x, EGLint y)
+ EGLScreenMESA screen, EGLint x, EGLint y)
{
- _EGLScreen *scrn = _eglLookupScreen(dpy, screen_number);
+ _EGLScreen *scrn = _eglLookupScreen(dpy, screen);
if (!scrn) {
_eglError(EGL_BAD_SCREEN_MESA, "eglScreenPositionMESA");
return EGL_FALSE;
@@ -175,31 +242,14 @@ _eglScreenPositionMESA(_EGLDriver *drv, EGLDisplay dpy,
}
-EGLBoolean
-_eglQueryDisplayMESA(_EGLDriver *drv, EGLDisplay dpy,
- EGLint attribute, EGLint *value)
-{
- const _EGLDisplay *display = _eglLookupDisplay(dpy);
- switch (attribute) {
- case EGL_SCREEN_COUNT_MESA:
- *value = display->NumScreens;
- break;
- default:
- _eglError(EGL_BAD_ATTRIBUTE, "eglQueryDisplayMESA");
- return EGL_FALSE;
- }
- return EGL_TRUE;
-}
-
-
/**
* Query a screen's current surface.
*/
EGLBoolean
_eglQueryScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy,
- EGLint screen_number, EGLSurface *surface)
+ EGLScreenMESA screen, EGLSurface *surface)
{
- const _EGLScreen *scrn = _eglLookupScreen(dpy, screen_number);
+ const _EGLScreen *scrn = _eglLookupScreen(dpy, screen);
if (scrn->CurrentSurface)
*surface = scrn->CurrentSurface->Handle;
else
@@ -212,10 +262,10 @@ _eglQueryScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy,
* Query a screen's current mode.
*/
EGLBoolean
-_eglQueryScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
+_eglQueryScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
EGLModeMESA *mode)
{
- const _EGLScreen *scrn = _eglLookupScreen(dpy, screen_number);
+ const _EGLScreen *scrn = _eglLookupScreen(dpy, screen);
if (scrn->CurrentMode)
*mode = scrn->CurrentMode->Handle;
else
@@ -225,10 +275,10 @@ _eglQueryScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
EGLBoolean
-_eglQueryScreenMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number,
+_eglQueryScreenMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen,
EGLint attribute, EGLint *value)
{
- const _EGLScreen *scrn = _eglLookupScreen(dpy, screen_number);
+ const _EGLScreen *scrn = _eglLookupScreen(dpy, screen);
if (!scrn) {
_eglError(EGL_BAD_SCREEN_MESA, "eglQueryScreenMESA");
diff --git a/src/egl/main/eglscreen.h b/src/egl/main/eglscreen.h
index 1dbb766dc69..1d1856b96b7 100644
--- a/src/egl/main/eglscreen.h
+++ b/src/egl/main/eglscreen.h
@@ -8,6 +8,8 @@
struct _egl_screen
{
+ EGLScreenMESA Handle; /* The public/opaque handle which names this object */
+
_EGLMode *CurrentMode;
_EGLSurface *CurrentSurface;
EGLint OriginX, OriginY;
@@ -18,7 +20,19 @@ struct _egl_screen
extern _EGLScreen *
-_eglLookupScreen(EGLDisplay dpy, GLint screenNumber);
+_eglNewScreen(void);
+
+
+extern _EGLScreen *
+_eglLookupScreen(EGLDisplay dpy, EGLScreenMESA screen);
+
+
+extern void
+_eglAddScreen(_EGLDisplay *display, _EGLScreen *screen);
+
+
+extern EGLBoolean
+_eglGetScreensMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA *screens, EGLint max_screens, EGLint *num_screens);
extern EGLSurface
@@ -26,15 +40,15 @@ _eglCreateScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config, c
extern EGLBoolean
-_eglShowSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen, EGLSurface surface);
+_eglShowSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLSurface surface);
extern EGLBoolean
-_eglScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number, EGLModeMESA mode);
+_eglScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA mode);
extern EGLBoolean
-_eglScreenPositionMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number, EGLint x, EGLint y);
+_eglScreenPositionMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLint x, EGLint y);
extern EGLBoolean
@@ -43,15 +57,15 @@ _eglQueryDisplayMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint attribute, EGLint *
extern EGLBoolean
_eglQueryScreenSurfaceMESA(_EGLDriver *drv, EGLDisplay dpy,
- EGLint screen_number, EGLSurface *surface);
+ EGLScreenMESA screen, EGLSurface *surface);
extern EGLBoolean
-_eglQueryScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number, EGLModeMESA *mode);
+_eglQueryScreenModeMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLModeMESA *mode);
extern EGLBoolean
-_eglQueryScreenMESA(_EGLDriver *drv, EGLDisplay dpy, EGLint screen_number, EGLint attribute, EGLint *value);
+_eglQueryScreenMESA(_EGLDriver *drv, EGLDisplay dpy, EGLScreenMESA screen, EGLint attribute, EGLint *value);
extern void