[Xorg-driver-geode] [PATCH] Fix packed overlay offscreen allocations

Daniel Drake dsd at laptop.org
Sun Feb 6 12:22:01 PST 2011


Commit 5e72a00ad2 caused packed video data to corrupt glyphs and other
parts of the screen, but it turns out that the commit actually at fault
was d681a844e, incorrectly changing the size of the allocated destination
memory from the number of bytes needed to the number of lines needed.

While fixing this, I noticed that LXAllocateSurface is probably making the
same mistake, and that the height is probably not calculated correctly for
some corner cases when calling LXCopyFromSys in the packed
video path (but I'm not sure about either).

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=33004
---
 src/lx_video.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/lx_video.c b/src/lx_video.c
index 7b51c5b..35e3ffa 100644
--- a/src/lx_video.c
+++ b/src/lx_video.c
@@ -302,7 +302,7 @@ LXCopyPacked(ScrnInfoPtr pScrni, int id, unsigned char *buf,
 
     lines = ((dstPitch * height) + pGeode->Pitch - 1) / pGeode->Pitch;
 
-    if (LXAllocateVidMem(pScrni, pPriv, lines) == FALSE) {
+    if (LXAllocateVidMem(pScrni, pPriv, dstPitch * height) == FALSE) {
 	ErrorF("Error allocating an offscreen Packed region.\n");
 	return FALSE;
     }
@@ -334,6 +334,7 @@ LXCopyPacked(ScrnInfoPtr pScrni, int id, unsigned char *buf,
 	GeodeCopyGreyscale(buf + srcOffset, pGeode->FBBase + dstOffset,
 	    srcPitch, dstPitch, height, pixels >> 1);
     } else
+	/* FIXME: should lines be used here instead of height? */
 	LXCopyFromSys(pGeode, buf + srcOffset, dstOffset, dstPitch, srcPitch,
 	    height, pixels);
 
@@ -818,6 +819,8 @@ LXAllocateSurface(ScrnInfoPtr pScrni, int id, unsigned short w,
     pitch = ((w << 1) + 15) & ~15;
     lines = ((pitch * h) + (pGeode->Pitch - 1)) / pGeode->Pitch;
 
+    /* FIXME: is lines the right parameter to use here,
+     * or should it be height * pitch? */
     vidmem = exaOffscreenAlloc(pScrni->pScreen, lines, 4, TRUE,
 		NULL, NULL);
 
-- 
1.7.4



More information about the Xorg-driver-geode mailing list