Qt 4.8
Public Types | Public Functions | Public Variables | List of all members
QRegionPrivate Struct Reference
Inheritance diagram for QRegionPrivate:
QRegion::QRegionData

Public Types

enum  { Single, Vector }
 

Public Functions

void append (const QRegionPrivate *r)
 
void append (const QRect *r)
 
void append (const QRegionPrivate *r)
 
bool canAppend (const QRegionPrivate *r) const
 
bool canAppend (const QRect *r) const
 
bool canAppend (const QRegionPrivate *r) const
 
bool canPrepend (const QRegionPrivate *r) const
 
bool canPrepend (const QRect *r) const
 
bool canPrepend (const QRegionPrivate *r) const
 
bool contains (const QRegionPrivate &r) const
 
bool contains (const QRegionPrivate &r) const
 
bool contains (const QRect &r2) const
 
void intersect (const QRect &r)
 
bool mergeFromAbove (QRect *bottom, const QRect *top, const QRect *nextToBottom, const QRect *nextToTop)
 
bool mergeFromBelow (QRect *top, const QRect *bottom, const QRect *nextToTop, const QRect *nextToBottom)
 
bool mergeFromLeft (QRect *left, const QRect *right)
 
bool mergeFromRight (QRect *left, const QRect *right)
 
QRegionPrivateoperator= (const QRegionPrivate &r)
 
QRegionPrivateoperator= (const QRegionPrivate &r)
 
void prepend (const QRegionPrivate *r)
 
void prepend (const QRect *r)
 
void prepend (const QRegionPrivate *r)
 
 QRegionPrivate ()
 
 QRegionPrivate (const QRect &r)
 
 QRegionPrivate (const QRegionPrivate &r)
 
 QRegionPrivate ()
 
 QRegionPrivate (const QRect &r)
 
 QRegionPrivate (const QRegionPrivate &r)
 
void updateInnerRect (const QRect &rect)
 
void updateInnerRect (const QRect &rect)
 
void vector ()
 
void vectorize ()
 
bool within (const QRect &r1) const
 

Public Variables

union {
   int   innerArea
 
   QRegionPrivate *   next
 
}; 
 
QRect extents
 
int innerArea
 
QRect innerRect
 
enum QRegionPrivate:: { ... }  mode
 
int numRects
 
QVector< QRectrects
 
QRect single
 
- Public Variables inherited from QRegion::QRegionData
QRegionPrivateqt_rgn
 
QBasicAtomicInt ref
 
HRGN rgn
 

Detailed Description

Definition at line 1225 of file qregion.cpp.

Enumerations

◆ anonymous enum

anonymous enum
Enumerator
Single 
Vector 

Definition at line 97 of file qregion_qws.cpp.

Constructors and Destructors

◆ QRegionPrivate() [1/6]

QRegionPrivate::QRegionPrivate ( )
inline

Definition at line 1232 of file qregion.cpp.

1232 : numRects(0), innerArea(-1) {}

◆ QRegionPrivate() [2/6]

QRegionPrivate::QRegionPrivate ( const QRect r)
inline

Definition at line 1233 of file qregion.cpp.

1233  {
1234  numRects = 1;
1235  extents = r;
1236  innerRect = r;
1237  innerArea = r.width() * r.height();
1238  }
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306

◆ QRegionPrivate() [3/6]

QRegionPrivate::QRegionPrivate ( const QRegionPrivate r)
inline

Definition at line 1240 of file qregion.cpp.

1240  {
1241  rects = r.rects;
1242  numRects = r.numRects;
1243  extents = r.extents;
1244  innerRect = r.innerRect;
1245  innerArea = r.innerArea;
1246  }
QVector< QRect > rects
Definition: qregion.cpp:1227

◆ QRegionPrivate() [4/6]

QRegionPrivate::QRegionPrivate ( )
inline

Definition at line 117 of file qregion_qws.cpp.

117 : mode(Single), numRects(0), innerArea(-1) {}
enum QRegionPrivate::@253 mode

◆ QRegionPrivate() [5/6]

QRegionPrivate::QRegionPrivate ( const QRect r)
inline

Definition at line 118 of file qregion_qws.cpp.

118  : mode(Single) {
119  numRects = 1;
120 // rects[0] = r;
121  single = r;
122  extents = r;
123  innerRect = r;
124  innerArea = r.width() * r.height();
125  }
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
enum QRegionPrivate::@253 mode

