Rather than having the call in multiple places and multiple times, just query the native visual id once and store it for later use.
Signed-off-by: Emil Velikov <emil.veli...@collabora.com> --- src/waffle/egl/wegl_config.c | 7 +++++++ src/waffle/egl/wegl_config.h | 1 + src/waffle/gbm/wgbm_config.c | 39 --------------------------------------- src/waffle/gbm/wgbm_config.h | 10 ---------- src/waffle/gbm/wgbm_platform.c | 2 +- src/waffle/gbm/wgbm_window.c | 7 ++----- src/waffle/xegl/xegl_window.c | 13 +------------ 7 files changed, 12 insertions(+), 67 deletions(-) diff --git a/src/waffle/egl/wegl_config.c b/src/waffle/egl/wegl_config.c index 08e06fb..892bfef 100644 --- a/src/waffle/egl/wegl_config.c +++ b/src/waffle/egl/wegl_config.c @@ -230,6 +230,7 @@ wegl_config_choose(struct wcore_platform *wc_plat, struct wcore_display *wc_dpy, const struct wcore_config_attrs *attrs) { + struct wegl_platform *plat = wegl_platform(wc_plat); struct wegl_display *dpy = wegl_display(wc_dpy); struct wegl_config *config; bool ok; @@ -251,6 +252,12 @@ wegl_config_choose(struct wcore_platform *wc_plat, if (!config->egl) goto fail; + ok = plat->eglGetConfigAttrib(dpy->egl, config->egl, + EGL_NATIVE_VISUAL_ID, &config->visual); + + if (!ok) + goto fail; + return &config->wcore; fail: diff --git a/src/waffle/egl/wegl_config.h b/src/waffle/egl/wegl_config.h index a9e3cb9..3e3cec9 100644 --- a/src/waffle/egl/wegl_config.h +++ b/src/waffle/egl/wegl_config.h @@ -40,6 +40,7 @@ struct wcore_config_attrs; struct wegl_config { struct wcore_config wcore; EGLConfig egl; + EGLint visual; }; DEFINE_CONTAINER_CAST_FUNC(wegl_config, diff --git a/src/waffle/gbm/wgbm_config.c b/src/waffle/gbm/wgbm_config.c index 1d64b71..7383425 100644 --- a/src/waffle/gbm/wgbm_config.c +++ b/src/waffle/gbm/wgbm_config.c @@ -30,45 +30,6 @@ #include "wgbm_config.h" #include "wgbm_display.h" -struct wcore_config* -wgbm_config_choose(struct wcore_platform *wc_plat, - struct wcore_display *wc_dpy, - const struct wcore_config_attrs *attrs) -{ - struct wcore_config *wc_config = wegl_config_choose(wc_plat, wc_dpy, attrs); - if (!wc_config) - return NULL; - - if (wgbm_config_get_gbm_format(wc_plat, wc_dpy, wc_config) == 0) { - wcore_errorf(WAFFLE_ERROR_UNSUPPORTED_ON_PLATFORM, - "requested config is unsupported on GBM"); - wegl_config_destroy(wc_config); - return NULL; - } - - return wc_config; -} - -uint32_t -wgbm_config_get_gbm_format(struct wcore_platform *wc_plat, - struct wcore_display *wc_display, - struct wcore_config *wc_config) -{ - EGLint gbm_format; - struct wegl_display *dpy = wegl_display(wc_display); - struct wegl_platform *plat = wegl_platform(wc_plat); - struct wegl_config *egl_config = wegl_config(wc_config); - bool ok = plat->eglGetConfigAttrib(dpy->egl, - egl_config->egl, - EGL_NATIVE_VISUAL_ID, - &gbm_format); - - if (!ok) { - return 0; - } - return gbm_format; -} - union waffle_native_config* wgbm_config_get_native(struct wcore_config *wc_config) { diff --git a/src/waffle/gbm/wgbm_config.h b/src/waffle/gbm/wgbm_config.h index 2c58321..6ee2cdd 100644 --- a/src/waffle/gbm/wgbm_config.h +++ b/src/waffle/gbm/wgbm_config.h @@ -34,15 +34,5 @@ union waffle_native_config; -struct wcore_config* -wgbm_config_choose(struct wcore_platform *wc_plat, - struct wcore_display *wc_dpy, - const struct wcore_config_attrs *attrs); - -uint32_t -wgbm_config_get_gbm_format(struct wcore_platform *wc_plat, - struct wcore_display *wc_dpy, - struct wcore_config *wc_config); - union waffle_native_config* wgbm_config_get_native(struct wcore_config *wc_config); diff --git a/src/waffle/gbm/wgbm_platform.c b/src/waffle/gbm/wgbm_platform.c index 0fc0352..5e36534 100644 --- a/src/waffle/gbm/wgbm_platform.c +++ b/src/waffle/gbm/wgbm_platform.c @@ -194,7 +194,7 @@ static const struct wcore_platform_vtbl wgbm_platform_vtbl = { }, .config = { - .choose = wgbm_config_choose, + .choose = wegl_config_choose, .destroy = wegl_config_destroy, .get_native = wgbm_config_get_native, }, diff --git a/src/waffle/gbm/wgbm_window.c b/src/waffle/gbm/wgbm_window.c index 313304b..d217992 100644 --- a/src/waffle/gbm/wgbm_window.c +++ b/src/waffle/gbm/wgbm_window.c @@ -67,7 +67,6 @@ wgbm_window_create(struct wcore_platform *wc_plat, struct wgbm_display *dpy = wgbm_display(wc_config->display); struct wgbm_platform *plat = wgbm_platform(wegl_platform(wc_plat)); struct wgbm_window *self; - uint32_t gbm_format; bool ok = true; if (width == -1 && height == -1) { @@ -85,11 +84,9 @@ wgbm_window_create(struct wcore_platform *wc_plat, if (self == NULL) return NULL; - gbm_format = wgbm_config_get_gbm_format(wc_plat, wc_config->display, - wc_config); - assert(gbm_format != 0); self->gbm_surface = plat->gbm_surface_create(dpy->gbm_device, - width, height, gbm_format, + width, height, + wegl_config(wc_config)->visual, GBM_BO_USE_RENDERING); if (!self->gbm_surface) { wcore_errorf(WAFFLE_ERROR_UNKNOWN, diff --git a/src/waffle/xegl/xegl_window.c b/src/waffle/xegl/xegl_window.c index cd2be46..e2b8b3d 100644 --- a/src/waffle/xegl/xegl_window.c +++ b/src/waffle/xegl/xegl_window.c @@ -63,8 +63,6 @@ xegl_window_create(struct wcore_platform *wc_plat, struct xegl_window *self; struct xegl_display *dpy = xegl_display(wc_config->display); struct wegl_config *config = wegl_config(wc_config); - struct wegl_platform *plat = wegl_platform(wc_plat); - xcb_visualid_t visual; bool ok = true; if (width == -1 && height == -1) { @@ -81,18 +79,9 @@ xegl_window_create(struct wcore_platform *wc_plat, if (self == NULL) return NULL; - ok = plat->eglGetConfigAttrib(dpy->wegl.egl, - config->egl, - EGL_NATIVE_VISUAL_ID, - (EGLint*) &visual); - if (!ok) { - wegl_emit_error(plat, "eglGetConfigAttrib(EGL_NATIVE_VISUAL_ID)"); - goto error; - } - ok = x11_window_init(&self->x11, &dpy->x11, - visual, + (xcb_visualid_t) config->visual, width, height); if (!ok) -- 2.6.2 _______________________________________________ waffle mailing list waffle@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/waffle