aboutsummaryrefslogtreecommitdiffhomepage
path: root/gpu/include/GrRect.h
diff options
context:
space:
mode:
Diffstat (limited to 'gpu/include/GrRect.h')
-rw-r--r--gpu/include/GrRect.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/gpu/include/GrRect.h b/gpu/include/GrRect.h
index 67e366c3bf..a9ff6ec14d 100644
--- a/gpu/include/GrRect.h
+++ b/gpu/include/GrRect.h
@@ -206,6 +206,14 @@ struct GrRect {
}
/**
+ * Returns true if the rects edges are integer-aligned.
+ */
+ bool isIRect() const {
+ return GrScalarIsInt(fLeft) && GrScalarIsInt(fTop) &&
+ GrScalarIsInt(fRight) && GrScalarIsInt(fBottom);
+ }
+
+ /**
* Does this rect contain a point.
*/
bool contains(const GrPoint& point) const {
@@ -363,6 +371,22 @@ struct GrRect {
return pts + 4;
}
+ /**
+ * Swaps (left and right) and/or (top and bottom) if they are inverted
+ */
+ void sort() {
+ if (fLeft > fRight) {
+ GrScalar temp = fLeft;
+ fLeft = fRight;
+ fRight = temp;
+ }
+ if (fTop > fBottom) {
+ GrScalar temp = fTop;
+ fTop = fBottom;
+ fBottom = temp;
+ }
+ }
+
bool operator ==(const GrRect& r) const {
return fLeft == r.fLeft &&
fTop == r.fTop &&