◆ QRegionPrivate() [6/6]

QRegionPrivate::QRegionPrivate ( const QRegionPrivate r)
inline

Definition at line 127 of file qregion_qws.cpp.

127  {
128  mode = r.mode;
129  rects = r.rects;
130  single = r.single;
131  numRects = r.numRects;
132  extents = r.extents;
133  innerRect = r.innerRect;
134  innerArea = r.innerArea;
135  }
enum QRegionPrivate::@253 mode
QVector< QRect > rects
Definition: qregion.cpp:1227

Functions

◆ append() [1/3]

void QRegionPrivate::append ( const QRegionPrivate r)

◆ append() [2/3]

void QRegionPrivate::append ( const QRect r)
inline

Definition at line 1460 of file qregion.cpp.

Referenced by isEmptyHelper(), QRegion::operator+=(), qt_bitmapToRegion(), UnionRectWithRegion(), QRegion::unite(), and XorRegion().

1461 {
1462  Q_ASSERT(!r->isEmpty());
1463 
1464  QRect *myLast = (numRects == 1 ? &extents : rects.data() + (numRects - 1));
1465  if (mergeFromRight(myLast, r)) {
1466  if (numRects > 1) {
1467  const QRect *nextToTop = (numRects > 2 ? myLast - 2 : 0);
1468  if (mergeFromBelow(myLast - 1, myLast, nextToTop, 0))
1469  --numRects;
1470  }
1471  } else if (mergeFromBelow(myLast, r, (numRects > 1 ? myLast - 1 : 0), 0)) {
1472  // nothing
1473  } else {
1474  vectorize();
1475  ++numRects;
1476  updateInnerRect(*r);
1477  if (rects.size() < numRects)
1479  rects[numRects - 1] = *r;
1480  }
1482  qMin(extents.top(), r->top()),
1483  qMax(extents.right(), r->right()),
1484  qMax(extents.bottom(), r->bottom()));
1485 
1486 #ifdef QT_REGION_DEBUG
1487  selfTest();
1488 #endif
1489 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
bool mergeFromRight(QRect *left, const QRect *right)
Definition: qregion.cpp:1338
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
bool mergeFromBelow(QRect *top, const QRect *bottom, const QRect *nextToTop, const QRect *nextToBottom)
Definition: qregion.cpp:1372
void updateInnerRect(const QRect &rect)
Definition: qregion.cpp:1282
void setCoords(int x1, int y1, int x2, int y2)
Sets the coordinates of the rectangle&#39;s top-left corner to (x1, y1), and the coordinates of its botto...
Definition: qrect.h:416
QVector< QRect > rects
Definition: qregion.cpp:1227
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
void vectorize()
Definition: qregion.cpp:1290

◆ append() [3/3]

void QRegionPrivate::append ( const QRegionPrivate r)

Definition at line 1491 of file qregion.cpp.

