[xserver-commit] xserver/miext/damage damage.c,1.8,1.9
Keith Packard
xserver-commit@pdx.freedesktop.org
Fri, 21 Nov 2003 16:49:13 -0800
Committed by: keithp
Update of /cvs/xserver/xserver/miext/damage
In directory pdx:/tmp/cvs-serv27760/miext/damage
Modified Files:
damage.c
Log Message:
* composite/compwindow.c: (compCopyWindow):
Offset for CopyWindow was wrong; resizing under twm
demonstrated this.
* miext/damage/damage.c: (damageDamageRegion):
Clip damage to monitored drawable, not just target drawable.
This avoids accumulating damage outside the monitored window.
* render/mipict.c: (miClipPictureReg), (miComputeCompositeRegion):
Clip regions for mask/src were offset wrong.
* xfixes/region.c: (ProcXFixesCopyRegion), (SProcXFixesCopyRegion),
(ProcXFixesCombineRegion), (SProcXFixesCombineRegion),
(ProcXFixesInvertRegion), (SProcXFixesInvertRegion),
(ProcXFixesTranslateRegion), (SProcXFixesTranslateRegion):
* xfixes/xfixes.c: (XFixesNumberRequests):
* xfixes/xfixesint.h:
Eliminate offset arguments in combining operators,
create separate CopyRegion and TranslateRegion requests.
Index: damage.c
===================================================================
RCS file: /cvs/xserver/xserver/miext/damage/damage.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- damage.c 17 Nov 2003 22:09:12 -0000 1.8
+++ damage.c 22 Nov 2003 00:49:11 -0000 1.9
@@ -101,94 +101,122 @@
drawableDamage(pDrawable);
DamagePtr pNext;
RegionPtr pClip;
+ RegionRec clippedRec;
+ RegionPtr pDamageRegion;
RegionRec pixClip;
Bool was_empty;
RegionRec tmpRegion;
BoxRec tmpBox;
int draw_x, draw_y;
- int x = 0, y = 0;
- if (clip)
- {
- if (pDrawable->type == DRAWABLE_WINDOW)
- pClip = &((WindowPtr)pDrawable)->borderClip;
- else
- {
- BoxRec box;
- box.x1 = pDrawable->x;
- box.y1 = pDrawable->y;
- box.x2 = pDrawable->x + pDrawable->width;
- box.y2 = pDrawable->y + pDrawable->height;
- REGION_INIT(pScreen, &pixClip, &box, 1);
- pClip = &pixClip;
- }
- REGION_INTERSECT (pScreen, pRegion, pRegion, pClip);
- }
- DAMAGE_DEBUG (("%s %d x %d +%d +%d\n", where,
- pRegion->extents.x2 - pRegion->extents.x1,
- pRegion->extents.y2 - pRegion->extents.y1,
- pRegion->extents.x1, pRegion->extents.y1));
+ /* short circuit for empty regions */
if (!REGION_NOTEMPTY(pScreen, pRegion))
- return;
- if (pDrawable->type == DRAWABLE_WINDOW &&
- !((WindowPtr) pDrawable)->realized)
- ErrorF ("unrealized window 0x%x shouldn't get damage\n", pDrawable->id);
+ return;
+
+ REGION_INIT (pScreen, &clippedRec, NullBox, 0);
for (; pDamage; pDamage = pNext)
{
pNext = pDamage->pNext;
+ /*
+ * Check for internal damage and don't send events
+ */
if (pScrPriv->internalLevel > 0 && !pDamage->isInternal)
{
DAMAGE_DEBUG (("non internal damage, skipping at %d\n",
pScrPriv->internalLevel));
continue;
}
- draw_x = pDamage->pDrawable->x;
- draw_y = pDamage->pDrawable->y;
- if (draw_x != x || draw_y != y)
+ /*
+ * Check for unrealized windows
+ */
+ if (pDamage->pDrawable->type == DRAWABLE_WINDOW &&
+ !((WindowPtr) (pDamage->pDrawable))->realized)
{
- REGION_TRANSLATE (pScreen, pRegion, x - draw_x, y - draw_y);
- x = draw_x;
- y = draw_y;
+ DAMAGE_DEBUG (("damage while window unrealized\n"));
+ continue;
+ }
+
+ /*
+ * Clip against border or pixmap bounds
+ */
+
+ pDamageRegion = pRegion;
+ if (clip || pDamage->pDrawable != pDrawable)
+ {
+ pDamageRegion = &clippedRec;
+ if (pDamage->pDrawable->type == DRAWABLE_WINDOW)
+ pClip = &((WindowPtr)(pDamage->pDrawable))->borderClip;
+ else
+ {
+ BoxRec box;
+ box.x1 = pDamage->pDrawable->x;
+ box.y1 = pDamage->pDrawable->y;
+ box.x2 = pDamage->pDrawable->x + pDamage->pDrawable->width;
+ box.y2 = pDamage->pDrawable->y + pDamage->pDrawable->height;
+ REGION_INIT(pScreen, &pixClip, &box, 1);
+ pClip = &pixClip;
+ }
+ REGION_INTERSECT (pScreen, pDamageRegion, pRegion, pClip);
+ /*
+ * Short circuit empty results
+ */
+ if (!REGION_NOTEMPTY(pScreen, pDamageRegion))
+ continue;
}
+
+ DAMAGE_DEBUG (("%s %d x %d +%d +%d\n", where,
+ pDamageRegion->extents.x2 - pDamageRegion->extents.x1,
+ pDamageRegion->extents.y2 - pDamageRegion->extents.y1,
+ pDamageRegion->extents.x1, pDamageRegion->extents.y1));
+
+ /*
+ * Move region to target coordinate space
+ */
+ draw_x = pDamage->pDrawable->x;
+ draw_y = pDamage->pDrawable->y;
+ if (draw_x || draw_y)
+ REGION_TRANSLATE (pScreen, pDamageRegion, -draw_x, -draw_y);
+
switch (pDamage->damageLevel) {
case DamageReportRawRegion:
- (*pDamage->damageReport) (pDamage, pRegion, pDamage->closure);
+ (*pDamage->damageReport) (pDamage, pDamageRegion, pDamage->closure);
break;
case DamageReportDeltaRegion:
REGION_INIT (pScreen, &tmpRegion, NullBox, 0);
- REGION_SUBTRACT (pScreen, &tmpRegion, pRegion, &pDamage->damage);
+ REGION_SUBTRACT (pScreen, &tmpRegion, pDamageRegion, &pDamage->damage);
if (REGION_NOTEMPTY (pScreen, &tmpRegion))
{
REGION_UNION(pScreen, &pDamage->damage,
- &pDamage->damage, pRegion);
+ &pDamage->damage, pDamageRegion);
(*pDamage->damageReport) (pDamage, &tmpRegion, pDamage->closure);
}
break;
case DamageReportBoundingBox:
tmpBox = *REGION_EXTENTS (pScreen, &pDamage->damage);
REGION_UNION(pScreen, &pDamage->damage,
- &pDamage->damage, pRegion);
+ &pDamage->damage, pDamageRegion);
if (!BOX_SAME (&tmpBox, REGION_EXTENTS (pScreen, &pDamage->damage)))
(*pDamage->damageReport) (pDamage, &pDamage->damage, pDamage->closure);
break;
case DamageReportNonEmpty:
was_empty = !REGION_NOTEMPTY(pScreen, &pDamage->damage);
REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
- pRegion);
+ pDamageRegion);
if (was_empty && REGION_NOTEMPTY(pScreen, &pDamage->damage))
(*pDamage->damageReport) (pDamage, &pDamage->damage, pDamage->closure);
break;
case DamageReportNone:
REGION_UNION(pScreen, &pDamage->damage, &pDamage->damage,
- pRegion);
+ pDamageRegion);
break;
}
+ /*
+ * translate original region back
+ */
+ if (pDamageRegion == pRegion && (draw_x || draw_y))
+ REGION_TRANSLATE (pScreen, pDamageRegion, draw_x, draw_y);
}
- if (!clip)
- {
- if (x || y)
- REGION_TRANSLATE (pScreen, pRegion, x, y);
- }
+ REGION_UNINIT (pScreen, &clippedRec);
}
#if DAMAGE_DEBUG_ENABLE