[Cogl] [PATCH 2/4] Implicitly allocate on cogl_wayland_onscreen_get_(shell_)?surface

Neil Roberts neil at linux.intel.com
Thu Jul 4 05:45:59 PDT 2013


The idea with the framebuffer allocation is that it will lazily
allocate so that if you don't want to handle errors then you don't
have to be aware that there is an allocation step. In order for this
to work any accessors that get data that is only available after
allocation should implicitly allocate the framebuffer. This patch
makes that change for cogl_wayland_onscreen_get_surface and
cogl_wayland_onscreen_get_shell_surface.
---
 cogl/winsys/cogl-winsys-egl-wayland.c | 36 ++++++++++++++++-------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/cogl/winsys/cogl-winsys-egl-wayland.c b/cogl/winsys/cogl-winsys-egl-wayland.c
index 0727bbc..0af2cfb 100644
--- a/cogl/winsys/cogl-winsys-egl-wayland.c
+++ b/cogl/winsys/cogl-winsys-egl-wayland.c
@@ -633,33 +633,29 @@ cogl_wayland_renderer_get_shell (CoglRenderer *renderer)
 struct wl_surface *
 cogl_wayland_onscreen_get_surface (CoglOnscreen *onscreen)
 {
-  CoglFramebuffer *fb;
+  CoglOnscreenEGL *egl_onscreen;
+  CoglOnscreenWayland *wayland_onscreen;
 
-  fb = COGL_FRAMEBUFFER (onscreen);
-  if (fb->allocated)
-    {
-      CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
-      CoglOnscreenWayland *wayland_onscreen = egl_onscreen->platform;
-      return wayland_onscreen->wayland_surface;
-    }
-  else
-    return NULL;
+  cogl_framebuffer_allocate (COGL_FRAMEBUFFER (onscreen), NULL);
+
+  egl_onscreen = onscreen->winsys;
+  wayland_onscreen = egl_onscreen->platform;
+
+  return wayland_onscreen->wayland_surface;
 }
 
 struct wl_shell_surface *
 cogl_wayland_onscreen_get_shell_surface (CoglOnscreen *onscreen)
 {
-  CoglFramebuffer *fb;
+  CoglOnscreenEGL *egl_onscreen;
+  CoglOnscreenWayland *wayland_onscreen;
 
-  fb = COGL_FRAMEBUFFER (onscreen);
-  if (fb->allocated)
-    {
-      CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
-      CoglOnscreenWayland *wayland_onscreen = egl_onscreen->platform;
-      return wayland_onscreen->wayland_shell_surface;
-    }
-  else
-    return NULL;
+  cogl_framebuffer_allocate (COGL_FRAMEBUFFER (onscreen), NULL);
+
+  egl_onscreen = onscreen->winsys;
+  wayland_onscreen = egl_onscreen->platform;
+
+  return wayland_onscreen->wayland_shell_surface;
 }
 
 void
-- 
1.7.11.3.g3c3efa5



More information about the Cogl mailing list