1492 {
1493  Q_ASSERT(!isEmptyHelper(r));
1494 
1495  if (r->numRects == 1) {
1496  append(&r->extents);
1497  return;
1498  }
1499 
1500  vectorize();
1501 
1502  QRect *destRect = rects.data() + numRects;
1503  const QRect *srcRect = r->rects.constData();
1504  int numAppend = r->numRects;
1505 
1506  // try merging
1507  {
1508  const QRect *rFirst = srcRect;
1509  QRect *myLast = destRect - 1;
1510  const QRect *nextToLast = (numRects > 1 ? myLast - 1 : 0);
1511  if (mergeFromRight(myLast, rFirst)) {
1512  ++srcRect;
1513  --numAppend;
1514  const QRect *rNextToFirst = (numAppend > 1 ? rFirst + 2 : 0);
1515  if (mergeFromBelow(myLast, rFirst + 1, nextToLast, rNextToFirst)) {
1516  ++srcRect;
1517  --numAppend;
1518  }
1519  if (numRects > 1) {
1520  nextToLast = (numRects > 2 ? myLast - 2 : 0);
1521  rNextToFirst = (numAppend > 0 ? srcRect : 0);
1522  if (mergeFromBelow(myLast - 1, myLast, nextToLast, rNextToFirst)) {
1523  --destRect;
1524  --numRects;
1525  }
1526  }
1527  } else if (mergeFromBelow(myLast, rFirst, nextToLast, rFirst + 1)) {
1528  ++srcRect;
1529  --numAppend;
1530  }
1531  }
1532 
1533  // append rectangles
1534  if (numAppend > 0) {
1535  const int newNumRects = numRects + numAppend;
1536  if (newNumRects > rects.size()) {
1537  rects.resize(newNumRects);
1538  destRect = rects.data() + numRects;
1539  }
1540  memcpy(destRect, srcRect, numAppend * sizeof(QRect));
1541 
1542  numRects = newNumRects;
1543  }
1544 
1545  // update inner rectangle
1546  if (innerArea < r->innerArea) {
1547  innerArea = r->innerArea;
1548  innerRect = r->innerRect;
1549  }
1550 
1551  // update extents
1552  destRect = &extents;
1553  srcRect = &r->extents;
1554  extents.setCoords(qMin(destRect->left(), srcRect->left()),
1555  qMin(destRect->top(), srcRect->top()),
1556  qMax(destRect->right(), srcRect->right()),
1557  qMax(destRect->bottom(), srcRect->bottom()));
1558 
1559 #ifdef QT_REGION_DEBUG
1560  selfTest();
1561 #endif
1562 }
void append(const QRect *r)
Definition: qregion.cpp:1460
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
bool mergeFromRight(QRect *left, const QRect *right)
Definition: qregion.cpp:1338
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
bool mergeFromBelow(QRect *top, const QRect *bottom, const QRect *nextToTop, const QRect *nextToBottom)
Definition: qregion.cpp:1372
void setCoords(int x1, int y1, int x2, int y2)
Sets the coordinates of the rectangle&#39;s top-left corner to (x1, y1), and the coordinates of its botto...
Definition: qrect.h:416
QVector< QRect > rects
Definition: qregion.cpp:1227
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
static bool isEmptyHelper(const QRegionPrivate *preg)
Definition: qregion.cpp:1321
void vectorize()
Definition: qregion.cpp:1290

◆ canAppend() [1/3]

bool QRegionPrivate::canAppend ( const QRegionPrivate r) const
inline

◆ canAppend() [2/3]

bool QRegionPrivate::canAppend ( const QRect r) const
inline

Definition at line 1669 of file qregion.cpp.

Referenced by isEmptyHelper(), QRegion::operator+=(), qt_bitmapToRegion(), UnionRectWithRegion(), UnionRegion(), QRegion::unite(), and XorRegion().

1670 {
1671  Q_ASSERT(!r->isEmpty());
1672 
1673  const QRect *myLast = (numRects == 1) ? &extents : (rects.constData() + (numRects - 1));
1674  if (r->top() > myLast->bottom())
1675  return true;
1676  if (r->top() == myLast->top()
1677  && r->height() == myLast->height()
1678  && r->left() > myLast->right())
1679  {
1680  return true;
1681  }
1682 
1683  return false;
1684 }
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QVector< QRect > rects
Definition: qregion.cpp:1227
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154

◆ canAppend() [3/3]

bool QRegionPrivate::canAppend ( const QRegionPrivate r) const
inline

Definition at line 1686 of file qregion.cpp.

1687 {
1688  return canAppend(r->numRects == 1 ? &r->extents : r->rects.constData());
1689 }
bool canAppend(const QRect *r) const
Definition: qregion.cpp:1669
QVector< QRect > rects
Definition: qregion.cpp:1227
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154

◆ canPrepend() [1/3]

bool QRegionPrivate::canPrepend ( const QRegionPrivate r) const
inline

◆ canPrepend() [2/3]

bool QRegionPrivate::canPrepend ( const QRect r) const
inline

Definition at line 1691 of file qregion.cpp.

Referenced by isEmptyHelper(), QRegion::operator+=(), and QRegion::unite().

1692 {
1693  Q_ASSERT(!r->isEmpty());
1694 
1695  const QRect *myFirst = (numRects == 1) ? &extents : rects.constData();
1696  if (r->bottom() < myFirst->top()) // not overlapping
1697  return true;
1698  if (r->top() == myFirst->top()
1699  && r->height() == myFirst->height()
1700  && r->right() < myFirst->left())
1701  {
1702  return true;
1703  }
1704 
1705  return false;
1706 }
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QVector< QRect > rects
Definition: qregion.cpp:1227
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154

◆ canPrepend() [3/3]

bool QRegionPrivate::canPrepend ( const QRegionPrivate r) const
inline

Definition at line 1708 of file qregion.cpp.

