summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2011-03-29 13:06:36 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2011-03-30 14:24:44 -0400
commit181f7ffa13a41641bd67bcaa1101b1d3a241eda2 (patch)
treea2b8c375a0553ffbbd448d5331e0532e4f19cbc0
parent5a791e6e093573434b75134449763456ca7b72cb (diff)
Add RegionInitBoxes(), and fix some buggy callers of RegionInit().
The interface to RegionInit(): RegionInit (RegionPtr pReg, BoxPtr rect, int size); is very confusing because it doesn't take a list of boxes, it takes *one* box, but if that box is NULL, it initializes an empty region with 'size' rectangles preallocated. Most callers of this function were correctly passing either NULL or just one box, but there were three confused cases, where the code seems to expect a region to be created from a list of boxes. This patch adds a new function RegionInitBoxes() and fixes those instances to call that instead. And yes, the pixman function to initialize a region from a list of boxes is called init_rects() because pixman is also awesome. V2: Make RegionInitBoxes() return a Bool indicating whether the call succeeded, and fix the callers to check this return value. Reviewed-by: Keith Packard <keithp@keithp.com> Signed-off-by: Søren Sandmann <ssp@redhat.com>
-rw-r--r--exa/exa_unaccel.c7
-rw-r--r--glx/glxdri.c19
-rw-r--r--include/regionstr.h5
3 files changed, 22 insertions, 9 deletions
diff --git a/exa/exa_unaccel.c b/exa/exa_unaccel.c
index bd533c402..078b91c77 100644
--- a/exa/exa_unaccel.c
+++ b/exa/exa_unaccel.c
@@ -127,11 +127,10 @@ ExaCheckCopyNtoN (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
EXA_FALLBACK(("from %p to %p (%c,%c)\n", pSrc, pDst,
exaDrawableLocation(pSrc), exaDrawableLocation(pDst)));
- if (pExaScr->prepare_access_reg) {
+ if (pExaScr->prepare_access_reg && RegionInitBoxes(&reg, pbox, nbox)) {
PixmapPtr pPixmap = exaGetDrawablePixmap(pSrc);
exaGetDrawableDeltas(pSrc, pPixmap, &xoff, &yoff);
- RegionInit(&reg, pbox, nbox);
RegionTranslate(&reg, xoff + dx, yoff + dy);
pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_SRC, &reg);
RegionUninit(&reg);
@@ -140,11 +139,11 @@ ExaCheckCopyNtoN (DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
if (pExaScr->prepare_access_reg &&
!exaGCReadsDestination(pDst, pGC->planemask, pGC->fillStyle,
- pGC->alu, pGC->clientClipType)) {
+ pGC->alu, pGC->clientClipType) &&
+ RegionInitBoxes (&reg, pbox, nbox)) {
PixmapPtr pPixmap = exaGetDrawablePixmap(pDst);
exaGetDrawableDeltas(pSrc, pPixmap, &xoff, &yoff);
- RegionInit(&reg, pbox, nbox);
RegionTranslate(&reg, xoff, yoff);
pExaScr->prepare_access_reg(pPixmap, EXA_PREPARE_DEST, &reg);
RegionUninit(&reg);
diff --git a/glx/glxdri.c b/glx/glxdri.c
index 3a573372a..a2afbc2ce 100644
--- a/glx/glxdri.c
+++ b/glx/glxdri.c
@@ -831,11 +831,20 @@ static void __glXReportDamage(__DRIdrawable *driDraw,
__glXenterServer(GL_FALSE);
- RegionInit(&region, (BoxPtr) rects, num_rects);
- RegionTranslate(&region, pDraw->x, pDraw->y);
- DamageDamageRegion(pDraw, &region);
- RegionUninit(&region);
-
+ if (RegionInitBoxes(&region, (BoxPtr) rects, num_rects)) {
+ RegionTranslate(&region, pDraw->x, pDraw->y);
+ DamageDamageRegion(pDraw, &region);
+ RegionUninit(&region);
+ }
+ else {
+ while (num_rects--) {
+ RegionInit (&region, (BoxPtr) rects++, 1);
+ RegionTranslate(&region, pDraw->x, pDraw->y);
+ DamageDamageRegion(pDraw, &region);
+ RegionUninit(&region);
+ }
+ }
+
__glXleaveServer(GL_FALSE);
}
diff --git a/include/regionstr.h b/include/regionstr.h
index 3759fe17b..3dfef5c83 100644
--- a/include/regionstr.h
+++ b/include/regionstr.h
@@ -132,6 +132,11 @@ static inline void RegionInit(RegionPtr _pReg, BoxPtr _rect, int _size)
}
}
+static inline Bool RegionInitBoxes(RegionPtr pReg, BoxPtr boxes, int nBoxes)
+{
+ return pixman_region_init_rects (pReg, boxes, nBoxes);
+}
+
static inline void RegionUninit(RegionPtr _pReg)
{
if ((_pReg)->data && (_pReg)->data->size) {