[mutter] cogl: Make platforms set the EGL_SURFACE_TYPE



commit 8f716772c221331b86a4f7395f59b0dbd48beb8c
Author: Jonas Ådahl <jadahl gmail com>
Date:   Mon Sep 26 15:54:27 2016 +0800

    cogl: Make platforms set the EGL_SURFACE_TYPE
    
    Cogl has no way to know how to properly set the surface type, so lets
    outsource that to the platform layer.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=773629

 cogl/cogl/winsys/cogl-winsys-egl-x11.c     |   14 ++++++++++++++
 cogl/cogl/winsys/cogl-winsys-egl.c         |   13 +++++--------
 src/backends/native/meta-renderer-native.c |   14 ++++++++++++++
 3 files changed, 33 insertions(+), 8 deletions(-)
---
diff --git a/cogl/cogl/winsys/cogl-winsys-egl-x11.c b/cogl/cogl/winsys/cogl-winsys-egl-x11.c
index 454b41e..b7e4e62 100644
--- a/cogl/cogl/winsys/cogl-winsys-egl-x11.c
+++ b/cogl/cogl/winsys/cogl-winsys-egl-x11.c
@@ -290,6 +290,19 @@ error:
   return FALSE;
 }
 
+static int
+_cogl_winsys_egl_add_config_attributes (CoglDisplay *display,
+                                        CoglFramebufferConfig *config,
+                                        EGLint *attributes)
+{
+  int i = 0;
+
+  attributes[i++] = EGL_SURFACE_TYPE;
+  attributes[i++] = EGL_WINDOW_BIT;
+
+  return i;
+}
+
 static CoglBool
 _cogl_winsys_egl_display_setup (CoglDisplay *display,
                                 CoglError **error)
@@ -794,6 +807,7 @@ _cogl_winsys_texture_pixmap_x11_get_texture (CoglTexturePixmapX11 *tex_pixmap,
 static const CoglWinsysEGLVtable
 _cogl_winsys_egl_vtable =
   {
+    .add_config_attributes = _cogl_winsys_egl_add_config_attributes,
     .display_setup = _cogl_winsys_egl_display_setup,
     .display_destroy = _cogl_winsys_egl_display_destroy,
     .context_created = _cogl_winsys_egl_context_created,
diff --git a/cogl/cogl/winsys/cogl-winsys-egl.c b/cogl/cogl/winsys/cogl-winsys-egl.c
index dbf14f6..8f2bcc7 100644
--- a/cogl/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/cogl/winsys/cogl-winsys-egl.c
@@ -233,11 +233,11 @@ egl_attributes_from_framebuffer_config (CoglDisplay *display,
   CoglRendererEGL *egl_renderer = renderer->winsys;
   int i = 0;
 
-  /* Let the platform add attributes first */
-  if (egl_renderer->platform_vtable->add_config_attributes)
-    i = egl_renderer->platform_vtable->add_config_attributes (display,
-                                                              config,
-                                                              attributes);
+  /* Let the platform add attributes first, including setting the
+   * EGL_SURFACE_TYPE */
+  i = egl_renderer->platform_vtable->add_config_attributes (display,
+                                                            config,
+                                                            attributes);
 
   if (config->need_stencil)
     {
@@ -269,9 +269,6 @@ egl_attributes_from_framebuffer_config (CoglDisplay *display,
                      EGL_OPENGL_ES_BIT :
                      EGL_OPENGL_ES2_BIT);
 
-  attributes[i++] = EGL_SURFACE_TYPE;
-  attributes[i++] = EGL_WINDOW_BIT;
-
   if (config->samples_per_pixel)
     {
        attributes[i++] = EGL_SAMPLE_BUFFERS;
diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c
index e292431..8a46dc4 100644
--- a/src/backends/native/meta-renderer-native.c
+++ b/src/backends/native/meta-renderer-native.c
@@ -258,6 +258,19 @@ fail:
   return FALSE;
 }
 
+static int
+meta_renderer_native_add_egl_config_attributes (CoglDisplay           *cogl_display,
+                                                CoglFramebufferConfig *config,
+                                                EGLint                *attributes)
+{
+  int i = 0;
+
+  attributes[i++] = EGL_SURFACE_TYPE;
+  attributes[i++] = EGL_WINDOW_BIT;
+
+  return i;
+}
+
 static gboolean
 meta_renderer_native_setup_egl_display (CoglDisplay *cogl_display,
                                         GError     **error)
@@ -807,6 +820,7 @@ meta_renderer_native_release_onscreen (CoglOnscreen *onscreen)
 
 static const CoglWinsysEGLVtable
 _cogl_winsys_egl_vtable = {
+  .add_config_attributes = meta_renderer_native_add_egl_config_attributes,
   .display_setup = meta_renderer_native_setup_egl_display,
   .display_destroy = meta_renderer_native_destroy_egl_display,
   .context_created = meta_renderer_native_egl_context_created,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]