If the drawable size remained the same, the application can continue to
reuse the same back and auxiliary buffers, but will need the new name
for the Pixmap.

Signed-off-by: Chris Wilson <[email protected]>
Cc: Ville Syrjälä <[email protected]>
Cc: Dave Airlie <[email protected]>
Cc: Kristian Høgsberg <[email protected]>
Cc: Jesse Barnes <[email protected]>
Cc: Michel Dänzer <[email protected]>
---
 hw/xfree86/dri2/dri2.c |   35 ++++++++++++++++++++---------------
 1 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index d837852..7896a61 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -340,13 +340,13 @@ static Bool
 allocate_or_reuse_buffer(DrawablePtr pDraw, DRI2ScreenPtr ds,
                         DRI2DrawablePtr pPriv,
                         unsigned int attachment, unsigned int format,
-                        int dimensions_match, DRI2BufferPtr *buffer)
+                        int force, DRI2BufferPtr *buffer)
 {
-    int old_buf = find_attachment(pPriv, attachment);
+    int old_buf;
 
-    if ((old_buf < 0)
-       || !dimensions_match
-       || (pPriv->buffers[old_buf]->format != format)) {
+    if (force ||
+       (old_buf = find_attachment(pPriv, attachment)) < 0 ||
+       (pPriv->buffers[old_buf]->format != format)) {
        *buffer = (*ds->CreateBuffer)(pDraw, attachment, format);
        pPriv->serialNumber = DRI2DrawableSerial(pDraw);
        return TRUE;
@@ -395,7 +395,7 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
     int need_fake_front = 0;
     int have_fake_front = 0;
     int front_format = 0;
-    int dimensions_match;
+    int dimensions_mismatch;
     int buffers_changed = 0;
     int i;
 
@@ -406,9 +406,9 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
        return NULL;
     }
 
-    dimensions_match = (pDraw->width == pPriv->width)
-       && (pDraw->height == pPriv->height)
-       && (pPriv->serialNumber == DRI2DrawableSerial(pDraw));
+    dimensions_mismatch =
+           pDraw->width != pPriv->width ||
+           pDraw->height != pPriv->height;
 
     buffers = calloc((count + 1), sizeof(buffers[0]));
     if (!buffers)
@@ -417,10 +417,13 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
     for (i = 0; i < count; i++) {
        const unsigned attachment = *(attachments++);
        const unsigned format = (has_format) ? *(attachments++) : 0;
+       int force = dimensions_mismatch;
+
+       if (attachment == DRI2BufferFrontLeft)
+               force |= pPriv->serialNumber != DRI2DrawableSerial(pDraw);
 
        if (allocate_or_reuse_buffer(pDraw, ds, pPriv, attachment,
-                                    format, dimensions_match,
-                                    &buffers[i]))
+                                    format, force, &buffers[i]))
                buffers_changed = 1;
 
        if (buffers[i] == NULL)
@@ -455,7 +458,9 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
 
     if (need_real_front > 0) {
        if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFrontLeft,
-                                    front_format, dimensions_match,
+                                    front_format,
+                                    dimensions_mismatch ||
+                                    pPriv->serialNumber != 
DRI2DrawableSerial(pDraw),
                                     &buffers[i]))
            buffers_changed = 1;
 
@@ -466,7 +471,7 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
 
     if (need_fake_front > 0) {
        if (allocate_or_reuse_buffer(pDraw, ds, pPriv, DRI2BufferFakeFrontLeft,
-                                    front_format, dimensions_match,
+                                    front_format, dimensions_mismatch,
                                     &buffers[i]))
            buffers_changed = 1;
 
@@ -495,8 +500,8 @@ do_get_buffers(DrawablePtr pDraw, int *width, int *height,
        box.y2 = pPriv->height;
        RegionInit(&region, &box, 0);
 
-       DRI2CopyRegion(pDraw, &region, DRI2BufferFakeFrontLeft,
-                      DRI2BufferFrontLeft);
+       DRI2CopyRegion(pDraw, &region,
+                      DRI2BufferFakeFrontLeft, DRI2BufferFrontLeft);
     }
 
     pPriv->needInvalidate = TRUE;
-- 
1.7.5.1

_______________________________________________
[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