[PATCH 2/3] compositor: move scanout handling to compositor-drm

Jesse Barnes jbarnes at virtuousgeek.org
Wed Jan 25 14:00:33 PST 2012


Much of the scanout handling code is only used by the DRM compositor, so
move it over to make it easier to add the sprite handling changes.
---
 src/compositor-drm.c |   44 +++++++++++++++++++++++++++++++++++++++++++-
 src/compositor.c     |   30 +-----------------------------
 src/compositor.h     |    4 ++--
 3 files changed, 46 insertions(+), 32 deletions(-)

diff --git a/src/compositor-drm.c b/src/compositor-drm.c
index 1d8da77..2cab9d5 100644
--- a/src/compositor-drm.c
+++ b/src/compositor-drm.c
@@ -106,6 +106,47 @@ struct drm_sprite {
 	uint32_t formats[];
 };
 
+/**
+ * drm_queue_scanout_surface - add a surface to the pending output list
+ * @output: output using scanout surface
+ * @es: surface to queue
+ *
+ * When we queue a page flip, we need to make sure the buffer is marked
+ * busy until the flip completes.  Call this function to do that for
+ * buffers that will be flipped to.
+ */
+static int
+drm_queue_scanout_surface(struct weston_output *output,
+			  struct weston_surface *es)
+{
+	/* assert output->pending_scanout_buffer == NULL */
+	output->pending_scanout_buffer = es->buffer;
+	output->pending_scanout_buffer->busy_count++;
+
+	wl_list_insert(output->pending_scanout_buffer->resource.destroy_listener_list.prev,
+		       &output->pending_scanout_buffer_destroy_listener.link);
+
+	return 0;
+}
+
+static void
+drm_dequeue_scanout_surface(struct weston_output *output)
+{
+	if (output->scanout_buffer) {
+		weston_buffer_post_release(output->scanout_buffer);
+		wl_list_remove(&output->scanout_buffer_destroy_listener.link);
+		output->scanout_buffer = NULL;
+	}
+
+	if (output->pending_scanout_buffer) {
+		output->scanout_buffer = output->pending_scanout_buffer;
+		wl_list_remove(&output->pending_scanout_buffer_destroy_listener.link);
+		wl_list_insert(output->scanout_buffer->resource.destroy_listener_list.prev,
+			       &output->scanout_buffer_destroy_listener.link);
+		output->pending_scanout_buffer = NULL;
+	}
+}
+
 static int
 drm_output_prepare_render(struct weston_output *output_base)
 {
@@ -169,6 +210,7 @@ page_flip_handler(int fd, unsigned int frame,
 		output->pending_fs_surf_fb_id = 0;
 	}
 
+	drm_dequeue_scanout_surface(&output->base);
 	msecs = sec * 1000 + usec / 1000;
 	weston_output_finish_frame(&output->base, msecs);
 }
@@ -289,7 +331,7 @@ drm_assign_planes(struct weston_output *output)
 
 	if (es->visual == WESTON_RGB_VISUAL) {
 		if (!drm_output_prepare_scanout_surface(output, es)) {
-			weston_queue_scanout_surface(output, es);
+			drm_queue_scanout_surface(output, es);
 			scanout = es;
 		}
 	}
diff --git a/src/compositor.c b/src/compositor.c
index f328f55..51038fa 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -633,7 +633,7 @@ weston_compositor_damage_all(struct weston_compositor *compositor)
 		weston_output_damage(output);
 }
 
-static inline void
+WL_EXPORT void
 weston_buffer_post_release(struct wl_buffer *buffer)
 {
 	if (--buffer->busy_count > 0)
@@ -762,20 +762,6 @@ out:
 	pixman_region32_fini(&cursor_region);
 }
 
-WL_EXPORT int
-weston_queue_scanout_surface(struct weston_output *output,
-			     struct weston_surface *es)
-{
-	/* assert output->pending_scanout_buffer == NULL */
-	output->pending_scanout_buffer = es->buffer;
-	output->pending_scanout_buffer->busy_count++;
-
-	wl_list_insert(output->pending_scanout_buffer->resource.destroy_listener_list.prev,
-		       &output->pending_scanout_buffer_destroy_listener.link);
-
-	return 0;
-}
-
 WL_EXPORT void
 weston_output_repaint(struct weston_output *output)
 {
@@ -884,20 +870,6 @@ idle_repaint(void *data)
 WL_EXPORT void
 weston_output_finish_frame(struct weston_output *output, int msecs)
 {
-	if (output->scanout_buffer) {
-		weston_buffer_post_release(output->scanout_buffer);
-		wl_list_remove(&output->scanout_buffer_destroy_listener.link);
-		output->scanout_buffer = NULL;
-	}
-
-	if (output->pending_scanout_buffer) {
-		output->scanout_buffer = output->pending_scanout_buffer;
-		wl_list_remove(&output->pending_scanout_buffer_destroy_listener.link);
-		wl_list_insert(output->scanout_buffer->resource.destroy_listener_list.prev,
-			       &output->scanout_buffer_destroy_listener.link);
-		output->pending_scanout_buffer = NULL;
-	}
-
 	if (output->repaint_needed)
 		repaint(output, msecs);
 	else
diff --git a/src/compositor.h b/src/compositor.h
index 031d094..759937b 100644
--- a/src/compositor.h
+++ b/src/compositor.h
@@ -448,6 +448,6 @@ typedef	void (*weston_zoom_done_func_t)(struct weston_zoom *zoom, void *data);
 struct weston_zoom *
 weston_zoom_run(struct weston_surface *surface, GLfloat start, GLfloat stop,
 		weston_zoom_done_func_t done, void *data);
-int weston_queue_scanout_surface(struct weston_output *output,
-				 struct weston_surface *es);
+void weston_buffer_post_release(struct wl_buffer *buffer);
+
 #endif
-- 
1.7.4.1



More information about the wayland-devel mailing list