rpi: Remove create_view and destroy_view implementations
authorTomeu Vizoso <tomeu@tomeuvizoso.net>
Mon, 28 Oct 2013 09:17:45 +0000 (10:17 +0100)
committerKristian Høgsberg <krh@bitplanet.net>
Mon, 28 Oct 2013 21:36:26 +0000 (14:36 -0700)
And also remove the vfunc definitions from the compositor as they
are unused now.

configure.ac
src/compositor.c
src/compositor.h
src/rpi-renderer.c

index 93213d4..84f3a79 100644 (file)
@@ -55,7 +55,7 @@ AC_CHECK_HEADERS([execinfo.h])
 
 AC_CHECK_FUNCS([mkostemp strchrnul initgroups])
 
-COMPOSITOR_MODULES="wayland-server >= 1.3.91 pixman-1"
+COMPOSITOR_MODULES="wayland-server >= 1.3.90 pixman-1"
 
 AC_ARG_ENABLE(egl, [  --disable-egl],,
               enable_egl=yes)
index 563bade..31c01c5 100644 (file)
@@ -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);
 
@@ -1204,9 +1198,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);
index e60a512..1b94764 100644 (file)
@@ -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);
 };
 
index b7e9487..8fb562d 100644 (file)
@@ -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 void
+rpir_view_handle_view_destroy(struct wl_listener *listener, void *data);
+
 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