2 * Ideas for screen management extension to EGL.
4 * Each EGLDisplay has one or more screens (CRTs, Flat Panels, etc).
5 * The number of screens can be queried with eglQueryDisplay(EGL_SCREEN_COUNT).
7 * A new kind of EGLSurface is possible- one which can be directly scanned
8 * out on a screen. Such a surface is created with eglCreateScreenSurface().
10 * To actually display a screen surface on a screen, the eglShowSurface()
17 #include "egldisplay.h"
18 #include "eglglobals.h"
20 #include "eglsurface.h"
21 #include "eglscreen.h"
25 _eglLookupScreen(EGLDisplay dpy
, GLint screenNumber
)
27 _EGLDisplay
*disp
= _eglLookupDisplay(dpy
);
28 if (!disp
|| screenNumber
< 0 || screenNumber
>= disp
->NumScreens
) {
32 return disp
->Screens
+ screenNumber
;
38 * Create a drawing surface which can be directly displayed on a screen.
41 _eglCreateScreenSurfaceMESA(_EGLDriver
*drv
, EGLDisplay dpy
, EGLConfig config
,
42 const EGLint
*attrib_list
)
45 EGLint width
= 0, height
= 0;
48 for (i
= 0; attrib_list
&& attrib_list
[i
] != EGL_NONE
; i
++) {
49 switch (attrib_list
[i
]) {
51 width
= attrib_list
[++i
];
54 height
= attrib_list
[++i
];
57 _eglError(EGL_BAD_ATTRIBUTE
, "eglCreateScreenSurfaceMESA");
58 return EGL_NO_SURFACE
;
62 if (width
<= 0 || height
<= 0) {
63 _eglError(EGL_BAD_ATTRIBUTE
,
64 "eglCreateScreenSurfaceMESA(width or height)");
65 return EGL_NO_SURFACE
;
68 surf
= (_EGLSurface
*) malloc(sizeof(_EGLSurface
));
69 _eglInitSurface(surf
);
71 surf
->Height
= height
;
72 surf
->Type
= EGL_SCREEN_BIT_MESA
;
74 /* insert into hash table */
75 _eglSaveSurface(surf
);
83 * Show the given surface on the named screen.
84 * If surface is EGL_NO_SURFACE, disable the screen's output.
86 * This is just a placeholder function; drivers will always override
87 * this with code that _really_ shows the surface.
90 _eglShowSurfaceMESA(_EGLDriver
*drv
, EGLDisplay dpy
, EGLint screen_number
,
93 _EGLScreen
*scrn
= _eglLookupScreen(dpy
, screen_number
);
97 _eglError(EGL_BAD_SCREEN_MESA
, "eglShowSurfaceMESA");
102 * XXX: Check if the surface's configuration is compatible with the
103 * current screen mode.
106 mode
= scrn
->CurrentMode
;
107 if (mode
== EGL_NO_MODE_MESA
) {
108 _eglError(EGL_BAD_MODE_MESA
, "eglShowSurfaceMESA(no current mode)");
112 if (surface
== EGL_NO_SURFACE
) {
113 scrn
->CurrentSurface
= NULL
;
116 _EGLSurface
*surf
= _eglLookupSurface(surface
);
117 if (!surf
|| surf
->Type
!= EGL_SCREEN_BIT_MESA
) {
118 _eglError(EGL_BAD_SURFACE
, "eglShowSurfaceMESA");
121 if (surf
->Width
< mode
->Width
|| surf
->Height
< mode
->Height
) {
122 _eglError(EGL_BAD_SURFACE
,
123 "eglShowSurfaceMESA(surface smaller than screen size)");
127 scrn
->CurrentSurface
= surf
;
135 * Set a screen's current display mode.
136 * Note: mode = EGL_NO_MODE is valid (turns off the screen)
138 * This is just a placeholder function; drivers will always override
139 * this with code that _really_ sets the mode.
142 _eglScreenModeMESA(_EGLDriver
*drv
, EGLDisplay dpy
, EGLint screen_number
,
145 _EGLScreen
*scrn
= _eglLookupScreen(dpy
, screen_number
);
148 _eglError(EGL_BAD_SCREEN_MESA
, "eglScreenModeMESA");
152 scrn
->CurrentMode
= _eglLookupMode(dpy
, mode
);
159 * Set a screen's surface origin.
162 _eglScreenPositionMESA(_EGLDriver
*drv
, EGLDisplay dpy
,
163 EGLint screen_number
, EGLint x
, EGLint y
)
165 _EGLScreen
*scrn
= _eglLookupScreen(dpy
, screen_number
);
167 _eglError(EGL_BAD_SCREEN_MESA
, "eglScreenPositionMESA");
179 _eglQueryDisplayMESA(_EGLDriver
*drv
, EGLDisplay dpy
,
180 EGLint attribute
, EGLint
*value
)
182 const _EGLDisplay
*display
= _eglLookupDisplay(dpy
);
184 case EGL_SCREEN_COUNT_MESA
:
185 *value
= display
->NumScreens
;
188 _eglError(EGL_BAD_ATTRIBUTE
, "eglQueryDisplayMESA");
196 * Query a screen's current surface.
199 _eglQueryScreenSurfaceMESA(_EGLDriver
*drv
, EGLDisplay dpy
,
200 EGLint screen_number
, EGLSurface
*surface
)
202 const _EGLScreen
*scrn
= _eglLookupScreen(dpy
, screen_number
);
203 if (scrn
->CurrentSurface
)
204 *surface
= scrn
->CurrentSurface
->Handle
;
206 *surface
= EGL_NO_SURFACE
;
212 * Query a screen's current mode.
215 _eglQueryScreenModeMESA(_EGLDriver
*drv
, EGLDisplay dpy
, EGLint screen_number
,
218 const _EGLScreen
*scrn
= _eglLookupScreen(dpy
, screen_number
);
219 if (scrn
->CurrentMode
)
220 *mode
= scrn
->CurrentMode
->Handle
;
222 *mode
= EGL_NO_MODE_MESA
;
228 _eglQueryScreenMESA(_EGLDriver
*drv
, EGLDisplay dpy
, EGLint screen_number
,
229 EGLint attribute
, EGLint
*value
)
231 const _EGLScreen
*scrn
= _eglLookupScreen(dpy
, screen_number
);
234 _eglError(EGL_BAD_SCREEN_MESA
, "eglQueryScreenMESA");
239 case EGL_SCREEN_POSITION_MESA
:
240 value
[0] = scrn
->OriginX
;
241 value
[1] = scrn
->OriginY
;
244 _eglError(EGL_BAD_ATTRIBUTE
, "eglQueryScreenMESA");
254 _eglDeleteScreen(_EGLScreen
*scrn
)