From 61a92a78cd49969f74a046fa26c3199e06365814 Mon Sep 17 00:00:00 2001 From: Søren Sandmann Pedersen Date: Tue, 29 Mar 2011 13:06:36 -0400 Subject: Add RegionInitBoxes(), and fix some buggy callers of RegionInit(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Søren Sandmann --- glx/glxdri.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'glx') diff --git a/glx/glxdri.c b/glx/glxdri.c index c87ac9a65..244eac6c2 100644 --- a/glx/glxdri.c +++ b/glx/glxdri.c @@ -817,10 +817,19 @@ static void __glXReportDamage(__DRIdrawable *driDraw, __glXenterServer(GL_FALSE); - RegionInit(®ion, (BoxPtr) rects, num_rects); - RegionTranslate(®ion, pDraw->x, pDraw->y); - DamageDamageRegion(pDraw, ®ion); - RegionUninit(®ion); + if (RegionInitBoxes(®ion, (BoxPtr) rects, num_rects)) { + RegionTranslate(®ion, pDraw->x, pDraw->y); + DamageDamageRegion(pDraw, ®ion); + RegionUninit(®ion); + } + else { + while (num_rects--) { + RegionInit (®ion, (BoxPtr) rects++, 1); + RegionTranslate(®ion, pDraw->x, pDraw->y); + DamageDamageRegion(pDraw, ®ion); + RegionUninit(®ion); + } + } __glXleaveServer(GL_FALSE); } -- cgit v1.2.3