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

Unified Diff: src/core/SkRRect.cpp

Issue 998903003: Fix bug with very large round rects with large radii (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update Created 5 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 | tests/RoundRectTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRRect.cpp
diff --git a/src/core/SkRRect.cpp b/src/core/SkRRect.cpp
index f2927644daabd40dbbe79f6964f2dfe305e56748..974c7a139ed57e5cc9fb0d53ba6a671a176016e4 100644
--- a/src/core/SkRRect.cpp
+++ b/src/core/SkRRect.cpp
@@ -173,26 +173,22 @@ void SkRRect::setRectRadii(const SkRect& rect, const SkVector radii[4]) {
// and Ltop = Lbottom = the width of the box,
// and Lleft = Lright = the height of the box.
// If f < 1, then all corner radii are reduced by multiplying them by f."
robertphillips 2015/03/11 18:13:28 So, if we don't do this math in doubles the code n
- SkScalar scale = SK_Scalar1;
+ double scale = 1.0;
- if (fRadii[0].fX + fRadii[1].fX > rect.width()) {
- scale = SkMinScalar(scale,
- SkScalarDiv(rect.width(), fRadii[0].fX + fRadii[1].fX));
+ if (fRadii[0].fX + ((double)fRadii[1].fX) > rect.width()) {
reed1 2015/03/13 14:16:21 can we use a helper function for these, one that t
robertphillips 2015/03/13 16:32:35 Done.
+ scale = SkTMin(scale, rect.width() / (fRadii[0].fX + ((double)fRadii[1].fX)));
}
- if (fRadii[1].fY + fRadii[2].fY > rect.height()) {
- scale = SkMinScalar(scale,
- SkScalarDiv(rect.height(), fRadii[1].fY + fRadii[2].fY));
+ if (fRadii[1].fY + ((double)fRadii[2].fY) > rect.height()) {
+ scale = SkTMin(scale, rect.height() / (fRadii[1].fY + ((double)fRadii[2].fY)));
}
- if (fRadii[2].fX + fRadii[3].fX > rect.width()) {
- scale = SkMinScalar(scale,
- SkScalarDiv(rect.width(), fRadii[2].fX + fRadii[3].fX));
+ if (fRadii[2].fX + ((double)fRadii[3].fX) > rect.width()) {
+ scale = SkTMin(scale, rect.width() / (fRadii[2].fX + ((double)fRadii[3].fX)));
}
- if (fRadii[3].fY + fRadii[0].fY > rect.height()) {
- scale = SkMinScalar(scale,
- SkScalarDiv(rect.height(), fRadii[3].fY + fRadii[0].fY));
+ if (fRadii[3].fY + ((double)fRadii[0].fY) > rect.height()) {
+ scale = SkTMin(scale, rect.height() / (fRadii[3].fY + ((double)fRadii[0].fY)));
}
- if (scale < SK_Scalar1) {
+ if (scale < 1.0) {
for (int i = 0; i < 4; ++i) {
fRadii[i].fX *= scale;
fRadii[i].fY *= scale;
« no previous file with comments | « no previous file | tests/RoundRectTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698