Index: programs/Xserver/miext/damage/damage.c =================================================================== RCS file: /cvs/xorg/xc/programs/Xserver/miext/damage/damage.c,v retrieving revision 1.18 diff -u -r1.18 damage.c --- programs/Xserver/miext/damage/damage.c 3 Jul 2005 07:37:35 -0000 1.18 +++ programs/Xserver/miext/damage/damage.c 9 Oct 2005 16:00:26 -0000 @@ -113,12 +113,11 @@ #if DAMAGE_DEBUG_ENABLE static void -_damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, int subWindowMode, const char *where) -#define damageDamageRegion(d,r,c,m) _damageDamageRegion(d,r,c,m,__FUNCTION__) +_damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, char *where) +#define damageDamageRegion(d,r,c) _damageDamageRegion(d,r,c,__FUNCTION__) #else static void -damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion, Bool clip, - int subWindowMode) +damageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion) #endif { ScreenPtr pScreen = pDrawable->pScreen; @@ -156,26 +155,6 @@ REGION_TRANSLATE (pScreen, pRegion, screen_x, screen_y); #endif - if (pDrawable->type == DRAWABLE_WINDOW && - ((WindowPtr)(pDrawable))->backingStore == NotUseful) - { - if (subWindowMode == ClipByChildren) - { - REGION_INTERSECT(pScreen, pRegion, pRegion, - &((WindowPtr)(pDrawable))->clipList); - } - else if (subWindowMode == IncludeInferiors) - { - RegionPtr pTempRegion = - NotClippedByChildren((WindowPtr)(pDrawable)); - REGION_INTERSECT(pScreen, pRegion, pRegion, pTempRegion); - REGION_UNINIT(pScreen, pTempRegion); - } - /* If subWindowMode is set to an invalid value, don't perform - * any drawable-based clipping. */ - } - - REGION_NULL (pScreen, &clippedRec); for (; pDamage; pDamage = pNext) { @@ -220,7 +199,7 @@ */ pDamageRegion = pRegion; - if (clip || pDamage->pDrawable != pDrawable) + if (pDamage->pDrawable != pDrawable) { pDamageRegion = &clippedRec; if (pDamage->pDrawable->type == DRAWABLE_WINDOW) @@ -249,7 +228,7 @@ pDamageRegion->extents.y2 - pDamageRegion->extents.y1, pDamageRegion->extents.x1, pDamageRegion->extents.y1, pDrawable->id, pDamage->pDrawable->id)); - + /* * Move region to target coordinate space */ @@ -303,23 +282,36 @@ REGION_UNINIT (pScreen, &clippedRec); } -#if DAMAGE_DEBUG_ENABLE -#define damageDamageBox(d,b,m) _damageDamageBox(d,b,m,__FUNCTION__) -static void -_damageDamageBox (DrawablePtr pDrawable, BoxPtr pBox, int subWindowMode, const char *where) -#else static void -damageDamageBox (DrawablePtr pDrawable, BoxPtr pBox, int subWindowMode) -#endif +damageDamageBox (DrawablePtr pDrawable, BoxPtr pBox, + RegionPtr pCompositeClip) { - RegionRec region; + RegionRec region; + int rir; - REGION_INIT (pDrawable->pScreen, ®ion, pBox, 1); -#if DAMAGE_DEBUG_ENABLE - _damageDamageRegion (pDrawable, ®ion, TRUE, subWindowMode, where); -#else - damageDamageRegion (pDrawable, ®ion, TRUE, subWindowMode); -#endif + if (pDrawable->type == DRAWABLE_WINDOW && + ((WindowPtr)(pDrawable))->backingStore == NotUseful) + { + /* Find out if the drawing is entirely within the clip */ + rir = RECT_IN_REGION (pDrawable->pScreen, + pCompositeClip, pBox); + + /* No overlap at all: no damage */ + if (rir == rgnOUT) + return; + + REGION_INIT (pDrawable->pScreen, ®ion, pBox, 1); + if (rir == rgnPART) + { + REGION_INTERSECT (pDrawable->pScreen, ®ion, + ®ion, pCompositeClip); + } + } else { + /* Backing store enabled: don't clip */ + REGION_INIT (pDrawable->pScreen, ®ion, pBox, 1); + } + + damageDamageRegion (pDrawable, ®ion); REGION_UNINIT (pDrawable->pScreen, ®ion); } @@ -464,14 +456,6 @@ DAMAGE_GC_FUNC_EPILOGUE (pGC); } -#define TRIM_BOX(box, pGC) if (pGC->pCompositeClip) { \ - BoxPtr extents = &pGC->pCompositeClip->extents;\ - if(box.x1 < extents->x1) box.x1 = extents->x1; \ - if(box.x2 > extents->x2) box.x2 = extents->x2; \ - if(box.y1 < extents->y1) box.y1 = extents->y1; \ - if(box.y2 > extents->y2) box.y2 = extents->y2; \ - } - #define TRANSLATE_BOX(box, pDrawable) { \ box.x1 += pDrawable->x; \ box.x2 += pDrawable->x; \ @@ -479,14 +463,6 @@ box.y2 += pDrawable->y; \ } -#define TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC) { \ - TRANSLATE_BOX(box, pDrawable); \ - TRIM_BOX(box, pGC); \ - } - -#define BOX_NOT_EMPTY(box) \ - (((box.x2 - box.x1) > 0) && ((box.y2 - box.y1) > 0)) - #define checkGCDamage(d,g) (getDrawableDamage(d) && \ (!g->pCompositeClip ||\ REGION_NOTEMPTY(d->pScreen, \ @@ -494,14 +470,6 @@ #ifdef RENDER -#define TRIM_PICTURE_BOX(box, pDst) { \ - BoxPtr extents = &pDst->pCompositeClip->extents;\ - if(box.x1 < extents->x1) box.x1 = extents->x1; \ - if(box.x2 > extents->x2) box.x2 = extents->x2; \ - if(box.y1 < extents->y1) box.y1 = extents->y1; \ - if(box.y2 > extents->y2) box.y2 = extents->y2; \ - } - #define checkPictureDamage(p) (getDrawableDamage(p->pDrawable) && \ REGION_NOTEMPTY(pScreen, p->pCompositeClip)) @@ -531,9 +499,7 @@ box.y1 = yDst + pDst->pDrawable->y; box.x2 = box.x1 + width; box.y2 = box.y1 + height; - TRIM_PICTURE_BOX(box, pDst); - if (BOX_NOT_EMPTY(box)) - damageDamageBox (pDst->pDrawable, &box, pDst->subWindowMode); + damageDamageBox (pDst->pDrawable, &box, pDst->pCompositeClip); } unwrap (pScrPriv, ps, Composite); (*ps->Composite) (op, @@ -608,9 +574,7 @@ } listTmp++; } - TRIM_PICTURE_BOX (box, pDst); - if (BOX_NOT_EMPTY(box)) - damageDamageBox (pDst->pDrawable, &box, pDst->subWindowMode); + damageDamageBox (pDst->pDrawable, &box, pDst->pCompositeClip); } unwrap (pScrPriv, ps, Glyphs); (*ps->Glyphs) (op, pSrc, pDst, maskFormat, xSrc, ySrc, nlist, list, glyphs); @@ -658,10 +622,8 @@ if(!pGC->miTranslate) { TRANSLATE_BOX(box, pDrawable); } - TRIM_BOX(box, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); + damageDamageBox (pDrawable, &box, pGC->pCompositeClip); } (*pGC->ops->FillSpans)(pDrawable, pGC, npt, ppt, pwidth, fSorted); @@ -707,10 +669,8 @@ if(!pGC->miTranslate) { TRANSLATE_BOX(box, pDrawable); } - TRIM_BOX(box, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); + damageDamageBox (pDrawable, &box, pGC->pCompositeClip); } (*pGC->ops->SetSpans)(pDrawable, pGC, pcharsrc, ppt, pwidth, npt, fSorted); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); @@ -738,9 +698,7 @@ box.y1 = y + pDrawable->y; box.y2 = box.y1 + h; - TRIM_BOX(box, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); + damageDamageBox (pDrawable, &box, pGC->pCompositeClip); } (*pGC->ops->PutImage)(pDrawable, pGC, depth, x, y, w, h, leftPad, format, pImage); @@ -760,7 +718,7 @@ { RegionPtr ret; DAMAGE_GC_OP_PROLOGUE(pGC, pDst); - + /* The driver will only call SourceValidate() when pSrc != pDst, * but the software sprite (misprite.c) always need to know when a * drawable is copied so it can remove the sprite. See #1030. */ @@ -780,9 +738,7 @@ box.y1 = dsty + pDst->y; box.y2 = box.y1 + height; - TRIM_BOX(box, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDst, &box, pGC->subWindowMode); + damageDamageBox (pDst, &box, pGC->pCompositeClip); } ret = (*pGC->ops->CopyArea)(pSrc, pDst, @@ -825,9 +781,7 @@ box.y1 = dsty + pDst->y; box.y2 = box.y1 + height; - TRIM_BOX(box, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDst, &box, pGC->subWindowMode); + damageDamageBox (pDst, &box, pGC->pCompositeClip); } ret = (*pGC->ops->CopyPlane)(pSrc, pDst, @@ -868,9 +822,8 @@ box.x2++; box.y2++; - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); + TRANSLATE_BOX(box, pDrawable); + damageDamageBox (pDrawable, &box, pGC->pCompositeClip); } (*pGC->ops->PolyPoint)(pDrawable, pGC, mode, npt, ppt); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); @@ -941,9 +894,8 @@ box.y2 += extra; } - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); + TRANSLATE_BOX(box, pDrawable); + damageDamageBox (pDrawable, &box, pGC->pCompositeClip); } (*pGC->ops->Polylines)(pDrawable, pGC, mode, npt, ppt); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); @@ -1019,9 +971,8 @@ box.y2 += extra; } - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); + TRANSLATE_BOX(box, pDrawable); + damageDamageBox (pDrawable, &box, pGC->pCompositeClip); } (*pGC->ops->PolySegment)(pDrawable, pGC, nSeg, pSeg); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); @@ -1053,33 +1004,29 @@ box.y1 = pRectsTmp->y - offset1; box.x2 = box.x1 + pRectsTmp->width + offset2; box.y2 = box.y1 + offset2; - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); + TRANSLATE_BOX(box, pDrawable); + damageDamageBox (pDrawable, &box, pGC->pCompositeClip); box.x1 = pRectsTmp->x - offset1; box.y1 = pRectsTmp->y + offset3; box.x2 = box.x1 + offset2; box.y2 = box.y1 + pRectsTmp->height - offset2; - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); + TRANSLATE_BOX(box, pDrawable); + damageDamageBox (pDrawable, &box, pGC->pCompositeClip); box.x1 = pRectsTmp->x + pRectsTmp->width - offset1; box.y1 = pRectsTmp->y + offset3; box.x2 = box.x1 + offset2; box.y2 = box.y1 + pRectsTmp->height - offset2; - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); + TRANSLATE_BOX(box, pDrawable); + damageDamageBox (pDrawable, &box, pGC->pCompositeClip); box.x1 = pRectsTmp->x - offset1; box.y1 = pRectsTmp->y + pRectsTmp->height - offset1; box.x2 = box.x1 + pRectsTmp->width + offset2; box.y2 = box.y1 + offset2; - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); + TRANSLATE_BOX(box, pDrawable); + damageDamageBox (pDrawable, &box, pGC->pCompositeClip); pRectsTmp++; } @@ -1132,9 +1079,8 @@ box.x2++; box.y2++; - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); + TRANSLATE_BOX(box, pDrawable); + damageDamageBox (pDrawable, &box, pGC->pCompositeClip); } (*pGC->ops->PolyArc)(pDrawable, pGC, nArcs, pArcs); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); @@ -1189,9 +1135,8 @@ box.x2++; box.y2++; - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); + TRANSLATE_BOX(box, pDrawable); + damageDamageBox (pDrawable, &box, pGC->pCompositeClip); } (*pGC->ops->FillPolygon)(pDrawable, pGC, shape, mode, npt, ppt); @@ -1228,9 +1173,8 @@ box.y2 = pRectsTmp->y + pRectsTmp->height; } - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); + TRANSLATE_BOX(box, pDrawable); + damageDamageBox (pDrawable, &box, pGC->pCompositeClip); } (*pGC->ops->PolyFillRect)(pDrawable, pGC, nRects, pRects); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); @@ -1269,9 +1213,8 @@ box.y2 = pArcsTmp->y + pArcsTmp->height; } - TRIM_AND_TRANSLATE_BOX(box, pDrawable, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); + TRANSLATE_BOX(box, pDrawable); + damageDamageBox (pDrawable, &box, pGC->pCompositeClip); } (*pGC->ops->PolyFillArc)(pDrawable, pGC, nArcs, pArcs); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); @@ -1284,18 +1227,17 @@ static void damageDamageChars (DrawablePtr pDrawable, - FontPtr font, + GCPtr pGC, int x, int y, unsigned int n, CharInfoPtr *charinfo, - Bool imageblt, - int subWindowMode) + Bool imageblt) { ExtentInfoRec extents; BoxRec box; - QueryGlyphExtents(font, charinfo, n, &extents); + QueryGlyphExtents(pGC->font, charinfo, n, &extents); if (imageblt) { if (extents.overallWidth > extents.overallRight) @@ -1313,7 +1255,7 @@ box.y1 = y - extents.overallAscent; box.x2 = x + extents.overallRight; box.y2 = y + extents.overallDescent; - damageDamageBox (pDrawable, &box, subWindowMode); + damageDamageBox (pDrawable, &box, pGC->pCompositeClip); } /* @@ -1356,8 +1298,8 @@ w += (*info)->metrics.characterWidth; if (n != 0) { - damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y, n, - charinfo, imageblt, pGC->subWindowMode); + damageDamageChars (pDrawable, pGC, x + pDrawable->x, y + pDrawable->y, n, + charinfo, imageblt); if (imageblt) (*pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, n, charinfo, FONTGLYPHS(pGC->font)); @@ -1456,8 +1398,8 @@ pointer pglyphBase) { DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y, - nglyph, ppci, TRUE, pGC->subWindowMode); + damageDamageChars (pDrawable, pGC, x + pDrawable->x, y + pDrawable->y, + nglyph, ppci, TRUE); (*pGC->ops->ImageGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); @@ -1473,8 +1415,8 @@ pointer pglyphBase) { DAMAGE_GC_OP_PROLOGUE(pGC, pDrawable); - damageDamageChars (pDrawable, pGC->font, x + pDrawable->x, y + pDrawable->y, - nglyph, ppci, FALSE, pGC->subWindowMode); + damageDamageChars (pDrawable, pGC, x + pDrawable->x, y + pDrawable->y, + nglyph, ppci, FALSE); (*pGC->ops->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); @@ -1505,9 +1447,7 @@ box.x2 = box.x1 + dx; box.y2 = box.y1 + dy; - TRIM_BOX(box, pGC); - if(BOX_NOT_EMPTY(box)) - damageDamageBox (pDrawable, &box, pGC->subWindowMode); + damageDamageBox (pDrawable, &box, pGC->pCompositeClip); } (*pGC->ops->PushPixels)(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg); DAMAGE_GC_OP_EPILOGUE(pGC, pDrawable); @@ -1585,7 +1525,7 @@ */ if ((what != PW_BACKGROUND || pWindow->backgroundState != None) && getWindowDamage (pWindow)) - damageDamageRegion (&pWindow->drawable, prgn, FALSE, -1); + damageDamageRegion (&pWindow->drawable, prgn); if(what == PW_BACKGROUND) { unwrap (pScrPriv, pScreen, PaintWindowBackground); (*pScreen->PaintWindowBackground) (pWindow, prgn, what); @@ -1616,7 +1556,7 @@ * at the destination location. Translate back and forth. */ REGION_TRANSLATE (pScreen, prgnSrc, dx, dy); - damageDamageRegion (&pWindow->drawable, prgnSrc, FALSE, -1); + damageDamageRegion (&pWindow->drawable, prgnSrc); REGION_TRANSLATE (pScreen, prgnSrc, -dx, -dy); } unwrap (pScrPriv, pScreen, CopyWindow); @@ -1651,7 +1591,7 @@ ScreenPtr pScreen = pWindow->drawable.pScreen; damageScrPriv(pScreen); - damageDamageRegion (&pWindow->drawable, prgn, FALSE, -1); + damageDamageRegion (&pWindow->drawable, prgn); unwrap (pScrPriv, pScreen, BackingStoreFuncs.RestoreAreas); (*pScreen->BackingStoreFuncs.RestoreAreas) (pPixmap, prgn, xorg, yorg, pWindow); @@ -1960,5 +1900,5 @@ DamageDamageRegion (DrawablePtr pDrawable, RegionPtr pRegion) { - damageDamageRegion (pDrawable, pRegion, FALSE, -1); + damageDamageRegion (pDrawable, pRegion); }