52 #if defined(Q_OS_UNIX) || defined(Q_WS_WIN) 304 #if defined(Q_WS_X11) 305 else if (
d->xrectangles) {
306 free(
d->xrectangles);
313 #define QRGN_SETRECT 1 // region stream commands 314 #define QRGN_SETELLIPSE 2 // (these are internal) 315 #define QRGN_SETPTARRAY_ALT 3 316 #define QRGN_SETPTARRAY_WIND 4 317 #define QRGN_TRANSLATE 5 322 #define QRGN_RECTS 10 325 #ifndef QT_NO_DATASTREAM 358 qWarning(
"QRegion::exec: Internal error");
400 for (
int i=0; i<(int)n; i++) {
454 for (i = a.
size() - 1; i > 0; --i) {
458 for (i = 0; i < a.
size(); ++i) {
489 #endif //QT_NO_DATASTREAM 491 #ifndef QT_NO_DEBUG_STREAM 495 s.
nospace() <<
"QRegion(size=" << rects.
size() <<
"), " 497 for (
int i=0; i<rects.
size(); ++i)
498 s <<
"- " << i << rects.
at(i) <<
'\n';
577 {
return *
this = *
this | r; }
601 #if !defined (Q_OS_UNIX) && !defined (Q_WS_WIN) 621 {
return *
this = *
this & r; }
627 #if defined (Q_OS_UNIX) || defined (Q_WS_WIN) 630 return *
this = *
this & r;
652 {
return *
this = *
this - r; }
662 {
return *
this = *
this ^ r; }
798 #if !defined (Q_OS_UNIX) && !defined (Q_WS_WIN) 1071 return qMin(point.x(), next->point.x());
1076 return qMax(point.x(), next->point.x());
1079 bool overlaps(
const Segment &other)
const 1081 return left() < other.right() && other.left() <
right();
1084 void connect(Segment &other)
1089 horizontal = (point.y() == other.point.y());
1092 void merge(Segment &other)
1094 if (
right() <= other.right()) {
1096 Segment *oprev = other.prev;
1098 other.point = point;
1100 prev->next = &other;
1106 Segment *onext = other.next;
1108 next->prev = &other;
1123 void mergeSegments(Segment *
a,
int na, Segment *b,
int nb)
1128 while (i != na && j != nb) {
1131 const int ra = sa.right();
1132 const int rb = sb.right();
1133 if (sa.overlaps(sb))
1140 void addSegmentsToPath(Segment *segment,
QPainterPath &path)
1142 Segment *current = segment;
1143 path.
moveTo(current->point);
1145 current->added =
true;
1147 Segment *last = current;
1148 current = current->next;
1149 while (current != segment) {
1150 if (current->horizontal != last->horizontal)
1151 path.
lineTo(current->point);
1152 current->added =
true;
1154 current = current->next;
1176 int lastRowSegmentCount = 0;
1177 Segment *lastRowSegments = 0;
1179 int lastSegment = 0;
1181 while (rect != end) {
1182 const int y = rect[0].
y();
1184 while (&rect[count] != end && rect[count].y() == y)
1187 for (
int i = 0; i < count; ++i) {
1188 int offset = lastSegment + i;
1189 segments[offset] = Segment(rect[i].topLeft());
1190 segments[offset += count] = Segment(rect[i].topRight() +
QPoint(1, 0));
1191 segments[offset += count] = Segment(rect[i].bottomRight() +
QPoint(1, 1));
1192 segments[offset += count] = Segment(rect[i].bottomLeft() +
QPoint(0, 1));
1194 offset = lastSegment + i;
1195 for (
int j = 0; j < 4; ++j)
1196 segments[offset + j * count].connect(segments[offset + ((j + 1) % 4) * count]);
1199 if (lastRowSegments && lastY == y)
1200 mergeSegments(lastRowSegments, lastRowSegmentCount, &segments[lastSegment], count);
1202 lastRowSegments = &segments[lastSegment + 2 * count];
1203 lastRowSegmentCount = count;
1204 lastSegment += 4 * count;
1205 lastY = y + rect[0].
height();
1209 for (
int i = 0; i < lastSegment; ++i) {
1210 Segment *segment = &segments[i];
1211 if (!segment->added)
1212 addSegmentsToPath(segment, result);
1218 #if defined(Q_OS_UNIX) || defined(Q_WS_WIN) 1268 const QRect &r1 = innerRect;
1277 const QRect &r2 = extents;
1284 if (area > innerArea) {
1291 if (numRects == 1) {
1298 inline void append(
const QRect *r);
1300 void prepend(
const QRect *r);
1302 inline bool canAppend(
const QRect *r)
const;
1304 inline bool canPrepend(
const QRect *r)
const;
1308 inline bool mergeFromLeft(
QRect *left,
const QRect *right);
1309 inline bool mergeFromBelow(
QRect *top,
const QRect *bottom,
1310 const QRect *nextToTop,
1311 const QRect *nextToBottom);
1312 inline bool mergeFromAbove(
QRect *bottom,
const QRect *top,
1313 const QRect *nextToBottom,
1314 const QRect *nextToTop);
1316 #ifdef QT_REGION_DEBUG 1317 void selfTest()
const;
1323 return !preg || preg->
numRects == 0;
1328 return (right->
top() == left->
top()
1330 && right->
left() <= (left->
right() + 1));
1342 updateInnerRect(*left);
1352 updateInnerRect(*right);
1359 const QRect *nextToTop,
1360 const QRect *nextToBottom)
1362 if (nextToTop && nextToTop->
y() == top->
y())
1364 if (nextToBottom && nextToBottom->
y() == bottom->
y())
1367 return ((top->
bottom() >= (bottom->
top() - 1))
1373 const QRect *nextToTop,
1374 const QRect *nextToBottom)
1378 updateInnerRect(*top);
1385 const QRect *nextToBottom,
1386 const QRect *nextToTop)
1390 updateInnerRect(*bottom);
1409 Q_ASSERT(extents.intersects(rect));
1412 #ifdef QT_REGION_DEBUG 1418 innerRect =
QRect();
1422 const QRect *src = dest;
1436 extents.setRight(
qMax(extents.right(), dest->
right()));
1437 extents.setBottom(
qMax(extents.bottom(), dest->
bottom()));
1443 if (!n || src->
y() != dest->
y() || src->
left() > r.
right()) {
1444 QRect *prev = dest - 1;
1446 updateInnerRect(*prev);
1451 updateInnerRect(*dest);
1455 #ifdef QT_REGION_DEBUG 1465 if (mergeFromRight(myLast, r)) {
1468 if (mergeFromBelow(myLast - 1, myLast, nextToTop, 0))
1471 }
else if (mergeFromBelow(myLast, r, (
numRects > 1 ? myLast - 1 : 0), 0)) {
1476 updateInnerRect(*r);
1482 qMin(extents.top(), r->
top()),
1486 #ifdef QT_REGION_DEBUG 1508 const QRect *rFirst = srcRect;
1509 QRect *myLast = destRect - 1;
1511 if (mergeFromRight(myLast, rFirst)) {
1514 const QRect *rNextToFirst = (numAppend > 1 ? rFirst + 2 : 0);
1515 if (mergeFromBelow(myLast, rFirst + 1, nextToLast, rNextToFirst)) {
1520 nextToLast = (
numRects > 2 ? myLast - 2 : 0);
1521 rNextToFirst = (numAppend > 0 ? srcRect : 0);
1522 if (mergeFromBelow(myLast - 1, myLast, nextToLast, rNextToFirst)) {
1527 }
else if (mergeFromBelow(myLast, rFirst, nextToLast, rFirst + 1)) {
1534 if (numAppend > 0) {
1535 const int newNumRects =
numRects + numAppend;
1540 memcpy(destRect, srcRect, numAppend *
sizeof(
QRect));
1546 if (innerArea < r->innerArea) {
1552 destRect = &extents;
1559 #ifdef QT_REGION_DEBUG 1581 const QRect *nextToFirst = (
numRects > 1 ? myFirst + 1 : 0);
1583 const QRect *rNextToLast = (r->
numRects > 1 ? rLast - 1 : 0);
1584 if (mergeFromLeft(myFirst, rLast)) {
1587 rNextToLast = (numPrepend > 1 ? rLast - 1 : 0);
1588 if (mergeFromAbove(myFirst, rLast, nextToFirst, rNextToLast)) {
1593 nextToFirst = (
numRects > 2? myFirst + 2 : 0);
1594 rNextToLast = (numPrepend > 0 ? rLast : 0);
1595 if (mergeFromAbove(myFirst + 1, myFirst, nextToFirst, rNextToLast)) {
1600 }
else if (mergeFromAbove(myFirst, rLast, nextToFirst, rNextToLast)) {
1605 if (numPrepend > 0) {
1606 const int newNumRects =
numRects + numPrepend;
1621 if (innerArea < r->innerArea) {
1632 #ifdef QT_REGION_DEBUG 1642 if (mergeFromLeft(myFirst, r)) {
1644 const QRect *nextToFirst = (
numRects > 2 ? myFirst + 2 : 0);
1645 if (mergeFromAbove(myFirst + 1, myFirst, nextToFirst, 0)) {
1651 }
else if (mergeFromAbove(myFirst, r, (
numRects > 1 ? myFirst + 1 : 0), 0)) {
1656 updateInnerRect(*r);
1659 extents.setCoords(
qMin(extents.left(), r->
left()),
1660 qMin(extents.top(), r->
top()),
1664 #ifdef QT_REGION_DEBUG 1674 if (r->
top() > myLast->bottom())
1676 if (r->
top() == myLast->top()
1677 && r->
height() == myLast->height()
1678 && r->
left() > myLast->right())
1696 if (r->
bottom() < myFirst->top())
1698 if (r->
top() == myFirst->top()
1699 && r->
height() == myFirst->height()
1700 && r->
right() < myFirst->left())
1713 #ifdef QT_REGION_DEBUG 1714 void QRegionPrivate::selfTest()
const 1722 Q_ASSERT(innerArea == (innerRect.width() * innerRect.height()));
1730 for (
int i = 0; i <
numRects; ++i) {
1733 qDebug() <<
"selfTest(): innerRect" << innerRect <<
'<' << r;
1737 for (
int i = 1; i <
numRects; ++i) {
1740 if (r2.
y() == r.
y()) {
1749 #endif // QT_REGION_DEBUG 1751 #if defined(Q_WS_X11) 1755 #elif defined(Q_WS_MAC) 1759 #elif defined(Q_WS_WIN) 1763 #elif defined(Q_WS_QWS) || defined(Q_WS_QPA) 1769 register const QRect *r2,
const QRect *r2End,
register int y1,
register int y2);
1771 register int y1,
register int y2);
1779 #define RectangleOut 0 1780 #define RectangleIn 1 1781 #define RectanglePart 2 1782 #define EvenOddRule 0 1783 #define WindingRule 1 1846 #define EXTENTCHECK(r1, r2) \ 1847 ((r1)->right() >= (r2)->left() && \ 1848 (r1)->left() <= (r2)->right() && \ 1849 (r1)->bottom() >= (r2)->top() && \ 1850 (r1)->top() <= (r2)->bottom()) 1855 #define EXTENTS(r,idRect){\ 1856 if((r)->left() < (idRect)->extents.left())\ 1857 (idRect)->extents.setLeft((r)->left());\ 1858 if((r)->top() < (idRect)->extents.top())\ 1859 (idRect)->extents.setTop((r)->top());\ 1860 if((r)->right() > (idRect)->extents.right())\ 1861 (idRect)->extents.setRight((r)->right());\ 1862 if((r)->bottom() > (idRect)->extents.bottom())\ 1863 (idRect)->extents.setBottom((r)->bottom());\ 1869 #define MEMCHECK(dest, rect, firstrect){\ 1870 if ((dest).numRects >= ((dest).rects.size()-1)){\ 1871 firstrect.resize(firstrect.size() * 2); \ 1872 (rect) = (firstrect).data() + (dest).numRects;\ 1881 #define NUMPTSTOBUFFER 200 2007 register const QRect *pBox,
2009 register QRect *pExtents;
2023 pBoxEnd = pBox + dest.
numRects - 1;
2038 while (pBox <= pBoxEnd) {
2039 if (pBox->
left() < pExtents->
left())
2058 register int nbox = region.
numRects;
2086 register const QRect *r2,
const QRect *r2End,
int y1,
int y2)
2090 register QRect *pNextRect;
2094 while (r1 != r1End && r2 != r2End) {
2152 register QRect *pPrevBox;
2153 register QRect *pCurBox;
2154 register QRect *pRegEnd;
2162 pPrevBox = rData + prevStart;
2163 prevNumRects = curStart - prevStart;
2170 pCurBox = rData + curStart;
2171 bandY1 = pCurBox->
top();
2172 for (curNumRects = 0; pCurBox != pRegEnd && pCurBox->
top() == bandY1; ++curNumRects) {
2176 if (pCurBox != pRegEnd) {
2184 while ((pRegEnd - 1)->top() == pRegEnd->
top())
2186 curStart = pRegEnd - rData;
2190 if (curNumRects == prevNumRects && curNumRects != 0) {
2191 pCurBox -= curNumRects;
2196 if (pPrevBox->
bottom() == pCurBox->
top() - 1) {
2211 }
while (prevNumRects != 0);
2214 pCurBox -= curNumRects;
2215 pPrevBox -= curNumRects;
2228 }
while (curNumRects != 0);
2240 if (pCurBox == pRegEnd) {
2241 curStart = prevStart;
2244 *pPrevBox++ = *pCurBox++;
2246 }
while (pCurBox != pRegEnd);
2284 register const QRect *r1;
2285 register const QRect *r2;
2292 register const QRect *r1BandEnd;
2293 register const QRect *r2BandEnd;
2371 while (r1BandEnd != r1End && r1BandEnd->
top() == r1->
top())
2375 while (r2BandEnd != r2End && r2BandEnd->
top() == r2->
top())
2386 if (r1->
top() < r2->
top()) {
2387 top =
qMax(r1->
top(), ybot + 1);
2390 if (nonOverlap1Func != 0 && bot >= top)
2391 (*nonOverlap1Func)(dest, r1, r1BandEnd, top, bot);
2393 }
else if (r2->
top() < r1->
top()) {
2394 top =
qMax(r2->
top(), ybot + 1);
2397 if (nonOverlap2Func != 0 && bot >= top)
2398 (*nonOverlap2Func)(dest, r2, r2BandEnd, top, bot);
2411 prevBand =
miCoalesce(dest, prevBand, curBand);
2420 (*overlapFunc)(dest, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot);
2422 if (dest.numRects != curBand)
2423 prevBand =
miCoalesce(dest, prevBand, curBand);
2429 if (r1->bottom() == ybot)
2431 if (r2->bottom() == ybot)
2433 }
while (r1 != r1End && r2 != r2End);
2440 if (nonOverlap1Func != 0) {
2443 while (r1BandEnd < r1End && r1BandEnd->top() == r1->
top())
2445 (*nonOverlap1Func)(dest, r1, r1BandEnd,
qMax(r1->top(), ybot + 1), r1->bottom());
2447 }
while (r1 != r1End);
2449 }
else if ((r2 != r2End) && (nonOverlap2Func != 0)) {
2452 while (r2BandEnd < r2End && r2BandEnd->top() == r2->
top())
2454 (*nonOverlap2Func)(dest, r2, r2BandEnd,
qMax(r2->top(), ybot + 1), r2->bottom());
2456 }
while (r2 != r2End);
2496 register int y1,
register int y2)
2498 register QRect *pNextRect;
2532 register const QRect *r2,
const QRect *r2End,
register int y1,
register int y2)
2534 register QRect *pNextRect;
2538 #define MERGERECT(r) \ 2539 if ((dest.numRects != 0) && \ 2540 (pNextRect[-1].top() == y1) && \ 2541 (pNextRect[-1].bottom() == y2) && \ 2542 (pNextRect[-1].right() >= r->left()-1)) { \ 2543 if (pNextRect[-1].right() < r->right()) { \ 2544 pNextRect[-1].setRight(r->right()); \ 2545 dest.updateInnerRect(pNextRect[-1]); \ 2546 Q_ASSERT(pNextRect[-1].left() <= pNextRect[-1].right()); \ 2549 MEMCHECK(dest, pNextRect, dest.rects) \ 2550 pNextRect->setCoords(r->left(), y1, r->right(), y2); \ 2551 dest.updateInnerRect(*pNextRect); \ 2558 while (r1 != r1End && r2 != r2End) {
2569 }
while (r1 != r1End);
2571 while (r2 != r2End) {
2621 const QRect *rEnd,
register int y1,
register int y2)
2623 register QRect *pNextRect;
2655 register const QRect *r2,
const QRect *r2End,
register int y1,
register int y2)
2657 register QRect *pNextRect;
2665 while (r1 != r1End && r2 != r2End) {
2666 if (r2->
right() < x1) {
2671 }
else if (r2->
left() <= x1) {
2675 x1 = r2->
right() + 1;
2676 if (x1 > r1->
right()) {
2699 x1 = r2->
right() + 1;
2700 if (x1 > r1->
right()) {
2715 if (r1->
right() >= x1) {
2730 while (r1 != r1End) {
2823 for (
int i = 0; i < r1->
numRects; ++i, ++rr1, ++rr2) {
2844 for (i = 0; i < pRegion->
numRects; ++i) {
2853 register const QRect *pbox;
2854 register const QRect *pboxEnd;
2855 QRect rect(rx, ry, rwidth, rheight);
2856 register QRect *prect = ▭
2857 int partIn, partOut;
2868 for (; pbox < pboxEnd; ++pbox) {
2872 if (pbox->
top() > ry) {
2874 if (partIn || pbox->
top() > prect->
bottom())
2879 if (pbox->
right() < rx)
2882 if (pbox->
left() > rx) {
2896 if (ry > prect->
bottom())
2998 #define BRESINITPGON(dy, x1, x2, xStart, d, m, m1, incr1, incr2) { \ 3007 dx = (x2) - xStart; \ 3011 incr1 = -2 * dx + 2 * (dy) * m1; \ 3012 incr2 = -2 * dx + 2 * (dy) * m; \ 3013 d = 2 * m * (dy) - 2 * dx - 2 * (dy); \ 3017 incr1 = 2 * dx - 2 * (dy) * m1; \ 3018 incr2 = 2 * dx - 2 * (dy) * m; \ 3019 d = -2 * m * (dy) + 2 * dx; \ 3024 #define BRESINCRPGON(d, minval, m, m1, incr1, incr2) { \ 3062 #define BRESINITPGONSTRUCT(dmaj, min1, min2, bres) \ 3063 BRESINITPGON(dmaj, min1, min2, bres.minor_axis, bres.d, \ 3064 bres.m, bres.m1, bres.incr1, bres.incr2) 3066 #define BRESINCRPGONSTRUCT(bres) \ 3067 BRESINCRPGON(bres.d, bres.minor_axis, bres.m, bres.m1, bres.incr1, bres.incr2) 3121 #define COUNTERCLOCKWISE -1 3152 #define SLLSPERBLOCK 25 3174 #define EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) { \ 3175 if (pAET->ymax == y) { \ 3176 pPrevAET->next = pAET->next; \ 3177 pAET = pPrevAET->next; \ 3180 pAET->back = pPrevAET; \ 3183 BRESINCRPGONSTRUCT(pAET->bres) \ 3185 pAET = pAET->next; \ 3197 #define EVALUATEEDGEEVENODD(pAET, pPrevAET, y) { \ 3198 if (pAET->ymax == y) { \ 3199 pPrevAET->next = pAET->next; \ 3200 pAET = pPrevAET->next; \ 3202 pAET->back = pPrevAET; \ 3205 BRESINCRPGONSTRUCT(pAET->bres) \ 3207 pAET = pAET->next; \ 3262 #define LARGE_COORDINATE INT_MAX 3263 #define SMALL_COORDINATE INT_MIN 3285 pSLL = pPrevSLL->
next;
3286 while (pSLL && (pSLL->
scanline < scanline)) {
3294 if ((!pSLL) || (pSLL->
scanline > scanline)) {
3300 (*SLLBlock)->next = tmpSLLBlock;
3302 *SLLBlock = tmpSLLBlock;
3305 pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]);
3309 pPrevSLL->
next = pSLL;
3320 start = start->
next;
3359 register const QPoint *top,
3383 pSLLBlock->
next = 0;
3385 PrevPt = &pts[count - 1];
3398 if (PrevPt->
y() > CurrPt->
y()) {
3411 if (bottom->
y() != top->
y()) {
3412 pETEs->
ymax = bottom->
y() - 1;
3417 dy = bottom->
y() - top->
y();
3422 if (PrevPt->
y() > ET->
ymax)
3423 ET->
ymax = PrevPt->
y();
3424 if (PrevPt->
y() < ET->
ymin)
3425 ET->
ymin = PrevPt->
y();
3458 ETEs->
back = pPrevAET;
3459 pPrevAET->
next = ETEs;
3489 register int inside = 1;
3490 register int isInside = 0;
3501 if ((!inside && !isInside) || (inside && isInside)) {
3525 register int changed = 0;
3532 pETEchase = pETEchase->
back;
3535 if (pETEchase != pETEinsert) {
3536 pETEchaseBackTMP = pETEchase->
back;
3540 pETEinsert->
next = pETEchase;
3541 pETEchase->
back->
next = pETEinsert;
3542 pETEchase->
back = pETEinsert;
3543 pETEinsert->
back = pETEchaseBackTMP;
3558 tmpSLLBlock = pSLLBlock->
next;
3560 pSLLBlock = tmpSLLBlock;
3578 bool canExtend = reg->
rects.
size() - *lastRow == numSpans
3579 && !(*needsExtend && *extendTo + 1 != y)
3580 && (*needsExtend || regRects[0].y() + regRects[0].
height() == y);
3582 for (
int i = 0; i < numSpans && canExtend; ++i) {
3583 if (regRects[i].x() != spans[i].
x1 || regRects[i].
right() != spans[i].
x2 - 1)
3589 *needsExtend =
true;
3592 for (
int i = 0; i < reg->
rects.
size() - *lastRow; ++i)
3593 regRects[i].setBottom(*extendTo);
3598 for (
int i = 0; i < numSpans; ++i)
3599 reg->
rects <<
QRect(spans[i].x1, y, spans[i].width(), 1);
3601 if (spans[0].x1 < reg->extents.left())
3607 *needsExtend =
false;
3619 static void PtsToRegion(
register int numFullPtBlocks,
register int iCurPtBlock,
3624 bool needsExtend =
false;
3633 for (; numFullPtBlocks >= 0; --numFullPtBlocks) {
3636 if (!numFullPtBlocks)
3637 i = iCurPtBlock >> 1;
3640 for (
QPoint *pts = CurPtBlock->
pts; i--; pts += 2) {
3641 const int width = pts[1].x() - pts[0].x();
3643 if (rowSize && row[rowSize-1].x2 == pts[0].x())
3644 row[rowSize-1].x2 = pts[1].x();
3646 row[rowSize++] =
QRegionSpan(pts[0].x(), pts[1].x());
3650 QPoint *next = i ? &pts[2] : (numFullPtBlocks ? CurPtBlock->
next->
pts : 0);
3652 if (!next || next->
y() != pts[0].y()) {
3653 flushRow(row.
data(), pts[0].y(), rowSize, reg, &lastRow, &extendTo, &needsExtend);
3659 CurPtBlock = CurPtBlock->
next;
3663 for (
int i = lastRow; i < reg->
rects.
size(); ++i)
3664 reg->
rects[i].setBottom(extendTo);
3673 for (
int i = 0; i < reg->
rects.
size(); ++i)
3697 register int iPts = 0;
3706 int fixWAET =
false;
3708 FirstPtBlock.
pts =
reinterpret_cast<QPoint *
>(FirstPtBlock.
data);
3710 int numFullPtBlocks = 0;
3716 if (((Count == 4) ||
3717 ((Count == 5) && (Pts[4].x() == Pts[0].x()) && (Pts[4].y() == Pts[0].y())))
3718 && (((Pts[0].
y() == Pts[1].
y()) && (Pts[1].x() == Pts[2].
x()) && (Pts[2].y() == Pts[3].
y())
3719 && (Pts[3].x() == Pts[0].
x())) || ((Pts[0].
x() == Pts[1].
x())
3720 && (Pts[1].y() == Pts[2].
y()) && (Pts[2].x() == Pts[3].
x())
3721 && (Pts[3].y() == Pts[0].
y())))) {
3722 int x =
qMin(Pts[0].x(), Pts[2].x());
3724 int y =
qMin(Pts[0].y(), Pts[2].y());
3737 if (!(pETEs = static_cast<EdgeTableEntry *>(malloc(
sizeof(
EdgeTableEntry) * Count))))
3742 pts = FirstPtBlock.
pts;
3746 curPtBlock = &FirstPtBlock;
3752 qWarning(
"QRegion: creating region from big polygon failed...!");
3764 for (y = ET.
ymin; y < ET.
ymax; ++y) {
3792 tmpPtBlock->
pts =
reinterpret_cast<QPoint *
>(tmpPtBlock->
data);
3793 curPtBlock->
next = tmpPtBlock;
3794 curPtBlock = tmpPtBlock;
3795 pts = curPtBlock->
pts;
3807 for (y = ET.
ymin; y < ET.
ymax; ++y) {
3829 if (pWETE == pAET) {
3840 tmpPtBlock->
pts =
reinterpret_cast<QPoint *
>(tmpPtBlock->
data);
3841 curPtBlock->
next = tmpPtBlock;
3842 curPtBlock = tmpPtBlock;
3843 pts = curPtBlock->
pts;
3864 PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
3865 for (curPtBlock = FirstPtBlock.
next; --numFullPtBlocks >= 0;) {
3866 tmpPtBlock = curPtBlock->
next;
3868 curPtBlock = tmpPtBlock;
3875 PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
3876 for (curPtBlock = FirstPtBlock.
next; --numFullPtBlocks >= 0;) {
3877 tmpPtBlock = curPtBlock->
next;
3879 curPtBlock = tmpPtBlock;
3896 xr.setCoords(prev1, y, x-1, y); \ 3897 UnionRectWithRegion(&xr, region, *region); \ 3905 for (y = 0; y < image.
height(); ++y) {
3907 int w = image.
width();
3910 for (x = 0; x < w;) {
3911 uchar byte = line[x / 8];
3912 if (x > w - 8 || byte!=all) {
3914 for (
int b = 8; b > 0 && x < w; --b) {
3915 if (!(byte & 0x01) == !all) {
3931 for (
int b = 8; b > 0 && x < w; --b) {
3932 if (!(byte & 0x80) == !all) {
3975 #if defined(Q_WS_X11) 3978 #elif defined(Q_WS_WIN) 3994 if (a.
count() > 2) {
4000 #if defined(Q_WS_X11) 4003 #elif defined(Q_WS_WIN) 4032 #if defined(Q_WS_X11) 4035 #elif defined(Q_WS_WIN) 4045 #if defined(Q_WS_X11) 4047 XDestroyRegion(x->
rgn);
4049 free(x->xrectangles);
4050 #elif defined(Q_WS_WIN) 4082 #if defined(Q_WS_X11) 4085 #elif defined(Q_WS_WIN) 4331 #ifdef QT_REGION_DEBUG 4339 #ifdef QT_REGION_DEBUG 4377 #if defined(Q_WS_QWS) || defined(Q_WS_QPA) 4385 #if 0 // TEST_INNERRECT 4386 static bool guard =
false;
4404 Q_ASSERT(maxArea <= region.d->qt_rgn->innerArea);
4427 if (!rects || num == 0 || (num == 1 && rects->
isEmpty()))
4443 for (
int i = 0; i < num; ++i) {
4444 const QRect &rect = rects[i];
QRegion & operator|=(const QRegion &r)
Applies the united() function to this region and r and assigns the result to this region...
The QVariant class acts like a union for the most common Qt data types.
struct _ScanLineList * next
The QDebug class provides an output stream for debugging information.
void append(const QRect *r)
QImage toImage() const
Converts the pixmap to a QImage.
struct _POINTBLOCK POINTBLOCK
QT_DEPRECATED int numRects() const
Returns the number of rectangles that will be returned in rects().
#define QRGN_SETPTARRAY_ALT
static QRect qt_rect_intersect_normalized(const QRect &r1, const QRect &r2)
QRegion intersected(const QRegion &r) const
Returns a region which is the intersection of this region and r.
struct _ScanLineList ScanLineList
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
void qt_win_dispose_rgn(HRGN r)
void setHeight(int h)
Sets the height of the rectangle to the given height.
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
QRegionPrivate(const QRect &r)
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
#define QT_END_NAMESPACE
This macro expands to.
struct _ScanLineListBlock ScanLineListBlock
static bool canMergeFromBelow(const QRect *top, const QRect *bottom, const QRect *nextToTop, const QRect *nextToBottom)
bool within(const QRect &r1) const
QRegion & operator-=(const QRegion &r)
Applies the subtracted() function to this region and r and assigns the result to this region...
static void XorRegion(QRegionPrivate *sra, QRegionPrivate *srb, QRegionPrivate &dest)
RegionType
Specifies the shape of the region to be created.
static void SubtractRegion(QRegionPrivate *regM, QRegionPrivate *regS, register QRegionPrivate &dest)
friend struct QRegionPrivate
~QRegion()
Destroys the region.
Q_DECLARE_TYPEINFO(QRegionSpan, Q_PRIMITIVE_TYPE)
bool mergeFromAbove(QRect *bottom, const QRect *top, const QRect *nextToBottom, const QRect *nextToTop)
#define it(className, varName)
void(* OverlapFunc)(register QRegionPrivate &dest, register const QRect *r1, const QRect *r1End, register const QRect *r2, const QRect *r2End, register int y1, register int y2)
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
int count(const T &t) const
Returns the number of occurrences of value in the vector.
QDebug & nospace()
Clears the stream's internal flag that records whether the last character was a space and returns a r...
ByteOrder byteOrder() const
Returns the current byte order setting – either BigEndian or LittleEndian.
#define QRGN_SETPTARRAY_WIND
T & first()
Returns a reference to the first item in the vector.
bool atEnd() const
Returns true if the I/O device has reached the end position (end of the stream or file) or if there i...
struct _POINTBLOCK * next
The QByteArray class provides an array of bytes.
#define BRESINITPGONSTRUCT(dmaj, min1, min2, bres)
T * take()
Returns the value of the pointer referenced by this object.
void intersect(const QRect &r)
struct _EdgeTableEntry * back
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the vector...
QRect normalized() const
Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height...
static QRegionPrivate * PolygonRegion(const QPoint *Pts, int Count, int rule)
int left() const
Returns the x-coordinate of the rectangle's left edge.
int width() const
Returns the width of the rectangle.
#define QT_END_INCLUDE_NAMESPACE
This macro is equivalent to QT_BEGIN_NAMESPACE.
long ASN1_INTEGER_get ASN1_INTEGER * a
QRect boundingRect() const
Returns the bounding rectangle of this region.
The QPolygon class provides a vector of points using integer precision.
bool mergeFromLeft(QRect *left, const QRect *right)
QRegion subtract(const QRegion &r) const
Use subtracted(r) instead.
static void UnionRegion(const QRegionPrivate *reg1, const QRegionPrivate *reg2, QRegionPrivate &dest)
static void loadAET(register EdgeTableEntry *AET, register EdgeTableEntry *ETEs)
int height() const
Returns the height of the rectangle.
bool mergeFromRight(QRect *left, const QRect *right)
int bottom() const
Returns the y-coordinate of the rectangle's bottom edge.
QRegion()
Constructs an empty region.
static void miSubtractO(register QRegionPrivate &dest, register const QRect *r1, const QRect *r1End, register const QRect *r2, const QRect *r2End, register int y1, register int y2)
static bool canMergeFromRight(const QRect *left, const QRect *right)
#define EXTENTCHECK(r1, r2)
const QRegion operator+(const QRegion &r) const
Applies the united() function to this region and r.
static void miUnionO(register QRegionPrivate &dest, register const QRect *r1, const QRect *r1End, register const QRect *r2, const QRect *r2End, register int y1, register int y2)
const QRegion operator^(const QRegion &r) const
Applies the xored() function to this region and r.
#define Q_BASIC_ATOMIC_INITIALIZER(a)
bool operator==(const QRegion &r) const
Returns true if the region is equal to r; otherwise returns false.
static void FreeStorage(register ScanLineListBlock *pSLLBlock)
static struct QRegionData shared_empty
struct _EdgeTableEntry * nextWETE
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
int rectCount() const
Returns the number of rectangles that will be returned in rects().
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
Format format() const
Returns the format of the image.
static void miUnionNonO(register QRegionPrivate &dest, register const QRect *r, const QRect *rEnd, register int y1, register int y2)
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
void resize(int size)
Sets the size of the vector to size.
#define EVALUATEEDGEEVENODD(pAET, pPrevAET, y)
void setVersion(int)
Sets the version number of the data serialization format to v.
bool mergeFromBelow(QRect *top, const QRect *bottom, const QRect *nextToTop, const QRect *nextToBottom)
const QRegion operator &(const QRegion &r) const
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
QRegionPrivate * qt_bitmapToRegion(const QBitmap &bitmap)
Q_CORE_EXPORT void qDebug(const char *,...)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the vector.
The QBitmap class provides monochrome (1-bit depth) pixmaps.
struct _ScanLineListBlock * next
#define QT_BEGIN_NAMESPACE
This macro expands to.
QRegionPrivate(const QRegionPrivate &r)
static void computeWAET(register EdgeTableEntry *AET)
bool canPrepend(const QRect *r) const
QRegion & operator+=(const QRegion &r)
Applies the united() function to this region and r and assigns the result to this region...
The Rectangle item provides a filled rectangle with an optional border.
bool isEmpty() const
Returns true if the region is empty; otherwise returns false.
static void miSubtractNonO1(register QRegionPrivate &dest, register const QRect *r, const QRect *rEnd, register int y1, register int y2)
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
static void miSetExtents(QRegionPrivate &dest)
void updateInnerRect(const QRect &rect)
QRegion intersect(const QRegion &r) const
Use intersected(r) instead.
static void flushRow(const QRegionSpan *spans, int y, int numSpans, QRegionPrivate *reg, int *lastRow, int *extendTo, bool *needsExtend)
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Q_CORE_EXPORT void qWarning(const char *,...)
The QImage class provides a hardware-independent image representation that allows direct access to th...
bool contains(const QPoint &p) const
Returns true if the region contains the point p; otherwise returns false.
struct _EdgeTableEntry EdgeTableEntry
static const char * data(const QByteArray &arr)
void addRect(const QRectF &rect)
Adds the given rectangle to this path as a closed subpath.
static void UnionRectWithRegion(register const QRect *rect, const QRegionPrivate *source, QRegionPrivate &dest)
The QRegion class specifies a clip region for a painter.
void setByteOrder(ByteOrder)
Sets the serialization byte order to bo.
static bool PointInRegion(QRegionPrivate *pRegion, int x, int y)
static bool EqualRegion(const QRegionPrivate *r1, const QRegionPrivate *r2)
void setCoords(int x1, int y1, int x2, int y2)
Sets the coordinates of the rectangle's top-left corner to (x1, y1), and the coordinates of its botto...
EdgeTableEntry * edgelist
QRegion united(const QRegion &r) const
Returns a region which is the union of this region and r.
QRegion eor(const QRegion &r) const
Use xored(r) instead.
bool canAppend(const QRect *r) const
bool contains(const QPoint &p, bool proper=false) const
Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false...
QRegion & operator=(const QRegion &)
Assigns r to this region and returns a reference to the region.
const T & at(int i) const
Returns the item at index position i in the vector.
int data[NUMPTSTOBUFFER *sizeof(QPoint)]
static void cleanUp(QRegionData *x)
int version() const
Returns the version number of the data serialization format.
QRegionSpan(int x1_, int x2_)
void(* NonOverlapFunc)(register QRegionPrivate &dest, register const QRect *r, const QRect *rEnd, register int y1, register int y2)
QRegion unite(const QRegion &r) const
Use united(r) instead.
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
void setY(int y)
Sets the y coordinate of this point to the given y coordinate.
int top() const
Returns the y-coordinate of the rectangle's top edge.
int width() const
Returns the width of the image.
void setRects(const QRect *rect, int num)
Sets the region using the array of rectangles specified by rects and number.
int right() const
Returns the x-coordinate of the rectangle's right edge.
Q_AUTOTEST_EXPORT QPainterPath qt_regionToPath(const QRegion ®ion)
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
bool contains(const QRect &r2) const
static void InsertEdgeInET(EdgeTable *ET, EdgeTableEntry *ETE, int scanline, ScanLineListBlock **SLLBlock, int *iSLLBlock)
const QRegion operator-(const QRegion &r) const
Applies the subtracted() function to this region and r.
int y() const
Returns the y-coordinate of the rectangle's top edge.
static void miRegionOp(register QRegionPrivate &dest, const QRegionPrivate *reg1, const QRegionPrivate *reg2, OverlapFunc overlapFunc, NonOverlapFunc nonOverlap1Func, NonOverlapFunc nonOverlap2Func)
int x() const
Returns the x-coordinate of the rectangle's left edge.
static bool RectInRegion(register QRegionPrivate *region, int rx, int ry, uint rwidth, uint rheight)
QRegion & operator^=(const QRegion &r)
Applies the xored() function to this region and r and assigns the result to this region.
The QPoint class defines a point in the plane using integer precision.
QVector< QRect > rects() const
Returns an array of non-overlapping rectangles that make up the region.
void setWidth(int w)
Sets the width of the rectangle to the given width.
The QRect class defines a rectangle in the plane using integer precision.
#define Q_AUTOTEST_EXPORT
struct _EdgeTableEntry * next
int height() const
Returns the height of the image.
QRegionPrivate & operator=(const QRegionPrivate &r)
bool contains(const T &t) const
Returns true if the vector contains an occurrence of value; otherwise returns false.
int y() const
Returns the y coordinate of this point.
static bool canMergeFromLeft(const QRect *right, const QRect *left)
bool intersects(const QRegion &r) const
Returns true if this region intersects with region, otherwise returns false.
#define QT_BEGIN_INCLUDE_NAMESPACE
This macro is equivalent to QT_END_NAMESPACE.
friend bool qt_region_strictContains(const QRegion ®ion, const QRect &rect)
Returns true if rect is guaranteed to be fully contained in region.
QList< QPolygonF > toSubpathPolygons(const QMatrix &matrix=QMatrix()) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QRegion & operator &=(const QRegion &r)
#define EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET)
bool rect_intersects(const QRect &r1, const QRect &r2)
void translate(int dx, int dy)
Translates (moves) the region dx along the X axis and dy along the Y axis.
T * data()
Returns a pointer to the data stored in the vector.
static int InsertionSort(register EdgeTableEntry *AET)
void exec(const QByteArray &ba, int ver=0, QDataStream::ByteOrder byteOrder=QDataStream::BigEndian)
QRegion translated(int dx, int dy) const
Returns a copy of the region that is translated dx along the x axis and dy along the y axis...
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
The QDataStream class provides serialization of binary data to a QIODevice.
static void CreateETandAET(register int count, register const QPoint *pts, EdgeTable *ET, EdgeTableEntry *AET, register EdgeTableEntry *pETEs, ScanLineListBlock *pSLLBlock)
const T * constData() const
Returns a const pointer to the data stored in the vector.
void reserve(int size)
Attempts to allocate memory for at least size elements.
int x() const
Returns the x coordinate of this point.
const QRegion operator|(const QRegion &r) const
Applies the united() function to this region and r.
friend Q_GUI_EXPORT QDataStream & operator<<(QDataStream &, const QRegion &)
Writes the region r to the stream s and returns a reference to the stream.
ByteOrder
The byte order used for reading/writing the data.
QRegion subtracted(const QRegion &r) const
Returns a region which is r subtracted from this region.
QRegion xored(const QRegion &r) const
Returns a region which is the exclusive or (XOR) of this region and r.
bool isNull() const
Returns true if this is a null pixmap; otherwise returns false.
bool isValid() const
Returns true if the rectangle is valid, otherwise returns false.
static bool overlaps(int posA, int lengthA, int posB, int lengthB)
void translate(int dx, int dy)
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position...
static const KeyPair *const end
#define MEMCHECK(dest, rect, firstrect)
friend Q_GUI_EXPORT QDataStream & operator>>(QDataStream &, QRegion &)
Reads a region from the stream s into r and returns a reference to the stream.
void prepend(const T &t)
Inserts value at the beginning of the vector.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
void setX(int x)
Sets the x coordinate of this point to the given x coordinate.
static void miIntersectO(register QRegionPrivate &dest, register const QRect *r1, const QRect *r1End, register const QRect *r2, const QRect *r2End, int y1, int y2)
int size() const
Returns the number of items in the vector.
static bool isEmptyHelper(const QRegionPrivate *preg)
void prepend(const QRect *r)
static int miCoalesce(register QRegionPrivate &dest, int prevStart, int curStart)
bool contains(const QRegionPrivate &r) const
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
void addEllipse(const QRectF &rect)
Creates an ellipse within the specified boundingRectangle and adds it to the painter path as a closed...
static int area(const QSize &s)
static void OffsetRegion(register QRegionPrivate ®ion, register int x, register int y)
static void PtsToRegion(register int numFullPtBlocks, register int iCurPtBlock, POINTBLOCK *FirstPtBlock, QRegionPrivate *reg)