{
EGLint scrnum;
+ if (!disp->Screens)
+ return NULL;
+
/* loop over all screens on the display */
- for (scrnum = 0; scrnum < disp->NumScreens; scrnum++) {
- const _EGLScreen *scrn = disp->Screens[scrnum];
+ for (scrnum = 0; scrnum < disp->Screens->Size; scrnum++) {
+ const _EGLScreen *scrn = disp->Screens->Elements[scrnum];
EGLint i;
/* search list of modes for handle */
for (i = 0; i < scrn->NumModes; i++) {
{
EGLint i;
- for (i = 0; i < display->NumScreens; i++) {
- if (display->Screens[i]->Handle == screen)
- return display->Screens[i];
+ if (!display->Screens)
+ return NULL;
+
+ for (i = 0; i < display->Screens->Size; i++) {
+ _EGLScreen *scr = (_EGLScreen *) display->Screens->Elements[i];
+ if (scr->Handle == screen)
+ return scr;
}
return NULL;
}
void
_eglAddScreen(_EGLDisplay *display, _EGLScreen *screen)
{
- EGLint n;
-
assert(display);
assert(screen);
+ if (!display->Screens) {
+ display->Screens = _eglCreateArray("Screen", 4);
+ if (!display->Screens)
+ return;
+ }
screen->Handle = _eglAllocScreenHandle();
- n = display->NumScreens;
- display->Screens = realloc(display->Screens, (n+1) * sizeof(_EGLScreen *));
- display->Screens[n] = screen;
- display->NumScreens++;
+ _eglAppendArray(display->Screens, (void *) screen);
}
+static EGLBoolean
+_eglFlattenScreen(void *elem, void *buffer)
+{
+ _EGLScreen *scr = (_EGLScreen *) elem;
+ EGLScreenMESA *handle = (EGLScreenMESA *) buffer;
+ *handle = scr->Handle;
+ return EGL_TRUE;
+}
+
+
EGLBoolean
_eglGetScreensMESA(_EGLDriver *drv, _EGLDisplay *display, EGLScreenMESA *screens,
EGLint max_screens, EGLint *num_screens)
{
- EGLint n;
-
- if (display->NumScreens > max_screens) {
- n = max_screens;
- }
- else {
- 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;
+ *num_screens = _eglFlattenArray(display->Screens, (void *) screens,
+ sizeof(screens[0]), max_screens, _eglFlattenScreen);
return EGL_TRUE;
}
egl_g3d_new_sw_screen
};
+static void
+egl_g3d_free_screen(void *scr)
+{
+ struct egl_g3d_screen *gscr = egl_g3d_screen((_EGLScreen *) scr);
+ FREE(gscr->native_modes);
+ FREE(gscr);
+}
+
static EGLBoolean
egl_g3d_terminate(_EGLDriver *drv, _EGLDisplay *dpy)
{
struct egl_g3d_display *gdpy = egl_g3d_display(dpy);
- EGLint i;
_eglReleaseDisplayResources(drv, dpy);
_eglCleanupDisplay(dpy);
gdpy->pipe->destroy(gdpy->pipe);
if (dpy->Screens) {
- for (i = 0; i < dpy->NumScreens; i++) {
- struct egl_g3d_screen *gscr = egl_g3d_screen(dpy->Screens[i]);
- FREE(gscr->native_modes);
- FREE(gscr);
- }
- FREE(dpy->Screens);
+ _eglDestroyArray(dpy->Screens, egl_g3d_free_screen);
+ dpy->Screens = NULL;
}
if (gdpy->smapi)