aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/core/SkRRect.h
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-12 19:02:53 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-12-12 19:02:53 +0000
commit68d61ed83ec7b6e98e9623c2f5c9e7b1a32d25bb (patch)
tree1462843b0770736314438d38676b3dd542bd9d1a /include/core/SkRRect.h
parent8cdf0f52ff395d4053f7ed5c20861c42eba25d31 (diff)
make RRect and Oval first-class drawing primitives in SkCanvas.
add RRect as a first-class clip primitive. Review URL: https://codereview.appspot.com/6923058 git-svn-id: http://skia.googlecode.com/svn/trunk@6762 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/core/SkRRect.h')
-rw-r--r--include/core/SkRRect.h43
1 files changed, 42 insertions, 1 deletions
diff --git a/include/core/SkRRect.h b/include/core/SkRRect.h
index 1b52da965c..a900d4a2e5 100644
--- a/include/core/SkRRect.h
+++ b/include/core/SkRRect.h
@@ -11,6 +11,8 @@
#include "SkRect.h"
#include "SkPoint.h"
+class SkPath;
+
// Path forward:
// core work
// add validate method (all radii positive, all radii sums < rect size, etc.)
@@ -83,7 +85,7 @@ public:
/**
* Returns the RR's sub type.
*/
- Type type() const {
+ Type getType() const {
SkDEBUGCODE(this->validate();)
if (kUnknown_Type == fType) {
@@ -93,6 +95,14 @@ public:
return fType;
}
+ Type type() const { return this->getType(); }
+
+ inline bool isEmpty() const { return kEmpty_Type == this->getType(); }
+ 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(); }
+ inline bool isComplex() const { return kComplex_Type == this->getType(); }
+
/**
* Set this RR to the empty rectangle (0,0,0,0) with 0 x & y radii.
*/
@@ -162,6 +172,16 @@ public:
const SkRect& rect() const { return fRect; }
const 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 &&
@@ -199,6 +219,24 @@ public:
SkDEBUGCODE(void validate() const;)
+ enum {
+ kSizeInMemory = 12 * sizeof(SkScalar)
+ };
+
+ /**
+ * Write the rrect into the specified buffer. This is guaranteed to always
+ * write kSizeInMemory bytes, and that value is guaranteed to always be
+ * a multiple of 4. Return kSizeInMemory.
+ */
+ uint32_t writeToMemory(void* buffer) const;
+
+ /**
+ * Read the rrect from the specified buffer. This is guaranteed to always
+ * read kSizeInMemory bytes, and that value is guaranteed to always be
+ * a multiple of 4. Return kSizeInMemory.
+ */
+ uint32_t readFromMemory(const void* buffer);
+
private:
SkRect fRect;
// Radii order is UL, UR, LR, LL. Use Corner enum to index into fRadii[]
@@ -208,6 +246,9 @@ private:
// uninitialized data
void computeType() const;
+
+ // to access fRadii directly
+ friend class SkPath;
};
#endif