Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Unified Diff: include/core/SkRRect.h

Issue 196343015: Add nine patch type to SkRRect. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: fix inf loop in tests Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/core/SkRRect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/core/SkRRect.h
diff --git a/include/core/SkRRect.h b/include/core/SkRRect.h
index c09d2d46fe85aed3ca925d2419fcb98838138225..5223ae7072d4fbbe788d028e8202d564fb9a89f0 100644
--- a/include/core/SkRRect.h
+++ b/include/core/SkRRect.h
@@ -71,6 +71,14 @@ public:
//!< the curves) nor a rect (i.e., both radii are non-zero)
kSimple_Type,
+ //!< The RR is non-empty and the two left x radii are equal, the two top
+ //!< y radii are equal, and the same for the right and bottom but it is
+ //!< neither an rect, oval, nor a simple RR. It is called "nine patch"
+ //!< because the centers of the corner ellipses form an axis aligned
+ //!< rect with edges that divide the RR into an 9 rectangular patches:
+ //!< an interior patch, four edge patches, and four corner patches.
+ kNinePatch_Type,
+
//!< A fully general (non-empty) RR. Some of the x and/or y radii are
//!< different from the others and there must be one corner where
//!< both radii are non-zero.
@@ -99,21 +107,11 @@ public:
inline bool isSimpleCircular() const {
return this->isSimple() && 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() const;
- /**
- * Are both x-radii the same on the two left corners, and similar for the top, right, and
- * bottom. When this is the case the four ellipse centers form a rectangle.
- */
- bool isNinePatch() const {
- return fRadii[kUpperLeft_Corner].fX == fRadii[kLowerLeft_Corner].fX &&
- fRadii[kUpperRight_Corner].fX == fRadii[kLowerRight_Corner].fX &&
- fRadii[kUpperLeft_Corner].fY == fRadii[kUpperRight_Corner].fY &&
- fRadii[kLowerLeft_Corner].fY == fRadii[kLowerRight_Corner].fY;
- }
-
SkScalar width() const { return fRect.width(); }
SkScalar height() const { return fRect.height(); }
@@ -172,6 +170,12 @@ public:
void setRectXY(const SkRect& rect, SkScalar xRad, SkScalar yRad);
/**
+ * Initialize the rr with one radius per-side.
+ */
+ void setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad,
+ SkScalar rightRad, SkScalar bottomRad);
+
+ /**
* Initialize the RR with potentially different radii for all four corners.
*/
void setRectRadii(const SkRect& rect, const SkVector radii[4]);
« no previous file with comments | « no previous file | src/core/SkRRect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698