gl-renderer: remove EGLConfig attributes from API
authorPekka Paalanen <pekka.paalanen@collabora.com>
Mon, 30 Sep 2019 12:43:07 +0000 (15:43 +0300)
committerPekka Paalanen <pekka.paalanen@collabora.com>
Fri, 4 Oct 2019 09:17:18 +0000 (12:17 +0300)
Now that all backends pass in a list of acceptable DRM formats, that is used to
determine if the EGLConfig has an alpha channel or not. Therefore the
opaque_attribs and alpha_attribs are now useless, and we can remove the whole
config_attribs argument from the API.

gl_renderer_get_egl_config() uses an internal attrib list that matches at least
the union of the opaque_attribs and alpha_attribs matches.

Overall, behaviour should remain unchanged.

The new attribute array becomes variable in the future, so it is left
non-const.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
libweston/backend-drm/drm.c
libweston/backend-wayland/wayland.c
libweston/backend-x11/x11.c
libweston/renderer-gl/egl-glue.c
libweston/renderer-gl/gl-renderer-internal.h
libweston/renderer-gl/gl-renderer.c
libweston/renderer-gl/gl-renderer.h

index fe01103d15d3d08b1bcfec6f4dec2373520654b4..24f64128f93869708756761678712c6a6346c308 100644 (file)
@@ -747,7 +747,6 @@ drm_backend_create_gl_renderer(struct drm_backend *b)
        if (gl_renderer->display_create(b->compositor,
                                        EGL_PLATFORM_GBM_KHR,
                                        (void *)b->gbm,
-                                       gl_renderer->opaque_attribs,
                                        format,
                                        n_formats) < 0) {
                return -1;
@@ -1393,7 +1392,6 @@ drm_output_init_egl(struct drm_output *output, struct drm_backend *b)
        if (gl_renderer->output_window_create(&output->base,
                                              (EGLNativeWindowType)output->gbm_surface,
                                              output->gbm_surface,
-                                             gl_renderer->opaque_attribs,
                                              format,
                                              n_formats) < 0) {
                weston_log("failed to create gl renderer output state\n");
index d5a60bcf0144f7641f5cb2001a80a05a61151f6b..22a4342f6dd83b0f5e66eccc7c0ea339d869f363 100644 (file)
@@ -779,7 +779,6 @@ wayland_output_init_gl_renderer(struct wayland_output *output)
        if (gl_renderer->output_window_create(&output->base,
                                              output->gl.egl_window,
                                              output->gl.egl_window,
-                                             gl_renderer->alpha_attribs,
                                              wayland_formats,
                                              ARRAY_LENGTH(wayland_formats)) < 0)
                goto cleanup_window;
@@ -2774,7 +2773,6 @@ wayland_backend_create(struct weston_compositor *compositor,
                if (gl_renderer->display_create(compositor,
                                                EGL_PLATFORM_WAYLAND_KHR,
                                                b->parent.wl_display,
-                                               gl_renderer->alpha_attribs,
                                                wayland_formats,
                                                ARRAY_LENGTH(wayland_formats)) < 0) {
                        weston_log("Failed to initialize the GL renderer; "
index 5498aba3e6394acd39256dad13a071490c2fb746..778f1df38a437ba47504680aa96e3c623b9216c8 100644 (file)
@@ -870,7 +870,6 @@ x11_output_switch_mode(struct weston_output *base, struct weston_mode *mode)
                ret = gl_renderer->output_window_create(&output->base,
                                                        (EGLNativeWindowType) output->window,
                                                        &xid,
-                                                       gl_renderer->opaque_attribs,
                                                        x11_formats,
                                                        ARRAY_LENGTH(x11_formats));
                if (ret < 0)
@@ -1046,7 +1045,6 @@ x11_output_enable(struct weston_output *base)
                                        &output->base,
                                        (EGLNativeWindowType) output->window,
                                        &xid,
-                                       gl_renderer->opaque_attribs,
                                        x11_formats,
                                        ARRAY_LENGTH(x11_formats));
                if (ret < 0)
@@ -1815,7 +1813,6 @@ init_gl_renderer(struct x11_backend *b)
 
        ret = gl_renderer->display_create(b->compositor, EGL_PLATFORM_X11_KHR,
                                          (void *) b->dpy,
-                                         gl_renderer->opaque_attribs,
                                          x11_formats,
                                          ARRAY_LENGTH(x11_formats));
 
index 918523e5c8ed300e3f5e45149e0627d32b6dd52c..5b1ba32daff2a707d13263d631e4e81c4a37913b 100644 (file)
@@ -187,7 +187,6 @@ out:
 
 EGLConfig
 gl_renderer_get_egl_config(struct gl_renderer *gr,
-                          const EGLint *config_attribs,
                           const uint32_t *drm_formats,
                           unsigned drm_formats_count)
 {
@@ -195,6 +194,14 @@ gl_renderer_get_egl_config(struct gl_renderer *gr,
        const struct pixel_format_info *pinfo[16];
        unsigned pinfo_count;
        unsigned i;
+       EGLint config_attribs[] = {
+               EGL_SURFACE_TYPE,    EGL_WINDOW_BIT,
+               EGL_RED_SIZE,        1,
+               EGL_GREEN_SIZE,      1,
+               EGL_BLUE_SIZE,       1,
+               EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
+               EGL_NONE
+       };
 
        assert(drm_formats_count < ARRAY_LENGTH(pinfo));
        drm_formats_count = MIN(drm_formats_count, ARRAY_LENGTH(pinfo));
index 07e29144c84590c9188689f81ddd87ed8a3013f0..511fd1850fb8bc050d35f9860ab693aa51a4a894 100644 (file)
@@ -138,7 +138,6 @@ egl_choose_config(struct gl_renderer *gr,
 
 EGLConfig
 gl_renderer_get_egl_config(struct gl_renderer *gr,
-                          const EGLint *config_attribs,
                           const uint32_t *drm_formats,
                           unsigned drm_formats_count);
 
index 0d55c9302caccd9a5d7c9d4109cdd64da1cabf3c..c8981c34fb59ad2aecf60af186af233992815efb 100644 (file)
@@ -3061,14 +3061,13 @@ static EGLSurface
 gl_renderer_create_window_surface(struct gl_renderer *gr,
                                  EGLNativeWindowType window_for_legacy,
                                  void *window_for_platform,
-                                 const EGLint *config_attribs,
                                  const uint32_t *drm_formats,
                                  unsigned drm_formats_count)
 {
        EGLSurface egl_surface = EGL_NO_SURFACE;
        EGLConfig egl_config;
 
-       egl_config = gl_renderer_get_egl_config(gr, config_attribs,
+       egl_config = gl_renderer_get_egl_config(gr,
                                                drm_formats, drm_formats_count);
        if (egl_config == EGL_NO_CONFIG_KHR)
                return EGL_NO_SURFACE;
@@ -3118,7 +3117,6 @@ static int
 gl_renderer_output_window_create(struct weston_output *output,
                                 EGLNativeWindowType window_for_legacy,
                                 void *window_for_platform,
-                                const EGLint *config_attribs,
                                 const uint32_t *drm_formats,
                                 unsigned drm_formats_count)
 {
@@ -3130,7 +3128,6 @@ gl_renderer_output_window_create(struct weston_output *output,
        egl_surface = gl_renderer_create_window_surface(gr,
                                                        window_for_legacy,
                                                        window_for_platform,
-                                                       config_attribs,
                                                        drm_formats,
                                                        drm_formats_count);
        if (egl_surface == EGL_NO_SURFACE) {
@@ -3234,27 +3231,6 @@ gl_renderer_destroy(struct weston_compositor *ec)
        free(gr);
 }
 
-static const EGLint gl_renderer_opaque_attribs[] = {
-       EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
-       EGL_RED_SIZE, 1,
-       EGL_GREEN_SIZE, 1,
-       EGL_BLUE_SIZE, 1,
-       EGL_ALPHA_SIZE, 0,
-       EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
-       EGL_NONE
-};
-
-static const EGLint gl_renderer_alpha_attribs[] = {
-       EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
-       EGL_RED_SIZE, 1,
-       EGL_GREEN_SIZE, 1,
-       EGL_BLUE_SIZE, 1,
-       EGL_ALPHA_SIZE, 1,
-       EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
-       EGL_NONE
-};
-
-
 /** Checks whether a platform EGL client extension is supported
  *
  * \param ec The weston compositor
@@ -3387,7 +3363,6 @@ static int
 gl_renderer_display_create(struct weston_compositor *ec,
                           EGLenum platform,
                           void *native_display,
-                          const EGLint *config_attribs,
                           const uint32_t *drm_formats,
                           unsigned drm_formats_count)
 {
@@ -3461,7 +3436,7 @@ gl_renderer_display_create(struct weston_compositor *ec,
                goto fail_with_error;
 
        if (!gr->has_configless_context) {
-               gr->egl_config = gl_renderer_get_egl_config(gr, config_attribs,
+               gr->egl_config = gl_renderer_get_egl_config(gr,
                                                            drm_formats,
                                                            drm_formats_count);
                if (gr->egl_config == EGL_NO_CONFIG_KHR) {
@@ -3749,9 +3724,6 @@ gl_renderer_setup(struct weston_compositor *ec, EGLSurface egl_surface)
 }
 
 WL_EXPORT struct gl_renderer_interface gl_renderer_interface = {
-       .opaque_attribs = gl_renderer_opaque_attribs,
-       .alpha_attribs = gl_renderer_alpha_attribs,
-
        .display_create = gl_renderer_display_create,
        .output_window_create = gl_renderer_output_window_create,
        .output_destroy = gl_renderer_output_destroy,
index e5cff24d00fe804de93b351b9050a11ee5cf0708..8a26ac66a6e68ac4286ea04ff8f3e6f272861fda 100644 (file)
@@ -57,20 +57,15 @@ enum gl_renderer_border_side {
 };
 
 struct gl_renderer_interface {
-       const EGLint *opaque_attribs;
-       const EGLint *alpha_attribs;
-
        int (*display_create)(struct weston_compositor *ec,
                              EGLenum platform,
                              void *native_display,
-                             const EGLint *config_attribs,
                              const uint32_t *drm_formats,
                              unsigned drm_formats_count);
 
        int (*output_window_create)(struct weston_output *output,
                                    EGLNativeWindowType window_for_legacy,
                                    void *window_for_platform,
-                                   const EGLint *config_attribs,
                                    const uint32_t *drm_formats,
                                    unsigned drm_formats_count);