/** * Vertically invert a region. */ static void InvertRegion(RegionPtr reg, int height) { const BoxPtr b = REGION_RECTS(reg); const int n = REGION_NUM_RECTS(reg); int i; RegionRec newRegion; miRegionInit(&newRegion, NULL, 0); CRASSERT(miValidRegion(reg)); for (i = 0; i < n; i++) { BoxRec invBox; RegionRec invReg; invBox.x1 = b[i].x1; invBox.y1 = height - b[i].y2; invBox.x2 = b[i].x2; invBox.y2 = height - b[i].y1; CRASSERT(invBox.y1 <= invBox.y2); miRegionInit(&invReg, &invBox, 1); REGION_UNION(&newRegion, &newRegion, &invReg); REGION_UNINIT(&invReg); } CRASSERT(miValidRegion(&newRegion)); REGION_COPY(reg, &newRegion); REGION_UNINIT(&newRegion); }
// FIXME: Make BoxRec and Rect identical to get rid of conversions. Region::Region(const Rect *rect) { if (!rect->isEmpty()) { BoxRec box; box.x1 = rect->left; box.x2 = rect->right; box.y1 = rect->top; box.y2 = rect->bottom; miRegionInit(&m_reg, &box, 0); } else { miRegionInit(&m_reg, NullBox, 0); } }
/** * Union the window's accum-dirty and prev-accum-dirty regions with the * incoming region. * Called by crHashtableWalk() via vncspuGetScreenRects(). */ static void WindowDirtyUnionCB(unsigned long key, void *windowData, void *regionData) { WindowInfo *window = (WindowInfo *) windowData; RegionPtr regionUnion = (RegionPtr) regionData; RegionRec accumScrn; /* accumulated region, in screen coords */ Bool overlap; miRegionInit(&accumScrn, NULL, 0); /* init local var */ CRASSERT(miValidRegion(&window->accumDirtyRegion)); CRASSERT(miValidRegion(&window->prevAccumDirtyRegion)); /* crDebug("accum area: %d prev accum: %d", miRegionArea(&window->accumDirtyRegion), miRegionArea(&window->prevAccumDirtyRegion)); */ /* at first, accumScrn region is in window coords */ REGION_UNION(&accumScrn, &window->accumDirtyRegion, &window->prevAccumDirtyRegion); /* intersect with window bounds */ REGION_INTERSECT(&accumScrn, &accumScrn, &window->clipRegion); REGION_VALIDATE(&accumScrn, &overlap); /* change y=0=bottom to y=0=top */ InvertRegion(&accumScrn, window->height ? window->height : 1); if (REGION_NUM_RECTS(&accumScrn) == 1 && accumScrn.extents.x1 == 0 && accumScrn.extents.y1 == 0 && accumScrn.extents.x2 == 1 && accumScrn.extents.y2 == 1) { /* empty / sentinal region */ } else { /* add window offset */ miTranslateRegion(&accumScrn, window->xPos, window->yPos); } /* now, accumScrn region is in screen coords */ REGION_UNION(regionUnion, regionUnion, &accumScrn); REGION_UNINIT(&accumScrn); /* done with local var */ }
Region::Region(const Region &src) { miRegionInit(&m_reg, NullBox, 0); set(&src); }
Region::Region() { miRegionInit(&m_reg, NullBox, 0); }