[PATCH v2 1/3] present: restore screen pixmap when aborting a flip

Frank Binns frank.binns at imgtec.com
Wed May 28 09:40:29 PDT 2014


If a 2D application is started on top of a fullscreen 3D application, which
is flipping, then we need to stop flipping and restore the root window, and
possibly the flip window, to using the screen pixmap. Normally this would
be done as part of an unflip. However, in the case that there is a pending
flip there is no mechanism to abort so the unflip is deferred until the
pending flip completes. This provides a window of opportunity for the 2D
application to draw to the wrong pixmap.

Restore the screen pixmap at the point a pending flip is marked as aborted,
thus avoiding this issue.

Signed-off-by: Frank Binns <frank.binns at imgtec.com>
---
 present/present.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/present/present.c b/present/present.c
index 73d5f69..dbd60cc 100644
--- a/present/present.c
+++ b/present/present.c
@@ -343,6 +343,26 @@ present_set_tree_pixmap(WindowPtr window, PixmapPtr pixmap)
 }
 
 static void
+present_set_abort_flip(ScreenPtr screen)
+{
+    present_screen_priv_ptr screen_priv = present_screen_priv(screen);
+
+    /* Switch back to using the screen pixmap now to avoid
+     * 2D applications drawing to the wrong pixmap.
+     */
+
+    if (screen_priv->flip_window)
+        present_set_tree_pixmap(screen_priv->flip_window,
+                                  (*screen->GetScreenPixmap)(screen));
+
+    if (screen->root)
+        present_set_tree_pixmap(screen->root,
+                                  (*screen->GetScreenPixmap)(screen));
+
+    screen_priv->flip_pending->abort_flip = TRUE;
+}
+
+static void
 present_unflip(ScreenPtr screen)
 {
     present_screen_priv_ptr screen_priv = present_screen_priv(screen);
@@ -470,7 +490,7 @@ present_check_flip_window (WindowPtr window)
         if (flip_pending->window == window) {
             if (!present_check_flip(flip_pending->crtc, window, flip_pending->pixmap,
                                     flip_pending->sync_flip, NULL, 0, 0))
-                flip_pending->abort_flip = TRUE;
+                present_set_abort_flip(screen);
         }
     } else {
         /*
@@ -587,7 +607,7 @@ present_execute(present_vblank_ptr vblank, uint64_t ust, uint64_t crtc_msc)
             /* Check pending flip
              */
             if (window == screen_priv->flip_pending->window)
-                screen_priv->flip_pending->abort_flip = TRUE;
+                present_set_abort_flip(screen);
         } else if (!screen_priv->unflip_event_id) {
 
             /* Check current flip
@@ -866,7 +886,7 @@ present_flip_destroy(ScreenPtr screen)
 
     /* Do the actual cleanup once the flip has been performed by the hardware */
     if (screen_priv->flip_pending)
-        screen_priv->flip_pending->abort_flip = TRUE;
+        present_set_abort_flip(screen);
 }
 
 void
-- 
1.8.5.4.gfdaaaa2



More information about the xorg-devel mailing list