[PATCH weston 27/68] compositor-drm: Clean up page_flip_pending path

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


page_flip_pending is set when we do a no-effect pageflip, and thus don't
need to release the buffer as we don't have a new one pending.

Now we have last/cur/pending properly broken out, we can just use these
consistently, and test if last != current (the effect), rather than the
specific path which triggered it.

Signed-off-by: Daniel Stone <daniels at collabora.com>

Differential Revision: https://phabricator.freedesktop.org/D1417
---
 libweston/compositor-drm.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/libweston/compositor-drm.c b/libweston/compositor-drm.c
index 382c8e2..bd6170a 100644
--- a/libweston/compositor-drm.c
+++ b/libweston/compositor-drm.c
@@ -786,6 +786,7 @@ drm_output_repaint(struct weston_output *output_base,
 	output->fb_current = output->fb_pending;
 	output->fb_pending = NULL;
 
+	assert(!output->page_flip_pending);
 	output->page_flip_pending = 1;
 
 	drm_output_set_cursor(output);
@@ -907,12 +908,18 @@ drm_output_start_repaint_loop(struct weston_output *output_base)
 	 */
 	fb_id = output->fb_current->fb_id;
 
+	assert(!output->page_flip_pending);
+	assert(!output->fb_last);
+
 	if (drmModePageFlip(backend->drm.fd, output->crtc_id, fb_id,
 			    DRM_MODE_PAGE_FLIP_EVENT, output) < 0) {
 		weston_log("queueing pageflip failed: %m\n");
 		goto finish_frame;
 	}
 
+	output->fb_last = drm_fb_ref(output->fb_current);
+	output->page_flip_pending = 1;
+
 	return;
 
 finish_frame:
@@ -973,16 +980,12 @@ page_flip_handler(int fd, unsigned int frame,
 
 	drm_output_update_msc(output, frame);
 
-	/* We don't set page_flip_pending on start_repaint_loop, in that case
-	 * we just want to page flip to the current buffer to get an accurate
-	 * timestamp */
-	if (output->page_flip_pending) {
-		drm_fb_unref(output->fb_last);
-		output->fb_last = NULL;
-	}
-
+	assert(output->page_flip_pending);
 	output->page_flip_pending = 0;
 
+	drm_fb_unref(output->fb_last);
+	output->fb_last = NULL;
+
 	if (output->destroy_pending)
 		drm_output_destroy(&output->base);
 	else if (output->disable_pending)
-- 
2.9.3



More information about the wayland-devel mailing list