[PATCH weston 4/6] window: simplify window_create_surface

Pekka Paalanen ppaalanen at gmail.com
Mon Nov 19 07:16:00 PST 2012


Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
---
 clients/window.c |   43 ++++++++++++++++++++++++-------------------
 1 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index a8c3e3a..a15ac2a 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -494,6 +494,9 @@ egl_window_surface_create(struct display *display,
 {
 	struct egl_window_surface *surface;
 
+	if (display->dpy == EGL_NO_DISPLAY)
+		return NULL;
+
 	surface = calloc(1, sizeof *surface);
 	if (!surface)
 		return NULL;
@@ -525,6 +528,17 @@ egl_window_surface_create(struct display *display,
 	return &surface->base;
 }
 
+#else
+
+static struct toysurface *
+egl_window_surface_create(struct display *display,
+			  struct wl_surface *wl_surface,
+			  uint32_t flags,
+			  struct rectangle *rectangle)
+{
+	return NULL;
+}
+
 #endif
 
 struct shm_surface_data {
@@ -1130,28 +1144,19 @@ window_create_surface(struct window *window)
 	if (!window->transparent)
 		flags = SURFACE_OPAQUE;
 
-	switch (window->buffer_type) {
-#ifdef HAVE_CAIRO_EGL
-	case WINDOW_BUFFER_TYPE_EGL_WINDOW:
-		if (!window->toysurface && window->display->dpy)
-			window->toysurface =
-				egl_window_surface_create(window->display,
-							  window->surface,
-							  flags,
-							  &window->allocation);
-
-		if (window->toysurface)
-			break;
-		/* fall through */
-#endif
-	case WINDOW_BUFFER_TYPE_SHM:
+	if (!window->toysurface &&
+	    window->buffer_type == WINDOW_BUFFER_TYPE_EGL_WINDOW &&
+	    window->display->dpy) {
+		window->toysurface =
+			egl_window_surface_create(window->display,
+						  window->surface, flags,
+						  &window->allocation);
+	}
+
+	if (!window->toysurface)
 		window->toysurface = shm_surface_create(window->display,
 							window->surface, flags,
 							&window->allocation);
-		break;
-	default:
-		assert(0);
-	}
 
 	window_get_resize_dx_dy(window, &dx, &dy);
 	window->cairo_surface =
-- 
1.7.8.6



More information about the wayland-devel mailing list