diff options
author | Jordan Crouse <jordan@cosmicpenguin.net> | 2008-11-18 15:41:58 -0700 |
---|---|---|
committer | Jordan Crouse <jordan@cosmicpenguin.net> | 2008-11-18 15:44:13 -0700 |
commit | cf0655edbcbd3910c12c33d8c786cc72c0242786 (patch) | |
tree | d6572761ffb7be4eb6b6dda814d4160890e8b91a /src/lx_video.c | |
parent | ee23fd75f5eb4447ca238694cc03fcdc219ee245 (diff) |
LX: Change the way EXA memory is allocated
Change how EXA memory is allocated to better allow for
EXA + video + rotation to co-exist on the system. Change
the video to only allocate memory when it needs it.
Also, automatically disable compression when there is less then
16Mb of memory.
Diffstat (limited to 'src/lx_video.c')
-rw-r--r-- | src/lx_video.c | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/src/lx_video.c b/src/lx_video.c index d41bb50..01ccba7 100644 --- a/src/lx_video.c +++ b/src/lx_video.c @@ -189,6 +189,24 @@ struct /* Copy planar YUV data */ static Bool +LXAllocMem(GeodeRec *pGeode, GeodePortPrivRec *pPriv, int size) +{ + if (!pPriv->vidmem || pPriv->vidmem->size < size) { + if (pPriv->vidmem) + GeodeFreeOffscreen(pGeode, pPriv->vidmem); + + pPriv->vidmem = GeodeAllocOffscreen(pGeode, size, 4); + + if (pPriv->vidmem == NULL) { + ErrorF("Could not allocate memory for the video\n"); + return FALSE; + } + } + + return TRUE; +} + +static Bool LXCopyPlanar(ScrnInfoPtr pScrni, int id, unsigned char *buf, short x1, short y1, short x2, short y2, int width, int height, pointer data) @@ -219,12 +237,8 @@ LXCopyPlanar(ScrnInfoPtr pScrni, int id, unsigned char *buf, size = YDstPitch * height; size += UVDstPitch * height; - pPriv->vidmem = GeodeAllocOffscreen(pGeode, size, 4); - - if (pPriv->vidmem == NULL) { - ErrorF("Could not allocate memory for the video\n"); + if (LXAllocMem(pGeode, pPriv, size) == FALSE) return FALSE; - } /* The top of the source region we want to copy */ top = y1 & ~1; @@ -284,12 +298,8 @@ LXCopyPacked(ScrnInfoPtr pScrni, int id, unsigned char *buf, lines = ((dstPitch * height) + pGeode->Pitch - 1) / pGeode->Pitch; - pPriv->vidmem = GeodeAllocOffscreen(pGeode, lines, 4); - - if (pPriv->vidmem == NULL) { - ErrorF("Error while allocating an offscreen region.\n"); + if (LXAllocMem(pGeode, pPriv, lines) == FALSE) return FALSE; - } /* The top of the source region we want to copy */ top = y1; @@ -485,14 +495,14 @@ LXPutImage(ScrnInfoPtr pScrni, if (id == FOURCC_YV12 || id == FOURCC_I420) ret = LXCopyPlanar(pScrni, id, buf, x1, y1, x2, y2, width, - height, data); + height, data); else ret = LXCopyPacked(pScrni, id, buf, x1, y1, x2, y2, width, - height, data); + height, data); if (ret == FALSE) return BadAlloc; - + if (!RegionsEqual(&pPriv->clip, clipBoxes) || (drawW != pPriv->pwidth || drawH != pPriv->pheight)) { REGION_COPY(pScrni->pScreen, &pPriv->clip, clipBoxes); @@ -705,6 +715,7 @@ LXSetupImageVideo(ScreenPtr pScrn) /* Use the common function */ adapt->QueryImageAttributes = GeodeQueryImageAttributes; + pPriv->vidmem = NULL; pPriv->filter = 0; pPriv->colorKey = 0; pPriv->colorKeyMode = 0; |