From: Pauli Nieminen <[email protected]>

DRI2SwapComplete is too late for front to fake front copy if swap is
completed asynchronously. Client could be able to use fake front already
before swap completes.

Moving front to fake front solves the problem but requires that driver
is capable to copy from new front to fake front immediately after
ScheduleSwap hook returns.

Signed-off-by: Pauli Nieminen <[email protected]>
---
 hw/xfree86/dri2/dri2.c |   34 ++++++++++++++++++++--------------
 1 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 12c1f72..604930c 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -811,7 +811,6 @@ DRI2SwapComplete(ClientPtr client, DRI2DrawablePtr pPriv, 
int frame,
 {
     DRI2SwapCompleteDataPtr pSwapData = swap_data;
     DRI2DrawableRefPtr ref = DRI2LookupClientDrawableRef(pPriv, client, 0);
-    DrawablePtr     pDraw = pPriv->drawable;
     CARD64          ust = 0;
 
     pPriv->swapsPending--;
@@ -821,19 +820,6 @@ DRI2SwapComplete(ClientPtr client, DRI2DrawablePtr pPriv, 
int frame,
     if (ref == NULL)
        goto out;
 
-    if (pDraw) {
-       BoxRec          box;
-       RegionRec       region;
-
-       box.x1 = 0;
-       box.y1 = 0;
-       box.x2 = pDraw->width;
-       box.y2 = pDraw->height;
-       RegionInit(&region, &box, 0);
-       DRI2CopyRegion(pPriv, &region, DRI2BufferFakeFrontLeft,
-                      DRI2BufferFrontLeft);
-    }
-
     ust = ((CARD64)tv_sec * 1000000) + tv_usec;
     if (swap_complete)
        swap_complete(client, pSwapData->data, type, ust, frame,
@@ -868,6 +854,23 @@ DRI2WaitSwap(ClientPtr client, DRI2DrawablePtr pPriv)
     return FALSE;
 }
 
+static void
+DRI2CopyFrontToFakeFront(DrawablePtr pDraw, DRI2DrawablePtr pPriv)
+{
+    if (pDraw) {
+       BoxRec          box;
+       RegionRec       region;
+
+       box.x1 = 0;
+       box.y1 = 0;
+       box.x2 = pDraw->width;
+       box.y2 = pDraw->height;
+       RegionInit(&region, &box, 0);
+       DRI2CopyRegion(pPriv, &region, DRI2BufferFakeFrontLeft,
+                      DRI2BufferFrontLeft);
+    }
+}
+
 int
 DRI2SwapBuffers(ClientPtr client, DRI2DrawablePtr pPriv, CARD64 target_msc,
                CARD64 divisor, CARD64 remainder, CARD64 *swap_target,
@@ -933,6 +936,8 @@ DRI2SwapBuffers(ClientPtr client, DRI2DrawablePtr pPriv, 
CARD64 target_msc,
        (*ds->CopyRegion)(pDraw, &region, pDestBuffer, pSrcBuffer);
        DRI2SwapComplete(client, pPriv, target_msc, 0, 0, DRI2_BLIT_COMPLETE,
                         func, pSwapData);
+
+       DRI2CopyFrontToFakeFront(pDraw, pPriv);
        return Success;
     }
 
@@ -991,6 +996,7 @@ DRI2SwapBuffers(ClientPtr client, DRI2DrawablePtr pPriv, 
CARD64 target_msc,
 
     DRI2InvalidateDrawable(pPriv);
 
+    DRI2CopyFrontToFakeFront(pDraw, pPriv);
     return Success;
 }
 
-- 
1.7.0.4

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to