From 578a5243bd0c262e731c7872e0b27dba5aea49bf Mon Sep 17 00:00:00 2001 From: Maximilian Grothusmann Date: Fri, 18 Sep 2009 01:22:07 +0200 Subject: [PATCH] Revert the not-EXA-related part of ee7c684f21d220d5e046bab31ae617a7d64d60f6 --- Xext/shm.c | 84 ++++++++++++++++++++++++++++++++++++++++++--------------- Xext/shmint.h | 3 ++ 2 files changed, 65 insertions(+), 22 deletions(-) diff --git a/Xext/shm.c b/Xext/shm.c index a48d2bd..1eff695 100644 --- a/Xext/shm.c +++ b/Xext/shm.c @@ -101,6 +101,7 @@ typedef struct _ShmDesc { unsigned long size; } ShmDescRec, *ShmDescPtr; +static void miShmPutImage(XSHM_PUT_IMAGE_ARGS); static PixmapPtr fbShmCreatePixmap(XSHM_CREATE_PIXMAP_ARGS); static int ShmDetachSegment( pointer /* value */, @@ -141,8 +142,8 @@ static ShmFuncsPtr shmFuncs[MAXSCREENS]; static DestroyPixmapProcPtr destroyPixmap[MAXSCREENS]; static int shmPixmapPrivateIndex; static DevPrivateKey shmPixmapPrivate = &shmPixmapPrivateIndex; -static ShmFuncs miFuncs = {NULL, NULL}; -static ShmFuncs fbFuncs = {fbShmCreatePixmap, NULL}; +static ShmFuncs miFuncs = {NULL, miShmPutImage}; +static ShmFuncs fbFuncs = {fbShmCreatePixmap, fbShmPutImage}; #define VERIFY_SHMSEG(shmseg,shmdesc,client) \ { \ @@ -488,28 +489,66 @@ ProcShmDetach(ClientPtr client) return(client->noClientException); } -/* - * If the given request doesn't exactly match PutImage's constraints, - * wrap the image in a scratch pixmap header and let CopyArea sort it out. - */ static void -doShmPutImage(DrawablePtr dst, GCPtr pGC, +miShmPutImage(DrawablePtr dst, GCPtr pGC, int depth, unsigned int format, int w, int h, int sx, int sy, int sw, int sh, int dx, int dy, char *data) { - PixmapPtr pPixmap; - - pPixmap = GetScratchPixmapHeader(dst->pScreen, w, h, depth, - BitsPerPixel(depth), - PixmapBytePad(w, depth), - data); - if (!pPixmap) + PixmapPtr pmap; + GCPtr putGC; + + putGC = GetScratchGC(depth, dst->pScreen); + if (!putGC) return; - pGC->ops->CopyArea((DrawablePtr)pPixmap, dst, pGC, sx, sy, sw, sh, dx, dy); - FreeScratchPixmapHeader(pPixmap); + pmap = (*dst->pScreen->CreatePixmap)(dst->pScreen, sw, sh, depth, + CREATE_PIXMAP_USAGE_SCRATCH); + if (!pmap) + { + FreeScratchGC(putGC); + return; + } + ValidateGC((DrawablePtr)pmap, putGC); + (*putGC->ops->PutImage)((DrawablePtr)pmap, putGC, depth, -sx, -sy, w, h, 0, + (format == XYPixmap) ? XYPixmap : ZPixmap, data); + FreeScratchGC(putGC); + if (format == XYBitmap) + (void)(*pGC->ops->CopyPlane)((DrawablePtr)pmap, dst, pGC, 0, 0, sw, sh, + dx, dy, 1L); + else + (void)(*pGC->ops->CopyArea)((DrawablePtr)pmap, dst, pGC, 0, 0, sw, sh, + dx, dy); + (*pmap->drawable.pScreen->DestroyPixmap)(pmap); } +_X_EXPORT void +fbShmPutImage(DrawablePtr dst, GCPtr pGC, + int depth, unsigned int format, + int w, int h, int sx, int sy, int sw, int sh, int dx, int dy, + char *data) +{ + if ((format == ZPixmap) || (depth == 1)) + { + PixmapPtr pPixmap; + + pPixmap = GetScratchPixmapHeader(dst->pScreen, w, h, depth, + BitsPerPixel(depth), PixmapBytePad(w, depth), (pointer)data); + if (!pPixmap) + return; + if (format == XYBitmap) + (void)(*pGC->ops->CopyPlane)((DrawablePtr)pPixmap, dst, pGC, + sx, sy, sw, sh, dx, dy, 1L); + else + (void)(*pGC->ops->CopyArea)((DrawablePtr)pPixmap, dst, pGC, + sx, sy, sw, sh, dx, dy); + FreeScratchPixmapHeader(pPixmap); + } + else + miShmPutImage(dst, pGC, depth, format, w, h, sx, sy, sw, sh, dx, dy, + data); +} + + #ifdef PANORAMIX static int ProcPanoramiXShmPutImage(ClientPtr client) @@ -862,12 +901,13 @@ ProcShmPutImage(ClientPtr client) shmdesc->addr + stuff->offset + (stuff->srcY * length)); else - doShmPutImage(pDraw, pGC, stuff->depth, stuff->format, - stuff->totalWidth, stuff->totalHeight, - stuff->srcX, stuff->srcY, - stuff->srcWidth, stuff->srcHeight, - stuff->dstX, stuff->dstY, - shmdesc->addr + stuff->offset); + (*shmFuncs[pDraw->pScreen->myNum]->PutImage)( + pDraw, pGC, stuff->depth, stuff->format, + stuff->totalWidth, stuff->totalHeight, + stuff->srcX, stuff->srcY, + stuff->srcWidth, stuff->srcHeight, + stuff->dstX, stuff->dstY, + shmdesc->addr + stuff->offset); if (stuff->sendEvent) { diff --git a/Xext/shmint.h b/Xext/shmint.h index f659fd2..d1f1a7a 100644 --- a/Xext/shmint.h +++ b/Xext/shmint.h @@ -34,6 +34,9 @@ void ShmRegisterFuncs(ScreenPtr pScreen, ShmFuncsPtr funcs); void +fbShmPutImage(XSHM_PUT_IMAGE_ARGS); + +void ShmRegisterFbFuncs(ScreenPtr pScreen); #endif /* _SHMINT_H_ */ -- 1.6.5.rc1