From e6216b48f5feee72f107348cb21bad724536ec62 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 14 Aug 2004 21:36:10 +0000 Subject: Fix offsets, do whole region at once by using GC clipping --- miext/cw/cw.c | 50 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 15 deletions(-) diff --git a/miext/cw/cw.c b/miext/cw/cw.c index 6e9ef6a07..5046164d9 100644 --- a/miext/cw/cw.c +++ b/miext/cw/cw.c @@ -675,30 +675,50 @@ cwCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) if (!cwDrawableIsRedirWindow((DrawablePtr)pWin)) { (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc); } else { - GCPtr pGC; - BoxPtr pBox; - int nbox, i, x_off, y_off; - int dx, dy; + GCPtr pGC; + BoxPtr pExtents; + int x_off, y_off; + int dx, dy; DrawablePtr pBackingDrawable; + RegionPtr pClip; + int src_x, src_y, dst_x, dst_y, w, h; + dx = ptOldOrg.x - pWin->drawable.x; + dy = ptOldOrg.y - pWin->drawable.y; + + pExtents = REGION_EXTENTS(pScreen, prgnSrc); + + src_x = pExtents->x1; + src_y = pExtents->y1; + w = pExtents->x2 - pExtents->x1; + h = pExtents->y2 - pExtents->y1; + dst_x = src_x - dx; + dst_y = src_y - dy; + pBackingDrawable = cwGetBackingDrawable((DrawablePtr)pWin, &x_off, &y_off); + /* Translate region (as required by API) */ + REGION_TRANSLATE(pScreen, prgnSrc, -dx, -dy); + pGC = GetScratchGC(pBackingDrawable->depth, pScreen); - ValidateGC(pBackingDrawable, pGC); + /* + * Copy region to GC as clip, aligning as dest clip + */ + pClip = REGION_CREATE (pScreen, NULL, 0); + REGION_INTERSECT(pScreen, pClip, &pWin->borderClip, prgnSrc); + REGION_TRANSLATE(pScreen, pClip, + -pWin->drawable.x + x_off, + -pWin->drawable.y + y_off); + + (*pGC->funcs->ChangeClip) (pGC, CT_REGION, pClip, 0); - pBox = REGION_RECTS(prgnSrc); - nbox = REGION_NUM_RECTS(prgnSrc); + ValidateGC(pBackingDrawable, pGC); - dx = ptOldOrg.x - pWin->drawable.x; - dy = ptOldOrg.y - pWin->drawable.y; + (*pGC->ops->CopyArea) (pBackingDrawable, pBackingDrawable, pGC, + src_x, src_y, w, h, dst_x, dst_y); - for (i = 0; i < nbox; i++, pBox++) { - (*pGC->ops->CopyArea)(pBackingDrawable, pBackingDrawable, pGC, - pBox->x1 + x_off, pBox->y1 + y_off, - pBox->x2 - pBox->x1, pBox->y2 - pBox->y1, - pBox->x1 + x_off + dx, pBox->y1 + y_off + dy); - } + (*pGC->funcs->DestroyClip) (pGC); FreeScratchGC(pGC); } -- cgit v1.2.3