summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmil Velikov <emil.velikov@collabora.com>2016-08-25 14:28:48 +0100
committerEmil Velikov <emil.l.velikov@gmail.com>2016-10-14 12:53:39 +0100
commitacd35c8758dc732409035cb0488c9d1c896f636d (patch)
treee07ca6d5f5b81873a1301520db7bfac7a83af7ba
parent36fe5900a4c3f098699acd09221ab31b74229580 (diff)
egl/android: tweak droid_add_configs_for_visuals()
Iterate over the driver_configs first in order to cut down the number of getConfigAttrib() calls by a factor of 5. While we're here, also drop the sentinel of the visuals array. We already know its size so we can use that and save a few bytes. v2: Use correct comparison in loop conditional (Eric) Use valid C initializer (Gurchetan) Signed-off-by: Emil Velikov <emil.velikov@collabora.com> Reviewed-by: Eric Engestrom <eric@engestrom.ch>
-rw-r--r--src/egl/drivers/dri2/platform_android.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
index ac9072afd5c..6a4122a8cc9 100644
--- a/src/egl/drivers/dri2/platform_android.c
+++ b/src/egl/drivers/dri2/platform_android.c
@@ -760,7 +760,6 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
{ HAL_PIXEL_FORMAT_RGB_888, { 0xff, 0xff00, 0xff0000, 0x0 } },
{ HAL_PIXEL_FORMAT_RGB_565, { 0xf800, 0x7e0, 0x1f, 0x0 } },
{ HAL_PIXEL_FORMAT_BGRA_8888, { 0xff0000, 0xff00, 0xff, 0xff000000 } },
- { 0, { 0, 0, 0, 0 } }
};
EGLint config_attrs[] = {
EGL_NATIVE_VISUAL_ID, 0,
@@ -771,38 +770,41 @@ droid_add_configs_for_visuals(_EGLDriver *drv, _EGLDisplay *dpy)
EGL_MAX_PBUFFER_HEIGHT, _EGL_MAX_PBUFFER_HEIGHT,
EGL_NONE
};
+ unsigned int format_count[ARRAY_SIZE(visuals)] = { 0 };
int count, i, j;
count = 0;
- for (i = 0; visuals[i].format; i++) {
- int format_count = 0;
+ for (i = 0; dri2_dpy->driver_configs[i]; i++) {
+ const EGLint surface_type = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
+ struct dri2_egl_config *dri2_conf;
+ unsigned int double_buffered = 0;
- config_attrs[1] = visuals[i].format;
- config_attrs[3] = visuals[i].format;
+ dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[i],
+ __DRI_ATTRIB_DOUBLE_BUFFER, &double_buffered);
- for (j = 0; dri2_dpy->driver_configs[j]; j++) {
- const EGLint surface_type = EGL_WINDOW_BIT | EGL_PBUFFER_BIT;
- struct dri2_egl_config *dri2_conf;
- unsigned int double_buffered = 0;
+ /* support only double buffered configs */
+ if (!double_buffered)
+ continue;
- dri2_dpy->core->getConfigAttrib(dri2_dpy->driver_configs[j],
- __DRI_ATTRIB_DOUBLE_BUFFER, &double_buffered);
+ for (j = 0; j < ARRAY_SIZE(visuals); j++) {
+ int format_count = 0;
- /* support only double buffered configs */
- if (!double_buffered)
- continue;
+ config_attrs[1] = visuals[j].format;
+ config_attrs[3] = visuals[j].format;
- dri2_conf = dri2_add_config(dpy, dri2_dpy->driver_configs[j],
- count + 1, surface_type, config_attrs, visuals[i].rgba_masks);
+ dri2_conf = dri2_add_config(dpy, dri2_dpy->driver_configs[i],
+ count + 1, surface_type, config_attrs, visuals[j].rgba_masks);
if (dri2_conf) {
count++;
- format_count++;
+ format_count[j]++;
}
}
+ }
- if (!format_count) {
+ for (i = 0; i < ARRAY_SIZE(format_count); i++) {
+ if (!format_count[i]) {
_eglLog(_EGL_DEBUG, "No DRI config supports native format 0x%x",
- visuals[i].format);
+ visuals[i].format);
}
}