mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 02:50:09 +01:00
egl: in _eglAddConfig() just save a pointer to the config; don't copy the config
This allows subclassing by drivers.
This commit is contained in:
parent
88f86c9d02
commit
97035cb19a
4 changed files with 31 additions and 16 deletions
|
|
@ -78,8 +78,8 @@ _eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config)
|
||||||
EGLint i;
|
EGLint i;
|
||||||
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
_EGLDisplay *disp = _eglLookupDisplay(dpy);
|
||||||
for (i = 0; i < disp->NumConfigs; i++) {
|
for (i = 0; i < disp->NumConfigs; i++) {
|
||||||
if (disp->Configs[i].Handle == config) {
|
if (disp->Configs[i]->Handle == config) {
|
||||||
return disp->Configs + i;
|
return disp->Configs[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -88,23 +88,24 @@ _eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the given _EGLConfig to the given display.
|
* Add the given _EGLConfig to the given display.
|
||||||
|
* Note that we just save the ptr to the config (we don't copy the config).
|
||||||
*/
|
*/
|
||||||
_EGLConfig *
|
_EGLConfig *
|
||||||
_eglAddConfig(_EGLDisplay *display, const _EGLConfig *config)
|
_eglAddConfig(_EGLDisplay *display, _EGLConfig *config)
|
||||||
{
|
{
|
||||||
_EGLConfig *newConfigs;
|
_EGLConfig **newConfigs;
|
||||||
EGLint n;
|
EGLint n;
|
||||||
|
|
||||||
n = display->NumConfigs;
|
n = display->NumConfigs;
|
||||||
|
|
||||||
newConfigs = (_EGLConfig *) realloc(display->Configs,
|
/* realloc array of ptrs */
|
||||||
(n + 1) * sizeof(_EGLConfig));
|
newConfigs = (_EGLConfig **) realloc(display->Configs,
|
||||||
|
(n + 1) * sizeof(_EGLConfig *));
|
||||||
if (newConfigs) {
|
if (newConfigs) {
|
||||||
display->Configs = newConfigs;
|
display->Configs = newConfigs;
|
||||||
display->Configs[n] = *config; /* copy struct */
|
display->Configs[n] = config;
|
||||||
display->Configs[n].Handle = (EGLConfig) n;
|
|
||||||
display->NumConfigs++;
|
display->NumConfigs++;
|
||||||
return display->Configs + n;
|
return config;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -330,8 +331,8 @@ _eglChooseConfig(_EGLDriver *drv, EGLDisplay dpy, const EGLint *attrib_list,
|
||||||
|
|
||||||
/* make array of pointers to qualifying configs */
|
/* make array of pointers to qualifying configs */
|
||||||
for (i = count = 0; i < disp->NumConfigs && count < config_size; i++) {
|
for (i = count = 0; i < disp->NumConfigs && count < config_size; i++) {
|
||||||
if (_eglConfigQualifies(disp->Configs + i, &criteria)) {
|
if (_eglConfigQualifies(disp->Configs[i], &criteria)) {
|
||||||
configList[count++] = disp->Configs + i;
|
configList[count++] = disp->Configs[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -389,7 +390,7 @@ _eglGetConfigs(_EGLDriver *drv, EGLDisplay dpy, EGLConfig *configs,
|
||||||
EGLint i;
|
EGLint i;
|
||||||
*num_config = MIN2(disp->NumConfigs, config_size);
|
*num_config = MIN2(disp->NumConfigs, config_size);
|
||||||
for (i = 0; i < *num_config; i++) {
|
for (i = 0; i < *num_config; i++) {
|
||||||
configs[i] = disp->Configs[i].Handle;
|
configs[i] = disp->Configs[i]->Handle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ _eglLookupConfig(_EGLDriver *drv, EGLDisplay dpy, EGLConfig config);
|
||||||
|
|
||||||
|
|
||||||
extern _EGLConfig *
|
extern _EGLConfig *
|
||||||
_eglAddConfig(_EGLDisplay *display, const _EGLConfig *config);
|
_eglAddConfig(_EGLDisplay *display, _EGLConfig *config);
|
||||||
|
|
||||||
|
|
||||||
extern EGLBoolean
|
extern EGLBoolean
|
||||||
|
|
|
||||||
|
|
@ -96,11 +96,25 @@ _eglGetCurrentDisplay(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Free all the data hanging of an _EGLDisplay object, but not
|
||||||
|
* the object itself.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
_eglCleanupDisplay(_EGLDisplay *disp)
|
_eglCleanupDisplay(_EGLDisplay *disp)
|
||||||
{
|
{
|
||||||
/* XXX incomplete */
|
EGLint i;
|
||||||
|
|
||||||
|
for (i = 0; i < disp->NumConfigs; i++) {
|
||||||
|
free(disp->Configs[i]);
|
||||||
|
}
|
||||||
free(disp->Configs);
|
free(disp->Configs);
|
||||||
|
disp->Configs = NULL;
|
||||||
|
|
||||||
|
/* XXX incomplete */
|
||||||
|
|
||||||
free((void *) disp->DriverName);
|
free((void *) disp->DriverName);
|
||||||
/* driver deletes _EGLDisplay */
|
disp->DriverName = NULL;
|
||||||
|
|
||||||
|
/* driver deletes the _EGLDisplay object */
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ struct _egl_display
|
||||||
_EGLScreen **Screens; /* array [NumScreens] */
|
_EGLScreen **Screens; /* array [NumScreens] */
|
||||||
|
|
||||||
EGLint NumConfigs;
|
EGLint NumConfigs;
|
||||||
_EGLConfig *Configs; /* array [NumConfigs] */
|
_EGLConfig **Configs; /* array [NumConfigs] of ptr to _EGLConfig */
|
||||||
|
|
||||||
#ifdef _EGL_PLATFORM_X
|
#ifdef _EGL_PLATFORM_X
|
||||||
Display *Xdpy;
|
Display *Xdpy;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue