File u_06-Add-a-shadow_pixmap-to-hold-information-on-shadow_fb2.patch of Package xf86-video-modesetting.1041
From: Egbert Eich <eich@suse.de>
Date: Wed Aug 26 16:00:17 2015 +0200
Subject: [PATCH 6/6]Add a shadow_pixmap to hold information on shadow_fb2
Patch-mainline: to be upstreamed
References: bsc#942871
Signed-off-by: Egbert Eich <eich@suse.com>
The DIX shadow functions use a pixmap to retrieve data for the source
buffer. Since we use two shadow buffers we cannot use the screen pixmap.
Instead, create a copy of the screen pixmap for the intermediary shadow
buffer and modify the pointer to this buffer.
Signed-off-by: Egbert Eich <eich@suse.de>
---
src/driver.c | 20 +++++++++++++++-----
src/drmmode_display.c | 3 +++
src/drmmode_display.h | 1 +
3 files changed, 19 insertions(+), 5 deletions(-)
diff --git a/src/driver.c b/src/driver.c
index 70ee335..569d3b6 100644
--- a/src/driver.c
+++ b/src/driver.c
@@ -879,9 +879,9 @@ msUpdateIntersect(modesettingPtr ms, shadowBufPtr pBuf, BoxPtr box,
for (i = box->y2 - box->y1 - 1; i >= 0; i--) {
unsigned char *o = old + i * stride,
*n = new + i * stride;
- if (memcmp(o, n, width) != 0) {
+ if (memcmp(n, o, width) != 0) {
dirty = 1;
- memcpy(o, n, width);
+ memcpy(n, o, width);
}
}
@@ -977,18 +977,26 @@ CreateScreenResources(ScreenPtr pScreen)
pixels = ms->drmmode.shadow_fb;
if (ms->drmmode.shadow_enable2) {
- ms->drmmode.shadow_fb2 = calloc(1, pScrn->displayWidth * pScrn->virtualY * ((pScrn->bitsPerPixel + 7) >> 3));
+ ms->drmmode.shadow_pixmap = (PixmapPtr)calloc(1, sizeof(PixmapRec));
+ if (ms->drmmode.shadow_pixmap)
+ ms->drmmode.shadow_fb2 = calloc(1, pScrn->displayWidth * pScrn->virtualY * ((pScrn->bitsPerPixel + 7) >> 3));
if (!ms->drmmode.shadow_fb2)
ms->drmmode.shadow_enable2 = FALSE;
- else
+ else {
pixels = ms->drmmode.shadow_fb2;
+ memcpy(ms->drmmode.shadow_pixmap, rootPixmap, sizeof(PixmapRec));
+ if (!pScreen->ModifyPixmapHeader(ms->drmmode.shadow_pixmap,
+ -1, -1, -1, -1, -1, ms->drmmode.shadow_fb))
+ FatalError("Couldn't adjust shadow pixmap\n");
+ }
}
if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, pixels))
FatalError("Couldn't adjust screen pixmap\n");
if (ms->drmmode.shadow_enable) {
- if (!shadowAdd(pScreen, rootPixmap, msUpdatePacked, msShadowWindow,
+ if (!shadowAdd(pScreen, ms->drmmode.shadow_pixmap ? ms->drmmode.shadow_pixmap : rootPixmap,
+ msUpdatePacked, msShadowWindow,
0, 0))
return FALSE;
}
@@ -1252,6 +1260,8 @@ CloseScreen(CLOSE_SCREEN_ARGS_DECL)
ms->drmmode.shadow_fb = NULL;
free(ms->drmmode.shadow_fb2);
ms->drmmode.shadow_fb2 = NULL;
+ free(ms->drmmode.shadow_pixmap);
+ ms->drmmode.shadow_pixmap = NULL;
}
drmmode_uevent_fini(pScrn, &ms->drmmode);
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 4de7cdc..cfb74a7 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -1219,6 +1219,9 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
drmmode->shadow_fb2 = NULL;
} else {
drmmode->shadow_fb2 = new_pixels;
+ memcpy(drmmode->shadow_pixmap, ppix, sizeof(PixmapRec));
+ screen->ModifyPixmapHeader(drmmode->shadow_pixmap,
+ width, height, -1, -1, pitch, drmmode->shadow_fb);
}
}
diff --git a/src/drmmode_display.h b/src/drmmode_display.h
index 9096a2d..5f726cd 100644
--- a/src/drmmode_display.h
+++ b/src/drmmode_display.h
@@ -68,6 +68,7 @@ typedef struct {
Bool shadow_enable2;
void *shadow_fb;
void *shadow_fb2;
+ PixmapPtr shadow_pixmap;
#ifdef HAVE_SCREEN_SPECIFIC_PRIVATE_KEYS
DevPrivateKeyRec pixmapPrivateKeyRec;