summaryrefslogtreecommitdiffstats
path: root/src/egl
diff options
context:
space:
mode:
authorEmil Velikov <[email protected]>2015-09-13 12:25:27 +0100
committerEmil Velikov <[email protected]>2015-10-07 15:17:57 +0100
commit858f2f2ae6d72f338fdd6d544b0c733814e22724 (patch)
tree9a443d5b82eb16e5727f6539b3c9d3f6173c1a23 /src/egl
parentb69cfbdf18fa64606a76761b20bc268f4ac731e5 (diff)
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 <[email protected]> Acked-by: Alex Deucher <[email protected]>
Diffstat (limited to 'src/egl')
-rw-r--r--src/egl/drivers/dri2/egl_dri2.c37
-rw-r--r--src/egl/drivers/dri2/egl_dri2.h6
2 files changed, 14 insertions, 29 deletions
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index f600d1b606d..229285fbbe6 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -131,12 +131,10 @@ const __DRIconfig *
dri2_get_dri_config(struct dri2_egl_config *conf, EGLint surface_type,
EGLenum colorspace)
{
- if (colorspace == EGL_GL_COLORSPACE_SRGB_KHR)
- return surface_type == EGL_WINDOW_BIT ? conf->dri_srgb_double_config :
- conf->dri_srgb_single_config;
- else
- return surface_type == EGL_WINDOW_BIT ? conf->dri_double_config :
- conf->dri_single_config;
+ const bool srgb = colorspace == EGL_GL_COLORSPACE_SRGB_KHR;
+
+ return surface_type == EGL_WINDOW_BIT ? conf->dri_double_config[srgb] :
+ conf->dri_single_config[srgb];
}
static EGLBoolean
@@ -284,14 +282,10 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
if (num_configs == 1) {
conf = (struct dri2_egl_config *) matching_config;
- if (double_buffer && srgb && !conf->dri_srgb_double_config)
- conf->dri_srgb_double_config = dri_config;
- else if (double_buffer && !srgb && !conf->dri_double_config)
- conf->dri_double_config = 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;
+ if (double_buffer && !conf->dri_double_config[srgb])
+ conf->dri_double_config[srgb] = dri_config;
+ else if (!double_buffer && !conf->dri_single_config[srgb])
+ conf->dri_single_config[srgb] = dri_config;
else
/* a similar config type is already added (unlikely) => discard */
return NULL;
@@ -301,17 +295,10 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
if (conf == NULL)
return NULL;
- if (double_buffer) {
- if (srgb)
- conf->dri_srgb_double_config = dri_config;
- else
- conf->dri_double_config = dri_config;
- } else {
- if (srgb)
- conf->dri_srgb_single_config = dri_config;
- else
- conf->dri_single_config = dri_config;
- }
+ if (double_buffer)
+ conf->dri_double_config[srgb] = dri_config;
+ else
+ conf->dri_single_config[srgb] = dri_config;
memcpy(&conf->base, &base, sizeof base);
conf->base.SurfaceType = 0;
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index 9aa2a8c1003..0e837b3eb8b 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -284,10 +284,8 @@ struct dri2_egl_surface
struct dri2_egl_config
{
_EGLConfig base;
- const __DRIconfig *dri_single_config;
- const __DRIconfig *dri_double_config;
- const __DRIconfig *dri_srgb_single_config;
- const __DRIconfig *dri_srgb_double_config;
+ const __DRIconfig *dri_single_config[2];
+ const __DRIconfig *dri_double_config[2];
};
struct dri2_egl_image