[PATCH weston 38/68] compositor-drm: Split repaint into helper

Daniel Stone daniels at collabora.com
Fri Dec 9 19:57:53 UTC 2016


We can separate repainting into two phases: one performing the actual
repaint (essentially drm_output_render) and populating the plane state
that wasn't already populated by drm_output_assign_planes, and another
applying this state to the device.

Differential Revision: https://phabricator.freedesktop.org/D1500

Signed-off-by: Daniel Stone <daniels at collabora.com>
---
 libweston/compositor-drm.c | 58 +++++++++++++++++++++++++++++-----------------
 1 file changed, 37 insertions(+), 21 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index f0a13e1..f1f9bcb 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -1527,12 +1527,10 @@ drm_waitvblank_pipe(struct drm_output *output)
 }
 
 static int
-drm_output_repaint(struct weston_output *output_base,
-		   pixman_region32_t *damage)
+drm_output_apply_state(struct drm_output_state *state)
 {
-	struct drm_output *output = to_drm_output(output_base);
-	struct drm_backend *backend =
-		to_drm_backend(output->base.compositor);
+	struct drm_output *output = state->output;
+	struct drm_backend *backend = to_drm_backend(output->base.compositor);
 	struct drm_plane *scanout_plane = output->scanout_plane;
 	struct drm_plane_state *scanout_state;
 	struct drm_plane_state *ps;
@@ -1540,20 +1538,7 @@ drm_output_repaint(struct weston_output *output_base,
 	struct drm_mode *mode;
 	int ret = 0;
 
-	if (output->disable_pending || output->destroy_pending)
-		goto err;
-
-	assert(!output->state_last);
-	if (!output->state_pending)
-		output->state_pending =
-			drm_output_state_duplicate(output->state_cur,
-						   DRM_OUTPUT_STATE_CLEAR_PLANES);
-
-	drm_output_render(output, damage);
-	scanout_state = drm_output_state_get_plane(output->state_pending,
-						   scanout_plane);
-	if (!scanout_state || !scanout_state->fb)
-		goto err;
+	scanout_state = drm_output_state_get_plane(state, scanout_plane);
 
 	/* The legacy SetCrtc API doesn't allow us to do scaling, and the
 	 * legacy PageFlip API doesn't allow us to do clipping either. */
@@ -1580,7 +1565,7 @@ drm_output_repaint(struct weston_output *output_base,
 			weston_log("set mode failed: %m\n");
 			goto err;
 		}
-		output_base->set_dpms(output_base, WESTON_DPMS_ON);
+		output->base.set_dpms(&output->base, WESTON_DPMS_ON);
 	}
 
 	if (drmModePageFlip(backend->drm.fd, output->crtc_id,
@@ -1592,7 +1577,7 @@ drm_output_repaint(struct weston_output *output_base,
 
 	assert(!output->page_flip_pending);
 
-	drm_output_set_cursor(output->state_pending);
+	drm_output_set_cursor(state);
 
 	/*
 	 * Now, update all the sprite surfaces
@@ -1655,6 +1640,37 @@ err:
 	return -1;
 }
 
+static int
+drm_output_repaint(struct weston_output *output_base,
+		   pixman_region32_t *damage)
+{
+	struct drm_output *output = to_drm_output(output_base);
+	struct drm_plane_state *scanout_state;
+
+	if (output->disable_pending || output->destroy_pending)
+		goto err;
+
+	assert(!output->state_last);
+	if (!output->state_pending)
+		output->state_pending =
+			drm_output_state_duplicate(output->state_cur,
+						   DRM_OUTPUT_STATE_CLEAR_PLANES);
+
+	drm_output_render(output, damage);
+	scanout_state = drm_output_state_get_plane(output->state_pending,
+						   output->scanout_plane);
+	if (!scanout_state || !scanout_state->fb)
+		goto err;
+
+	return drm_output_apply_state(output->state_pending);
+
+err:
+	drm_output_state_free(output->state_pending);
+	output->state_pending = NULL;
+	return -1;
+}
+
+
 static void
 drm_output_start_repaint_loop(struct weston_output *output_base)
 {
-- 
2.9.3



More information about the wayland-devel mailing list