[PATCH 5/6] window: Clean up buffer type choosing

Jasper St. Pierre jstpierre at mecheye.net
Mon Apr 28 08:19:31 PDT 2014


Extracting it to a function makes this cleaner and more
understandable.
---
 clients/window.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/clients/window.c b/clients/window.c
index e2f7010..d822af7 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -4338,6 +4338,17 @@ surface_create(struct window *window)
 	return surface;
 }
 
+static window_buffer_type
+get_preferred_buffer_type(struct display *display)
+{
+#ifdef HAVE_CAIRO_EGL
+	if (display->argb_device)
+		return WINDOW_BUFFER_TYPE_EGL_WINDOW;
+#endif
+
+	return WINDOW_BUFFER_TYPE_SHM;
+}
+
 static struct window *
 window_create_internal(struct display *display, int custom)
 {
@@ -4356,14 +4367,7 @@ window_create_internal(struct display *display, int custom)
 	window->custom = custom;
 	window->preferred_format = WINDOW_PREFERRED_FORMAT_NONE;
 
-	if (display->argb_device)
-#ifdef HAVE_CAIRO_EGL
-		surface->buffer_type = WINDOW_BUFFER_TYPE_EGL_WINDOW;
-#else
-		surface->buffer_type = WINDOW_BUFFER_TYPE_SHM;
-#endif
-	else
-		surface->buffer_type = WINDOW_BUFFER_TYPE_SHM;
+	surface->buffer_type = get_preferred_buffer_type(display);
 
 	wl_surface_set_user_data(surface->surface, window);
 	wl_list_insert(display->window_list.prev, &window->link);
-- 
1.9.0



More information about the wayland-devel mailing list