2 * Ideas for screen management extension to EGL.
4 * Each EGLDisplay has one or more screens (CRTs, Flat Panels, etc).
5 * The screens' handles can be obtained with eglGetScreensMESA().
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()
18 #include "egldisplay.h"
19 #include "eglglobals.h"
20 #include "eglcurrent.h"
22 #include "eglconfig.h"
23 #include "eglsurface.h"
24 #include "eglscreen.h"
29 * Return a new screen handle/ID.
30 * NOTE: we never reuse these!
33 _eglAllocScreenHandle(void)
37 _eglLockMutex(_eglGlobal
.Mutex
);
38 s
= _eglGlobal
.FreeScreenHandle
++;
39 _eglUnlockMutex(_eglGlobal
.Mutex
);
46 * Initialize an _EGLScreen object to default values.
49 _eglInitScreen(_EGLScreen
*screen
)
51 memset(screen
, 0, sizeof(_EGLScreen
));
58 * Given a public screen handle, return the internal _EGLScreen object.
61 _eglLookupScreen(EGLScreenMESA screen
, _EGLDisplay
*display
)
65 for (i
= 0; i
< display
->NumScreens
; i
++) {
66 if (display
->Screens
[i
]->Handle
== screen
)
67 return display
->Screens
[i
];
74 * Add the given _EGLScreen to the display's list of screens.
77 _eglAddScreen(_EGLDisplay
*display
, _EGLScreen
*screen
)
84 screen
->Handle
= _eglAllocScreenHandle();
85 n
= display
->NumScreens
;
86 display
->Screens
= realloc(display
->Screens
, (n
+1) * sizeof(_EGLScreen
*));
87 display
->Screens
[n
] = screen
;
88 display
->NumScreens
++;
94 _eglGetScreensMESA(_EGLDriver
*drv
, _EGLDisplay
*display
, EGLScreenMESA
*screens
,
95 EGLint max_screens
, EGLint
*num_screens
)
99 if (display
->NumScreens
> max_screens
) {
103 n
= display
->NumScreens
;
108 for (i
= 0; i
< n
; i
++)
109 screens
[i
] = display
->Screens
[i
]->Handle
;
119 * Drivers should do a proper implementation.
122 _eglCreateScreenSurfaceMESA(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLConfig
*conf
,
123 const EGLint
*attrib_list
)
130 * Show the given surface on the named screen.
131 * If surface is EGL_NO_SURFACE, disable the screen's output.
133 * This is just a placeholder function; drivers will always override
134 * this with code that _really_ shows the surface.
137 _eglShowScreenSurfaceMESA(_EGLDriver
*drv
, _EGLDisplay
*dpy
,
138 _EGLScreen
*scrn
, _EGLSurface
*surf
,
142 scrn
->CurrentSurface
= NULL
;
145 if (surf
->Type
!= EGL_SCREEN_BIT_MESA
) {
146 _eglError(EGL_BAD_SURFACE
, "eglShowSurfaceMESA");
149 if (surf
->Width
< mode
->Width
|| surf
->Height
< mode
->Height
) {
150 _eglError(EGL_BAD_SURFACE
,
151 "eglShowSurfaceMESA(surface smaller than screen size)");
155 scrn
->CurrentSurface
= surf
;
156 scrn
->CurrentMode
= mode
;
163 * Set a screen's current display mode.
164 * Note: mode = EGL_NO_MODE is valid (turns off the screen)
166 * This is just a placeholder function; drivers will always override
167 * this with code that _really_ sets the mode.
170 _eglScreenModeMESA(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLScreen
*scrn
,
173 scrn
->CurrentMode
= m
;
179 * Set a screen's surface origin.
182 _eglScreenPositionMESA(_EGLDriver
*drv
, _EGLDisplay
*dpy
,
183 _EGLScreen
*scrn
, EGLint x
, EGLint y
)
193 * Query a screen's current surface.
196 _eglQueryScreenSurfaceMESA(_EGLDriver
*drv
, _EGLDisplay
*dpy
,
197 _EGLScreen
*scrn
, _EGLSurface
**surf
)
199 *surf
= scrn
->CurrentSurface
;
205 * Query a screen's current mode.
208 _eglQueryScreenModeMESA(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLScreen
*scrn
,
211 *m
= scrn
->CurrentMode
;
217 _eglQueryScreenMESA(_EGLDriver
*drv
, _EGLDisplay
*dpy
, _EGLScreen
*scrn
,
218 EGLint attribute
, EGLint
*value
)
221 case EGL_SCREEN_POSITION_MESA
:
222 value
[0] = scrn
->OriginX
;
223 value
[1] = scrn
->OriginY
;
225 case EGL_SCREEN_POSITION_GRANULARITY_MESA
:
226 value
[0] = scrn
->StepX
;
227 value
[1] = scrn
->StepY
;
230 _eglError(EGL_BAD_ATTRIBUTE
, "eglQueryScreenMESA");
239 * Delete the modes associated with given screen.
242 _eglDestroyScreenModes(_EGLScreen
*scrn
)
245 for (i
= 0; i
< scrn
->NumModes
; i
++) {
246 if (scrn
->Modes
[i
].Name
)
247 free((char *) scrn
->Modes
[i
].Name
); /* cast away const */
257 * Default fallback routine - drivers should usually override this.
260 _eglDestroyScreen(_EGLScreen
*scrn
)
262 _eglDestroyScreenModes(scrn
);