summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Romanick <ian.d.romanick@intel.com>2009-04-08 15:44:34 -0700
committerIan Romanick <ian.d.romanick@intel.com>2009-06-11 22:45:59 -0700
commit32d250a881341ece8a1f1d78359adc1b265b5174 (patch)
tree40930ba32b8e236d79e9c19529e34df273a47172
parentdb61eff891675aeaf2466c3529424de4621005dc (diff)
DRI2: Add fake front-buffer to request list for windows
If a front-buffer is requested for a window, add the fake front-buffer to the list of requested buffers. Signed-off-by: Ian Romanick <ian.d.romanick@intel.com> (cherry picked from commit aa2928325fe51d94a636dde9c090e8f54a311a12)
-rw-r--r--hw/xfree86/dri2/dri2.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
index 0f2e24b3f..351d02b7b 100644
--- a/hw/xfree86/dri2/dri2.c
+++ b/hw/xfree86/dri2/dri2.c
@@ -139,6 +139,42 @@ DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height,
DRI2ScreenPtr ds = DRI2GetScreen(pDraw->pScreen);
DRI2DrawablePtr pPriv = DRI2GetDrawable(pDraw);
DRI2BufferPtr buffers;
+ unsigned int temp_buf[32];
+ unsigned int *temp = temp_buf;
+
+
+ /* If the drawable is a window and the front-buffer is requested, silently
+ * add the fake front-buffer to the list of requested attachments. The
+ * counting logic in the loop accounts for the case where the client
+ * requests both the fake and real front-buffer.
+ */
+ if (pDraw->type == DRAWABLE_WINDOW) {
+ int need_fake_front = 0;
+ int i;
+
+ if ((count + 1) > 32) {
+ temp = xalloc((count + 1) * sizeof(temp[0]));
+ }
+
+ for (i = 0; i < count; i++) {
+ if (attachments[i] == DRI2BufferFrontLeft) {
+ need_fake_front++;
+ }
+
+ if (attachments[i] == DRI2BufferFakeFrontLeft) {
+ need_fake_front--;
+ }
+
+ temp[i] = attachments[i];
+ }
+
+ if (need_fake_front > 0) {
+ temp[i] = DRI2BufferFakeFrontLeft;
+ count++;
+ attachments = temp;
+ }
+ }
+
if (pPriv->buffers == NULL ||
pDraw->width != pPriv->width || pDraw->height != pPriv->height)
@@ -151,6 +187,10 @@ DRI2GetBuffers(DrawablePtr pDraw, int *width, int *height,
pPriv->height = pDraw->height;
}
+ if (temp != temp_buf) {
+ xfree(temp);
+ }
+
*width = pPriv->width;
*height = pPriv->height;
*out_count = pPriv->bufferCount;