diff options
author | Eric Engestrom <[email protected]> | 2017-06-21 10:40:31 +0100 |
---|---|---|
committer | Eric Engestrom <[email protected]> | 2017-06-22 14:54:36 +0100 |
commit | b81cfc73408b3d55772a56fbfa0e505b4da281a8 (patch) | |
tree | 1aaae171bec958a570de9f1819eb3a1a76e249bd /src | |
parent | bcd67b171152dfba2402de923a44dfe946e2684a (diff) |
egl: simplify dri_config conditionals
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 <[email protected]>
Reviewed-by: Emil Velikov <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/egl/drivers/dri2/egl_dri2.c | 25 | ||||
-rw-r--r-- | 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 fd7584f7ab6..763e6d6952b 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 3f29e64cdcf..4a5cf8e4ef1 100644 --- a/src/egl/drivers/dri2/egl_dri2.h +++ b/src/egl/drivers/dri2/egl_dri2.h @@ -321,8 +321,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 |