From 509f6085ce7747d76f638a7a30170c437b296a40 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Sun, 6 Feb 2011 20:22:01 +0000 Subject: Fix packed overlay offscreen allocations 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 file changed, 4 insertions(+), 1 deletion(-) 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); -- cgit v1.2.3