aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkRRect.h
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2018-02-22 13:41:39 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-02-22 19:09:10 +0000
commit242135a402592e4fb40c5aba44cf8d483e68d292 (patch)
tree04f98735331d03ffc00ad9f15c16cf3cc43e59cf /include/core/SkRRect.h
parent2c0349262132d6aa54ac6e8a4295f17c67e25907 (diff)
move some RRect methods into priv
also, return radii by value instead of reference, in possible prep for changing underlying representation Bug: skia:7649 Change-Id: Iff42a49c53cc48171fc63462be366cc3500b2273 Reviewed-on: https://skia-review.googlesource.com/109385 Commit-Queue: Mike Reed <reed@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
Diffstat (limited to 'include/core/SkRRect.h')
-rw-r--r--include/core/SkRRect.h34
1 files changed, 13 insertions, 21 deletions
diff --git a/include/core/SkRRect.h b/include/core/SkRRect.h
index 798dd47f13..a553191515 100644
--- a/include/core/SkRRect.h
+++ b/include/core/SkRRect.h
@@ -105,23 +105,22 @@ public:
inline bool isRect() const { return kRect_Type == this->getType(); }
inline bool isOval() const { return kOval_Type == this->getType(); }
inline bool isSimple() const { return kSimple_Type == this->getType(); }
- // TODO: should isSimpleCircular & isCircle take a tolerance? This could help
- // instances where the mapping to device space is noisy.
- inline bool isSimpleCircular() const {
- return this->isSimple() && SkScalarNearlyEqual(fRadii[0].fX, fRadii[0].fY);
- }
- inline bool isCircle() const {
- return this->isOval() && SkScalarNearlyEqual(fRadii[0].fX, fRadii[0].fY);
- }
inline bool isNinePatch() const { return kNinePatch_Type == this->getType(); }
inline bool isComplex() const { return kComplex_Type == this->getType(); }
- bool allCornersCircular(SkScalar tolerance = SK_ScalarNearlyZero) const;
-
SkScalar width() const { return fRect.width(); }
SkScalar height() const { return fRect.height(); }
/**
+ * kSimple means that all corners have the same x,y radii. This returns the top/left
+ * corner's radii as representative of all corners. If the RRect is kComplex, then
+ * this still returns that corner's radii, but it is not indicative of the other corners.
+ */
+ SkVector getSimpleRadii() const {
+ return fRadii[0];
+ }
+
+ /**
* Same as default initialized - zero width and height at the origin.
*/
void setEmpty() { *this = SkRRect(); }
@@ -206,18 +205,9 @@ public:
};
const SkRect& rect() const { return fRect; }
- const SkVector& radii(Corner corner) const { return fRadii[corner]; }
+ SkVector radii(Corner corner) const { return fRadii[corner]; }
const SkRect& getBounds() const { return fRect; }
- /**
- * When a rrect is simple, all of its radii are equal. This returns one
- * of those radii. This call requires the rrect to be non-complex.
- */
- const SkVector& getSimpleRadii() const {
- SkASSERT(!this->isComplex());
- return fRadii[0];
- }
-
friend bool operator==(const SkRRect& a, const SkRRect& b) {
return a.fRect == b.fRect && SkScalarsEqual(&a.fRadii[0].fX, &b.fRadii[0].fX, 8);
}
@@ -279,7 +269,6 @@ public:
bool contains(const SkRect& rect) const;
bool isValid() const;
- static bool AreRectAndRadiiValid(const SkRect&, const SkVector[4]);
enum {
kSizeInMemory = 12 * sizeof(SkScalar)
@@ -323,6 +312,8 @@ public:
void dumpHex() const { this->dump(true); }
private:
+ static bool AreRectAndRadiiValid(const SkRect&, const SkVector[4]);
+
SkRRect(const SkRect& rect, const SkVector radii[4], int32_t type)
: fRect(rect)
, fRadii{radii[0], radii[1], radii[2], radii[3]}
@@ -347,6 +338,7 @@ private:
// to access fRadii directly
friend class SkPath;
+ friend class SkRRectPriv;
};
#endif