aboutsummaryrefslogtreecommitdiffstats
path: root/src/egl/main/eglscreen.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/egl/main/eglscreen.c')
-rw-r--r--src/egl/main/eglscreen.c120
1 files changed, 85 insertions, 35 deletions
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");