1709 {
1710  return canPrepend(r->numRects == 1 ? &r->extents : r->rects.constData() + r->numRects - 1);
1711 }
bool canPrepend(const QRect *r) const
Definition: qregion.cpp:1691
QVector< QRect > rects
Definition: qregion.cpp:1227
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154

◆ contains() [1/3]

bool QRegionPrivate::contains ( const QRegionPrivate r) const
inline

Definition at line 152 of file qregion_qws.cpp.

152  {
153  const QRect &r1 = innerRect;
154  const QRect &r2 = r.extents;
155  return CONTAINSCHECK(r1, r2);
156  }
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
#define CONTAINSCHECK(r1, r2)
Definition: qregion_qws.cpp:89

◆ contains() [2/3]

bool QRegionPrivate::contains ( const QRegionPrivate r) const
inline

Definition at line 1263 of file qregion.cpp.

Referenced by QRegion::intersect(), QRegion::operator+=(), qt_bitmapToRegion(), QRegion::subtract(), SubtractRegion(), UnionRegion(), QRegion::unite(), and XorRegion().

1263  {
1264  return contains(r.extents);
1265  }
bool contains(const QRegionPrivate &r) const
Definition: qregion.cpp:1263

◆ contains() [3/3]

bool QRegionPrivate::contains ( const QRect r2) const
inline

Definition at line 1267 of file qregion.cpp.

1267  {
1268  const QRect &r1 = innerRect;
1269  return r2.left() >= r1.left() && r2.right() <= r1.right()
1270  && r2.top() >= r1.top() && r2.bottom() <= r1.bottom();
1271  }
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

◆ intersect()

void QRegionPrivate::intersect ( const QRect r)

Definition at line 1407 of file qregion.cpp.

Referenced by QRegion::intersect().

