/** * Add a module to the module array. */ static _EGLModule * _eglAddModule(const char *path) { _EGLModule *mod; EGLint i; if (!_eglModules) { _eglModules = _eglCreateArray("Module", 8); if (!_eglModules) return NULL; } /* find duplicates */ for (i = 0; i < _eglModules->Size; i++) { mod = _eglModules->Elements[i]; if (strcmp(mod->Path, path) == 0) return mod; } /* allocate a new one */ mod = calloc(1, sizeof(*mod)); if (mod) { mod->Path = _eglstrdup(path); if (!mod->Path) { free(mod); mod = NULL; } } if (mod) { _eglAppendArray(_eglModules, (void *) mod); _eglLog(_EGL_DEBUG, "added %s to module array", mod->Path); } return mod; }
/** * Add the given _EGLScreen to the display's list of screens. */ void _eglAddScreen(_EGLDisplay *display, _EGLScreen *screen) { assert(display); assert(screen); if (!display->Screens) { display->Screens = _eglCreateArray("Screen", 4); if (!display->Screens) return; } screen->Handle = _eglAllocScreenHandle(); _eglAppendArray(display->Screens, (void *) screen); }
/** * Link a config to its display and return the handle of the link. * The handle can be passed to client directly. * * Note that we just save the ptr to the config (we don't copy the config). */ EGLConfig _eglLinkConfig(_EGLConfig *conf) { _EGLDisplay *dpy = conf->Display; /* sanity check */ assert(dpy && conf->ConfigID > 0); if (!dpy->Configs) { dpy->Configs = _eglCreateArray("Config", 16); if (!dpy->Configs) return (EGLConfig) NULL; } _eglAppendArray(dpy->Configs, (void *) conf); return (EGLConfig) conf; }
/** * Link a screen to its display and return the handle of the link. * The handle can be passed to client directly. */ EGLScreenMESA _eglLinkScreen(_EGLScreen *screen) { _EGLDisplay *display; EGLint i; assert(screen && screen->Display); display = screen->Display; if (!display->Screens) { display->Screens = _eglCreateArray("Screen", 4); if (!display->Screens) return (EGLScreenMESA) 0; } screen->Handle = _eglAllocScreenHandle(); for (i = 0; i < screen->NumModes; i++) screen->Modes[i].Handle = screen->Handle + i; _eglAppendArray(display->Screens, (void *) screen); return screen->Handle; }