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

Unified Diff: include/core/SkRRect.h

Issue 1373293002: Handle inverted rects in SkRRect creation methods (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fixed SK_ARRAY_COUNT error Created 5 years, 3 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 | « gm/roundrects.cpp ('k') | 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 064e7be8e47b4150ee2869893dae2945e4c47aaa..8d8cdbf02c79de89e62360c6dc6296089c9faeb3 100644
--- a/include/core/SkRRect.h
+++ b/include/core/SkRRect.h
@@ -127,12 +127,14 @@ public:
* Set this RR to match the supplied rect. All radii will be 0.
*/
void setRect(const SkRect& rect) {
- if (rect.isEmpty()) {
+ fRect = rect;
+ fRect.sort();
+
+ if (fRect.isEmpty()) {
this->setEmpty();
return;
}
- fRect = rect;
memset(fRadii, 0, sizeof(fRadii));
fType = kRect_Type;
@@ -156,15 +158,17 @@ public:
* width and all y radii will equal half the height.
*/
void setOval(const SkRect& oval) {
- if (oval.isEmpty()) {
+ fRect = oval;
+ fRect.sort();
+
+ if (fRect.isEmpty()) {
this->setEmpty();
return;
}
- SkScalar xRad = SkScalarHalf(oval.width());
- SkScalar yRad = SkScalarHalf(oval.height());
+ SkScalar xRad = SkScalarHalf(fRect.width());
+ SkScalar yRad = SkScalarHalf(fRect.height());
- fRect = oval;
for (int i = 0; i < 4; ++i) {
fRadii[i].set(xRad, yRad);
}
« no previous file with comments | « gm/roundrects.cpp ('k') | src/core/SkRRect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698