From 3cf46cc1e32efc0e4be1d88be111ba0438e0f021 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Thu, 30 Mar 2006 05:15:58 +0000 Subject: [PATCH] Add an UploadToScreen implementation, for testing PutImage support, and make the DownloadFromScreen more robust. --- ChangeLog | 7 +++++ hw/kdrive/ephyr/ephyr_draw.c | 59 ++++++++++++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index d921e34fc..e2263245c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-03-29 Eric Anholt + + * hw/kdrive/ephyr/ephyr_draw.c: (ephyrDownloadFromScreen), + (ephyrUploadToScreen), (ephyrDrawInit): + Add an UploadToScreen implementation, for testing PutImage support, and + make the DownloadFromScreen more robust. + 2006-03-29 Eric Anholt * exa/exa_accel.c: (exaGetImage): diff --git a/hw/kdrive/ephyr/ephyr_draw.c b/hw/kdrive/ephyr/ephyr_draw.c index 93cb23b3c..f4bb2a1b0 100644 --- a/hw/kdrive/ephyr/ephyr_draw.c +++ b/hw/kdrive/ephyr/ephyr_draw.c @@ -227,25 +227,71 @@ ephyrDoneComposite(PixmapPtr pDst) } /** - * Does an fbGetImage to pull image data from a pixmap. + * Does fake acceleration of DownloadFromScren using memcpy. */ static Bool ephyrDownloadFromScreen(PixmapPtr pSrc, int x, int y, int w, int h, char *dst, int dst_pitch) { - /* Only "accelerate" it if we can hand it off to fbGetImage, which expects - * the dst pitch to match the width of the image. - */ - if (dst_pitch != PixmapBytePad(&pSrc->drawable, w)) + KdScreenPriv(pSrc->drawable.pScreen); + KdScreenInfo *screen = pScreenPriv->screen; + EphyrScrPriv *scrpriv = screen->driver; + EphyrFakexaPriv *fakexa = scrpriv->fakexa; + char *src; + int src_pitch, cpp; + + if (pSrc->drawable.bitsPerPixel < 8) return FALSE; - fbGetImage(&pSrc->drawable, x, y, w, h, ZPixmap, FB_ALLONES, dst); + cpp = pSrc->drawable.bitsPerPixel / 8; + src_pitch = exaGetPixmapPitch(pSrc); + src = fakexa->exa->memoryBase + exaGetPixmapOffset(pSrc); + src += y * src_pitch + x * cpp; + + for (; h > 0; h--) { + memcpy(dst, src, w * cpp); + dst += dst_pitch; + src += src_pitch; + } exaMarkSync(pSrc->drawable.pScreen); return TRUE; } +/** + * Does fake acceleration of DownloadFromScren using memcpy. + */ +static Bool +ephyrUploadToScreen(PixmapPtr pDst, int x, int y, int w, int h, char *src, + int src_pitch) +{ + KdScreenPriv(pDst->drawable.pScreen); + KdScreenInfo *screen = pScreenPriv->screen; + EphyrScrPriv *scrpriv = screen->driver; + EphyrFakexaPriv *fakexa = scrpriv->fakexa; + char *dst; + int dst_pitch, cpp; + + if (pDst->drawable.bitsPerPixel < 8) + return FALSE; + + cpp = pDst->drawable.bitsPerPixel / 8; + dst_pitch = exaGetPixmapPitch(pDst); + dst = fakexa->exa->memoryBase + exaGetPixmapOffset(pDst); + dst += y * dst_pitch + x * cpp; + + for (; h > 0; h--) { + memcpy(dst, src, w * cpp); + dst += dst_pitch; + src += src_pitch; + } + + exaMarkSync(pDst->drawable.pScreen); + + return TRUE; +} + /** * In fakexa, we currently only track whether we have synced to the latest * "accelerated" drawing that has happened or not. This will be used by an @@ -331,6 +377,7 @@ ephyrDrawInit(ScreenPtr pScreen) fakexa->exa->DoneComposite = ephyrDoneComposite; fakexa->exa->DownloadFromScreen = ephyrDownloadFromScreen; + fakexa->exa->UploadToScreen = ephyrUploadToScreen; fakexa->exa->MarkSync = ephyrMarkSync; fakexa->exa->WaitMarker = ephyrWaitMarker;