From 567cf67959b30432ae30f4851ec17b3a375ab838 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Thu, 9 Apr 2009 14:38:24 -0700 Subject: [PATCH] DRI2: Synchronize the contents of the real and fake front-buffers Signed-off-by: Ian Romanick --- hw/xfree86/dri2/dri2.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c index 351d02b7b..0b52a0f8c 100644 --- a/hw/xfree86/dri2/dri2.c +++ b/hw/xfree86/dri2/dri2.c @@ -141,6 +141,7 @@ DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height, DRI2BufferPtr buffers; unsigned int temp_buf[32]; unsigned int *temp = temp_buf; + int have_fake_front = 0; /* If the drawable is a window and the front-buffer is requested, silently @@ -163,6 +164,7 @@ DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height, if (attachments[i] == DRI2BufferFakeFrontLeft) { need_fake_front--; + have_fake_front = 1; } temp[i] = attachments[i]; @@ -171,6 +173,7 @@ DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height, if (need_fake_front > 0) { temp[i] = DRI2BufferFakeFrontLeft; count++; + have_fake_front = 1; attachments = temp; } } @@ -195,6 +198,25 @@ DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height, *height = pPriv->height; *out_count = pPriv->bufferCount; + + /* If the client is getting a fake front-buffer, pre-fill it with the + * contents of the real front-buffer. This ensures correct operation of + * applications that call glXWaitX before calling glDrawBuffer. + */ + if (have_fake_front) { + BoxRec box; + RegionRec region; + + box.x1 = 0; + box.y1 = 0; + box.x2 = pPriv->width; + box.y2 = pPriv->height; + REGION_INIT(pDraw->pScreen, ®ion, &box, 0); + + DRI2CopyRegion(pDraw, ®ion, DRI2BufferFakeFrontLeft, + DRI2BufferFrontLeft); + } + return pPriv->buffers; }