[Mesa-dev] [PATCH mesa] egl: simplify dri_config conditionals
Eric Engestrom
eric.engestrom at imgtec.com
Wed Jun 21 12:25:49 UTC 2017
In the same spirit as 858f2f2ae6 (egl/dri2: ease srgb __DRIconfig
conditionals), let's merge dri_single_config and dri_double_config into
a single dri_config[2].
This moves the `if (double) dri_double_config else dri_single_config`
logic to `dri_config[double]`, reducing code duplication and making it
easier to read.
Signed-off-by: Eric Engestrom <eric.engestrom at imgtec.com>
---
src/egl/drivers/dri2/egl_dri2.c | 25 ++++++++++---------------
src/egl/drivers/dri2/egl_dri2.h | 3 +--
2 files changed, 11 insertions(+), 17 deletions(-)
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 020a0bc639..c09c5f57a4 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -162,10 +162,10 @@ const __DRIconfig *
dri2_get_dri_config(struct dri2_egl_config *conf, EGLint surface_type,
EGLenum colorspace)
{
+ const bool double_buffer = surface_type == EGL_WINDOW_BIT;
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];
+ return conf->dri_config[double_buffer][srgb];
}
static EGLBoolean
@@ -323,10 +323,8 @@ 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 && !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;
+ if (!conf->dri_config[double_buffer][srgb])
+ conf->dri_config[double_buffer][srgb] = dri_config;
else
/* a similar config type is already added (unlikely) => discard */
return NULL;
@@ -336,10 +334,7 @@ dri2_add_config(_EGLDisplay *disp, const __DRIconfig *dri_config, int id,
if (conf == NULL)
return NULL;
- if (double_buffer)
- conf->dri_double_config[srgb] = dri_config;
- else
- conf->dri_single_config[srgb] = dri_config;
+ conf->dri_config[double_buffer][srgb] = dri_config;
memcpy(&conf->base, &base, sizeof base);
conf->base.SurfaceType = 0;
@@ -1188,13 +1183,13 @@ dri2_create_context(_EGLDriver *drv, _EGLDisplay *disp, _EGLConfig *conf,
* doubleBufferMode check in
* src/mesa/main/context.c:check_compatible()
*/
- if (dri2_config->dri_double_config[0])
- dri_config = dri2_config->dri_double_config[0];
+ if (dri2_config->dri_config[1][0])
+ dri_config = dri2_config->dri_config[1][0];
else
- dri_config = dri2_config->dri_single_config[0];
+ dri_config = dri2_config->dri_config[0][0];
- /* EGL_WINDOW_BIT is set only when there is a dri_double_config. This
- * makes sure the back buffer will always be used.
+ /* EGL_WINDOW_BIT is set only when there is a double-buffered dri_config.
+ * This makes sure the back buffer will always be used.
*/
if (conf->SurfaceType & EGL_WINDOW_BIT)
dri2_ctx->base.WindowRenderBuffer = EGL_BACK_BUFFER;
diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index f8c26a9d45..0d4dcdfa1f 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -320,8 +320,7 @@ struct dri2_egl_surface
struct dri2_egl_config
{
_EGLConfig base;
- const __DRIconfig *dri_single_config[2];
- const __DRIconfig *dri_double_config[2];
+ const __DRIconfig *dri_config[2][2];
};
struct dri2_egl_image
--
Cheers,
Eric
More information about the mesa-dev
mailing list