[PATCH weston 4/5] window: merge struct surface_data into shm_surface_data

Pekka Paalanen ppaalanen at gmail.com
Mon Nov 19 05:32:50 PST 2012


Struct surface_data was not really useful, and it definitely was not
used with EGL-based windows.

This also fixes a semantic mistake, where struct shm_surface_data was
put into cairo_surface_t private, but got out as struct surface_data
instead. Due to struct layout, however, this did not cause a real bug.

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

diff --git a/clients/window.c b/clients/window.c
index 16dc801..18bacfc 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -347,9 +347,6 @@ enum window_location {
 };
 
 static const cairo_user_data_key_t surface_data_key;
-struct surface_data {
-	struct wl_buffer *buffer;
-};
 
 #ifdef HAVE_CAIRO_EGL
 
@@ -414,22 +411,22 @@ display_create_egl_window_surface(struct display *display,
 
 #endif
 
+struct shm_surface_data {
+	struct wl_buffer *buffer;
+	struct shm_pool *pool;
+};
+
 struct wl_buffer *
 display_get_buffer_for_surface(struct display *display,
 			       cairo_surface_t *surface)
 {
-	struct surface_data *data;
+	struct shm_surface_data *data;
 
 	data = cairo_surface_get_user_data (surface, &surface_data_key);
 
 	return data->buffer;
 }
 
-struct shm_surface_data {
-	struct surface_data data;
-	struct shm_pool *pool;
-};
-
 static void
 shm_pool_destroy(struct shm_pool *pool);
 
@@ -438,7 +435,7 @@ shm_surface_data_destroy(void *p)
 {
 	struct shm_surface_data *data = p;
 
-	wl_buffer_destroy(data->data.buffer);
+	wl_buffer_destroy(data->buffer);
 	if (data->pool)
 		shm_pool_destroy(data->pool);
 
@@ -570,10 +567,10 @@ display_create_shm_surface_from_pool(struct display *display,
 	else
 		format = WL_SHM_FORMAT_ARGB8888;
 
-	data->data.buffer = wl_shm_pool_create_buffer(pool->pool, offset,
-						      rectangle->width,
-						      rectangle->height,
-						      stride, format);
+	data->buffer = wl_shm_pool_create_buffer(pool->pool, offset,
+						 rectangle->width,
+						 rectangle->height,
+						 stride, format);
 
 	return surface;
 }
-- 
1.7.8.6



More information about the wayland-devel mailing list