egl/dri2: ease srgb __DRIconfig conditionals
One can simplify the if-else chain, by declaring the driconfigs as a two sized array, whist using srgb as a index to the correct entry. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com> Acked-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
b69cfbdf18
commit
858f2f2ae6
|
@ -131,12 +131,10 @@ const __DRIconfig *
|
||||||
dri2_get_dri_config(struct dri2_egl_config *conf, EGLint surface_type,
|
dri2_get_dri_config(struct dri2_egl_config *conf, EGLint surface_type,
|
||||||
EGLenum colorspace)
|
EGLenum colorspace)
|
||||||
{
|
{
|
||||||
if (colorspace == EGL_GL_COLORSPACE_SRGB_KHR)
|
const bool srgb = colorspace == EGL_GL_COLORSPACE_SRGB_KHR;
|
||||||
return surface_type == EGL_WINDOW_BIT ? conf->dri_srgb_double_config :
|
|
||||||
conf->dri_srgb_single_config;
|
return surface_type == EGL_WINDOW_BIT ? conf->dri_double_config[srgb] :
|
||||||
else
|
conf->dri_single_config[srgb];
|
||||||
return surface_type == EGL_WINDOW_BIT ? conf->dri_double_config :
|
|
||||||
conf->dri_single_config;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static EGLBoolean
|
static EGLBoolean
|
||||||
|
@ -284,14 +282,10 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
|
||||||
if (num_configs == 1) {
|
if (num_configs == 1) {
|
||||||
conf = (struct dri2_egl_config *) matching_config;
|
conf = (struct dri2_egl_config *) matching_config;
|
||||||
|
|
||||||
if (double_buffer && srgb && !conf->dri_srgb_double_config)
|
if (double_buffer && !conf->dri_double_config[srgb])
|
||||||
conf->dri_srgb_double_config = dri_config;
|
conf->dri_double_config[srgb] = dri_config;
|
||||||
else if (double_buffer && !srgb && !conf->dri_double_config)
|
else if (!double_buffer && !conf->dri_single_config[srgb])
|
||||||
conf->dri_double_config = dri_config;
|
conf->dri_single_config[srgb] = dri_config;
|
||||||
else if (!double_buffer && srgb && !conf->dri_srgb_single_config)
|
|
||||||
conf->dri_srgb_single_config = dri_config;
|
|
||||||
else if (!double_buffer && !srgb && !conf->dri_single_config)
|
|
||||||
conf->dri_single_config = dri_config;
|
|
||||||
else
|
else
|
||||||
/* a similar config type is already added (unlikely) => discard */
|
/* a similar config type is already added (unlikely) => discard */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -301,17 +295,10 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
|
||||||
if (conf == NULL)
|
if (conf == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
if (double_buffer) {
|
if (double_buffer)
|
||||||
if (srgb)
|
conf->dri_double_config[srgb] = dri_config;
|
||||||
conf->dri_srgb_double_config = dri_config;
|
else
|
||||||
else
|
conf->dri_single_config[srgb] = dri_config;
|
||||||
conf->dri_double_config = dri_config;
|
|
||||||
} else {
|
|
||||||
if (srgb)
|
|
||||||
conf->dri_srgb_single_config = dri_config;
|
|
||||||
else
|
|
||||||
conf->dri_single_config = dri_config;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(&conf->base, &base, sizeof base);
|
memcpy(&conf->base, &base, sizeof base);
|
||||||
conf->base.SurfaceType = 0;
|
conf->base.SurfaceType = 0;
|
||||||
|
|
|
@ -284,10 +284,8 @@ struct dri2_egl_surface
|
||||||
struct dri2_egl_config
|
struct dri2_egl_config
|
||||||
{
|
{
|
||||||
_EGLConfig base;
|
_EGLConfig base;
|
||||||
const __DRIconfig *dri_single_config;
|
const __DRIconfig *dri_single_config[2];
|
||||||
const __DRIconfig *dri_double_config;
|
const __DRIconfig *dri_double_config[2];
|
||||||
const __DRIconfig *dri_srgb_single_config;
|
|
||||||
const __DRIconfig *dri_srgb_double_config;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct dri2_egl_image
|
struct dri2_egl_image
|
||||||
|
|
Loading…
Reference in New Issue