[PATCH 1/3] present: When composited, get the bits into the window pixmap immediately (v2)

Mario Kleiner mario.kleiner.de at gmail.com
Sun Feb 8 10:31:59 PST 2015


From: Keith Packard <keithp at keithp.com>

When a window is composited, we want to notify the compositing manager
of the new contents *before* the next frame, so that it can prepare
them for display at the next frame, instead of doing the copy at that
frame time, and notifying the compositor so that it would always be a
frame behind.

This change catches the common case of a operation destined for the
next frame and immediately performs the copy, leaving the queue entry
around so that the PresentComplete event can be delivered at the
target frame time. This should give applications the right answer if
the Compositor is able to get the frame constructed before that frame
happens, which is at least better than the current situation where the
client receives the PresentComplete notify at the target frame, but
the contents will not be displayed until a subsequent frame.

Signed-off-by: Keith Packard <keithp at keithp.com>
Reviewed-by: Mario Kleiner <mario.kleiner.de at gmail.com>

v2 (mario): Trivial rebase on top of 1.17.0-rc2
Signed-off-by: Mario Kleiner <mario.kleiner.de at gmail.com>
Tested-by: Mario Kleiner <mario.kleiner.de at gmail.com>
---
 present/present.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/present/present.c b/present/present.c
index bb7f33c..2e7662a 100644
--- a/present/present.c
+++ b/present/present.c
@@ -890,8 +890,25 @@ present_pixmap(WindowPtr window,
     vblank->queued = TRUE;
     if ((pixmap && target_msc >= crtc_msc) || (!pixmap && target_msc > crtc_msc)) {
         ret = present_queue_vblank(screen, target_crtc, vblank->event_id, target_msc);
-        if (ret == Success)
+        if (ret == Success) {
+            /* If the window is composited, and the contents are
+             * destined for the next frame, just do the copy, sending
+             * damage along to the compositor.
+             *
+             * Leave the vblank around to send the completion event at
+             * vblank time
+             */
+            if (pixmap && window && vblank->mode == PresentCompleteModeCopy &&
+                (target_msc - crtc_msc) <= 1 &&
+                screen->GetWindowPixmap(window) != screen->GetScreenPixmap(screen))
+            {
+                DebugPresent(("\tC %p %8lld: %08lx -> %08lx\n", vblank, crtc_msc,
+                             vblank->pixmap->drawable.id, vblank->window->drawable.id));
+                present_copy(vblank);
+            }
+
             return Success;
+        }
 
         DebugPresent(("present_queue_vblank failed\n"));
     }
-- 
2.1.0



More information about the xorg-devel mailing list