[PATCH] rpi: Remove create_view and destroy_view implementations

Tomeu Vizoso tomeu at tomeuvizoso.net
Mon Oct 28 10:17:45 CET 2013


And also remove the vfunc definitions from the compositor as they
are unused now.
---
 src/compositor.c   |  9 ---------
 src/compositor.h   |  2 --
 src/rpi-renderer.c | 29 ++++++++++++++++++++++++-----
 3 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/src/compositor.c b/src/compositor.c
index 65e9bfb..c2b7655 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -358,12 +358,6 @@ weston_view_create(struct weston_surface *surface)
 
 	view->surface = surface;
 
-	if (surface->compositor->renderer->create_view &&
-	    surface->compositor->renderer->create_view(view) < 0) {
-		free(view);
-		return NULL;
-	}
-
 	/* Assign to surface */
 	wl_list_insert(&surface->views, &view->surface_link);
 
@@ -1205,9 +1199,6 @@ weston_view_destroy(struct weston_view *view)
 
 	weston_view_set_transform_parent(view, NULL);
 
-	if (view->surface->compositor->renderer->destroy_view)
-		view->surface->compositor->renderer->destroy_view(view);
-
 	wl_list_remove(&view->surface_link);
 
 	free(view);
diff --git a/src/compositor.h b/src/compositor.h
index e60a512..1b94764 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -521,11 +521,9 @@ struct weston_renderer {
 			       pixman_region32_t *output_damage);
 	void (*flush_damage)(struct weston_surface *surface);
 	void (*attach)(struct weston_surface *es, struct weston_buffer *buffer);
-	int (*create_view)(struct weston_view *view);
 	void (*surface_set_color)(struct weston_surface *surface,
 			       float red, float green,
 			       float blue, float alpha);
-	void (*destroy_view)(struct weston_view *view);
 	void (*destroy)(struct weston_compositor *ec);
 };
 
diff --git a/src/rpi-renderer.c b/src/rpi-renderer.c
index b7e9487..6f7e1e9 100644
--- a/src/rpi-renderer.c
+++ b/src/rpi-renderer.c
@@ -136,6 +136,8 @@ struct rpir_view {
 
 	DISPMANX_ELEMENT_HANDLE_T handle;
 	int layer;
+
+	struct wl_listener view_destroy_listener;
 };
 
 struct rpir_output {
@@ -172,6 +174,12 @@ struct rpi_renderer {
 static int
 rpi_renderer_create_surface(struct weston_surface *base);
 
+static int
+rpi_renderer_create_view(struct weston_view *base);
+
+static int
+rpir_view_handle_view_destroy(struct weston_view *base);
+
 static inline struct rpir_surface *
 to_rpir_surface(struct weston_surface *surface)
 {
@@ -184,6 +192,9 @@ to_rpir_surface(struct weston_surface *surface)
 static inline struct rpir_view *
 to_rpir_view(struct weston_view *view)
 {
+	if (!view->renderer_state)
+		rpi_renderer_create_view(view);
+
 	return view->renderer_state;
 }
 
@@ -1477,6 +1488,12 @@ rpi_renderer_create_view(struct weston_view *base)
 
 	view->view = base;
 	base->renderer_state = view;
+
+	view->view_destroy_listener.notify =
+		rpir_view_handle_view_destroy;
+	wl_signal_add(&base->destroy_signal,
+		      &view->view_destroy_listener);
+
 	return 0;
 }
 
@@ -1522,9 +1539,12 @@ rpi_renderer_surface_set_color(struct weston_surface *base,
 }
 
 static void
-rpi_renderer_destroy_view(struct weston_view *base)
+rpir_view_handle_view_destroy(struct wl_listener *listener, void *data)
 {
-	struct rpir_view *view = to_rpir_view(base);
+	struct rpir_view *view;
+	struct weston_view *base = data;
+
+	view = container_of(listener, struct rpir_view, view_destroy_listener);
 
 	assert(view);
 	assert(view->view == base);
@@ -1532,8 +1552,9 @@ rpi_renderer_destroy_view(struct weston_view *base)
 		return;
 
 	view->view = NULL;
+	base->renderer_state = NULL;
 
-	/* If guaranteed to not be on screen, just detroy it. */
+	/* If guaranteed to not be on screen, just destroy it. */
 	if (wl_list_empty(&view->link))
 		rpir_view_destroy(view);
 
@@ -1582,9 +1603,7 @@ rpi_renderer_create(struct weston_compositor *compositor,
 	renderer->base.repaint_output = rpi_renderer_repaint_output;
 	renderer->base.flush_damage = rpi_renderer_flush_damage;
 	renderer->base.attach = rpi_renderer_attach;
-	renderer->base.create_view = rpi_renderer_create_view;
 	renderer->base.surface_set_color = rpi_renderer_surface_set_color;
-	renderer->base.destroy_view = rpi_renderer_destroy_view;
 	renderer->base.destroy = rpi_renderer_destroy;
 
 #ifdef ENABLE_EGL
-- 
1.8.3.1



More information about the wayland-devel mailing list