1408 {
1409  Q_ASSERT(extents.intersects(rect));
1410  Q_ASSERT(numRects > 1);
1411 
1412 #ifdef QT_REGION_DEBUG
1413  selfTest();
1414 #endif
1415 
1416  const QRect r = rect.normalized();
1417  extents = QRect();
1418  innerRect = QRect();
1419  innerArea = -1;
1420 
1421  QRect *dest = rects.data();
1422  const QRect *src = dest;
1423  int n = numRects;
1424  numRects = 0;
1425  while (n--) {
1426  *dest = qt_rect_intersect_normalized(*src++, r);
1427  if (dest->isEmpty())
1428  continue;
1429 
1430  if (numRects == 0) {
1431  extents = *dest;
1432  } else {
1433  extents.setLeft(qMin(extents.left(), dest->left()));
1434  // hw: extents.top() will never change after initialization
1435  //extents.setTop(qMin(extents.top(), dest->top()));
1436  extents.setRight(qMax(extents.right(), dest->right()));
1437  extents.setBottom(qMax(extents.bottom(), dest->bottom()));
1438 
1439  const QRect *nextToLast = (numRects > 1 ? dest - 2 : 0);
1440 
1441  // mergeFromBelow inlined and optimized
1442  if (canMergeFromBelow(dest - 1, dest, nextToLast, 0)) {
1443  if (!n || src->y() != dest->y() || src->left() > r.right()) {
1444  QRect *prev = dest - 1;
1445  prev->setBottom(dest->bottom());
1446  updateInnerRect(*prev);
1447  continue;
1448  }
1449  }
1450  }
1451  updateInnerRect(*dest);
1452  ++dest;
1453  ++numRects;
1454  }
1455 #ifdef QT_REGION_DEBUG
1456  selfTest();
1457 #endif
1458 }
static QRect qt_rect_intersect_normalized(const QRect &r1, const QRect &r2)
Definition: qregion.cpp:1396
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
static bool canMergeFromBelow(const QRect *top, const QRect *bottom, const QRect *nextToTop, const QRect *nextToBottom)
Definition: qregion.cpp:1358
QRect normalized() const
Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height...
Definition: qrect.cpp:322
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void updateInnerRect(const QRect &rect)
Definition: qregion.cpp:1282
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
QVector< QRect > rects
Definition: qregion.cpp:1227
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
int y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:255
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
bool intersects(const QRect &r) const
Returns true if this rectangle intersects with the given rectangle (i.
Definition: qrect.cpp:1429

◆ mergeFromAbove()

bool QRegionPrivate::mergeFromAbove ( QRect bottom,
const QRect top,
const QRect nextToBottom,
const QRect nextToTop 
)
inline

Definition at line 1384 of file qregion.cpp.

1387 {
1388  if (canMergeFromBelow(top, bottom, nextToTop, nextToBottom)) {
1389  bottom->setTop(top->top());
1390  updateInnerRect(*bottom);
1391  return true;
1392  }
1393  return false;
1394 }
static bool canMergeFromBelow(const QRect *top, const QRect *bottom, const QRect *nextToTop, const QRect *nextToBottom)
Definition: qregion.cpp:1358
void setTop(int pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:261
void updateInnerRect(const QRect &rect)
Definition: qregion.cpp:1282
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243

◆ mergeFromBelow()

bool QRegionPrivate::mergeFromBelow ( QRect top,
const QRect bottom,
const QRect nextToTop,
const QRect nextToBottom 
)
inline

Definition at line 1372 of file qregion.cpp.

1375 {
1376  if (canMergeFromBelow(top, bottom, nextToTop, nextToBottom)) {
1377  top->setBottom(bottom->bottom());
1378  updateInnerRect(*top);
1379  return true;
1380  }
1381  return false;
1382 }
void setBottom(int pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:267
static bool canMergeFromBelow(const QRect *top, const QRect *bottom, const QRect *nextToTop, const QRect *nextToBottom)
Definition: qregion.cpp:1358
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
void updateInnerRect(const QRect &rect)
Definition: qregion.cpp:1282

◆ mergeFromLeft()

bool QRegionPrivate::mergeFromLeft ( QRect left,
const QRect right 
)
inline

Definition at line 1348 of file qregion.cpp.

1349 {
1350  if (canMergeFromLeft(right, left)) {
1351  right->setLeft(left->left());
1352  updateInnerRect(*right);
1353  return true;
1354  }
1355  return false;
1356 }
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
void updateInnerRect(const QRect &rect)
Definition: qregion.cpp:1282
void setLeft(int pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:258
static bool canMergeFromLeft(const QRect *right, const QRect *left)
Definition: qregion.cpp:1333

◆ mergeFromRight()

bool QRegionPrivate::mergeFromRight ( QRect left,
const QRect right 
)
inline

Definition at line 1338 of file qregion.cpp.

1339 {
1340  if (canMergeFromRight(left, right)) {
1341  left->setRight(right->right());
1342  updateInnerRect(*left);
1343  return true;
1344  }
1345  return false;
1346 }
static bool canMergeFromRight(const QRect *left, const QRect *right)
Definition: qregion.cpp:1326
void updateInnerRect(const QRect &rect)
Definition: qregion.cpp:1282
void setRight(int pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:264
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246

◆ operator=() [1/2]

QRegionPrivate& QRegionPrivate::operator= ( const QRegionPrivate r)
inline

Definition at line 137 of file qregion_qws.cpp.

137  {
138  mode = r.mode;
139  rects = r.rects;
140  single = r.single;
141  numRects = r.numRects;
142  extents = r.extents;
143  innerRect = r.innerRect;
144  innerArea = r.innerArea;
145  return *this;
146  }
enum QRegionPrivate::@253 mode
QVector< QRect > rects
Definition: qregion.cpp:1227

◆ operator=() [2/2]

QRegionPrivate& QRegionPrivate::operator= ( const QRegionPrivate r)
inline

Definition at line 1248 of file qregion.cpp.

1248  {
1249  rects = r.rects;
1250  numRects = r.numRects;
1251  extents = r.extents;
1252  innerRect = r.innerRect;
1253  innerArea = r.innerArea;
1254  return *this;
1255  }
QVector< QRect > rects
Definition: qregion.cpp:1227

◆ prepend() [1/3]

void QRegionPrivate::prepend ( const QRegionPrivate r)

◆ prepend() [2/3]

void QRegionPrivate::prepend ( const QRect r)

Definition at line 1637 of file qregion.cpp.

Referenced by isEmptyHelper(), QRegion::operator+=(), and QRegion::unite().

1638 {
1639  Q_ASSERT(!r->isEmpty());
1640 
1641  QRect *myFirst = (numRects == 1 ? &extents : rects.data());
1642  if (mergeFromLeft(myFirst, r)) {
1643  if (numRects > 1) {
1644  const QRect *nextToFirst = (numRects > 2 ? myFirst + 2 : 0);
1645  if (mergeFromAbove(myFirst + 1, myFirst, nextToFirst, 0)) {
1646  --numRects;
1647  memmove(rects.data(), rects.constData() + 1,
1648  numRects * sizeof(QRect));
1649  }
1650  }
1651  } else if (mergeFromAbove(myFirst, r, (numRects > 1 ? myFirst + 1 : 0), 0)) {
1652  // nothing
1653  } else {
1654  vectorize();
1655  ++numRects;
1656  updateInnerRect(*r);
1657  rects.prepend(*r);
1658  }
1660  qMin(extents.top(), r->top()),
1661  qMax(extents.right(), r->right()),
1662  qMax(extents.bottom(), r->bottom()));
1663 
1664 #ifdef QT_REGION_DEBUG
1665  selfTest();
1666 #endif
1667 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
bool mergeFromAbove(QRect *bottom, const QRect *top, const QRect *nextToBottom, const QRect *nextToTop)
Definition: qregion.cpp:1384
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
bool mergeFromLeft(QRect *left, const QRect *right)
Definition: qregion.cpp:1348
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void updateInnerRect(const QRect &rect)
Definition: qregion.cpp:1282
void setCoords(int x1, int y1, int x2, int y2)
Sets the coordinates of the rectangle&#39;s top-left corner to (x1, y1), and the coordinates of its botto...
Definition: qrect.h:416
QVector< QRect > rects
Definition: qregion.cpp:1227
bool isEmpty() const
Returns true if the rectangle is empty, otherwise returns false.
Definition: qrect.h:234
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154
void prepend(const T &t)
Inserts value at the beginning of the vector.
Definition: qvector.h:378
void vectorize()
Definition: qregion.cpp:1290

◆ prepend() [3/3]

void QRegionPrivate::prepend ( const QRegionPrivate r)

Definition at line 1564 of file qregion.cpp.

1565 {
1566  Q_ASSERT(!isEmptyHelper(r));
1567 
1568  if (r->numRects == 1) {
1569  prepend(&r->extents);
1570  return;
1571  }
1572 
1573  vectorize();
1574 
1575  int numPrepend = r->numRects;
1576  int numSkip = 0;
1577 
1578  // try merging
1579  {
1580  QRect *myFirst = rects.data();
1581  const QRect *nextToFirst = (numRects > 1 ? myFirst + 1 : 0);
1582  const QRect *rLast = r->rects.constData() + r->numRects - 1;
1583  const QRect *rNextToLast = (r->numRects > 1 ? rLast - 1 : 0);
1584  if (mergeFromLeft(myFirst, rLast)) {
1585  --numPrepend;
1586  --rLast;
1587  rNextToLast = (numPrepend > 1 ? rLast - 1 : 0);
1588  if (mergeFromAbove(myFirst, rLast, nextToFirst, rNextToLast)) {
1589  --numPrepend;
1590  --rLast;
1591  }
1592  if (numRects > 1) {
1593  nextToFirst = (numRects > 2? myFirst + 2 : 0);
1594  rNextToLast = (numPrepend > 0 ? rLast : 0);
1595  if (mergeFromAbove(myFirst + 1, myFirst, nextToFirst, rNextToLast)) {
1596  --numRects;
1597  ++numSkip;
1598  }
1599  }
1600  } else if (mergeFromAbove(myFirst, rLast, nextToFirst, rNextToLast)) {
1601  --numPrepend;
1602  }
1603  }
1604 
1605  if (numPrepend > 0) {
1606  const int newNumRects = numRects + numPrepend;
1607  if (newNumRects > rects.size())
1608  rects.resize(newNumRects);
1609 
1610  // move existing rectangles
1611  memmove(rects.data() + numPrepend, rects.constData() + numSkip,
1612  numRects * sizeof(QRect));
1613 
1614  // prepend new rectangles
1615  memcpy(rects.data(), r->rects.constData(), numPrepend * sizeof(QRect));
1616 
1617  numRects = newNumRects;
1618  }
1619 
1620  // update inner rectangle
1621  if (innerArea < r->innerArea) {
1622  innerArea = r->innerArea;
1623  innerRect = r->innerRect;
1624  }
1625 
1626  // update extents
1628  qMin(extents.top(), r->extents.top()),
1629  qMax(extents.right(), r->extents.right()),
1630  qMax(extents.bottom(), r->extents.bottom()));
1631 
1632 #ifdef QT_REGION_DEBUG
1633  selfTest();
1634 #endif
1635 }
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
bool mergeFromAbove(QRect *bottom, const QRect *top, const QRect *nextToBottom, const QRect *nextToTop)
Definition: qregion.cpp:1384
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
bool mergeFromLeft(QRect *left, const QRect *right)
Definition: qregion.cpp:1348
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
void setCoords(int x1, int y1, int x2, int y2)
Sets the coordinates of the rectangle&#39;s top-left corner to (x1, y1), and the coordinates of its botto...
Definition: qrect.h:416
QVector< QRect > rects
Definition: qregion.cpp:1227
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
T * data()
Returns a pointer to the data stored in the vector.
Definition: qvector.h:152
const T * constData() const
Returns a const pointer to the data stored in the vector.
Definition: qvector.h:154
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137
static bool isEmptyHelper(const QRegionPrivate *preg)
Definition: qregion.cpp:1321
void prepend(const QRect *r)
Definition: qregion.cpp:1637
void vectorize()
Definition: qregion.cpp:1290

◆ updateInnerRect() [1/2]

void QRegionPrivate::updateInnerRect ( const QRect rect)
inline

Definition at line 158 of file qregion_qws.cpp.

158  {
159  const int area = rect.width() * rect.height();
160  if (area > innerArea) {
161  innerArea = area;
162  innerRect = rect;
163  }
164  }
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
static int area(const QSize &s)
Definition: qicon.cpp:155

◆ updateInnerRect() [2/2]

void QRegionPrivate::updateInnerRect ( const QRect rect)
inline

Definition at line 1282 of file qregion.cpp.

Referenced by miCoalesce(), miSetExtents(), PtsToRegion(), and QRegion::setRects().

1282  {
1283  const int area = rect.width() * rect.height();
1284  if (area > innerArea) {
1285  innerArea = area;
1286  innerRect = rect;
1287  }
1288  }
int width() const
Returns the width of the rectangle.
Definition: qrect.h:303
int height() const
Returns the height of the rectangle.
Definition: qrect.h:306
static int area(const QSize &s)
Definition: qicon.cpp:155

◆ vector()

void QRegionPrivate::vector ( )
inline

Definition at line 108 of file qregion_qws.cpp.

Referenced by miRegionOp(), PolygonRegion(), and qt_bitmapToRegion().

109  {
110  if(mode != Vector && numRects) {
111  if(rects.size() < 1) rects.resize(1);
112  rects[0] = single;
113  }
114  mode = Vector;
115  }
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
enum QRegionPrivate::@253 mode
QVector< QRect > rects
Definition: qregion.cpp:1227
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ vectorize()

void QRegionPrivate::vectorize ( )
inline

Definition at line 1290 of file qregion.cpp.

Referenced by miRegionOp(), PolygonRegion(), and QRegion::rects().

1290  {
1291  if (numRects == 1) {
1292  if (!rects.size())
1293  rects.resize(1);
1294  rects[0] = extents;
1295  }
1296  }
void resize(int size)
Sets the size of the vector to size.
Definition: qvector.h:342
QVector< QRect > rects
Definition: qregion.cpp:1227
int size() const
Returns the number of items in the vector.
Definition: qvector.h:137

◆ within()

bool QRegionPrivate::within ( const QRect r1) const
inline

Definition at line 1276 of file qregion.cpp.

Referenced by QRegion::intersect(), QRegion::operator+=(), and QRegion::unite().

1276  {
1277  const QRect &r2 = extents;
1278  return r2.left() >= r1.left() && r2.right() <= r1.right()
1279  && r2.top() >= r1.top() && r2.bottom() <= r1.bottom();
1280  }
int left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:240
int bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:249
int top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:243
int right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:246
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58

Properties

◆ @255

union { ... }

◆ extents

QRect QRegionPrivate::extents

◆ innerArea

int QRegionPrivate::innerArea

◆ innerRect

QRect QRegionPrivate::innerRect

◆ mode

enum { ... } QRegionPrivate::mode

◆ next

QRegionPrivate* QRegionPrivate::next

Definition at line 105 of file qregion_qws.cpp.

Referenced by qt_allocRegionMemory(), and qt_freeRegionMemory().

◆ numRects

int QRegionPrivate::numRects

◆ rects

QVector< QRect > QRegionPrivate::rects

◆ single

QRect QRegionPrivate::single

The documentation for this struct was generated from the following files: