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

Unified Diff: src/core/SkRRect.cpp

Issue 202163004: Revert of Add nine patch type to SkRRect. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: 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 | « include/core/SkRRect.h ('k') | src/effects/SkBlurMaskFilter.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 082646c2a76594c4a33e47fa7b759ef3308634c1..915ed75327f590c567ec18a5e9e0d92f64b76ee4 100644
--- a/src/core/SkRRect.cpp
+++ b/src/core/SkRRect.cpp
@@ -42,61 +42,6 @@
SkDEBUGCODE(this->validate();)
}
-
-void SkRRect::setNinePatch(const SkRect& rect, SkScalar leftRad, SkScalar topRad,
- SkScalar rightRad, SkScalar bottomRad) {
- if (rect.isEmpty()) {
- this->setEmpty();
- return;
- }
-
- leftRad = SkMaxScalar(leftRad, 0);
- topRad = SkMaxScalar(topRad, 0);
- rightRad = SkMaxScalar(rightRad, 0);
- bottomRad = SkMaxScalar(bottomRad, 0);
-
- SkScalar scale = SK_Scalar1;
- if (leftRad + rightRad > rect.width()) {
- scale = SkScalarDiv(rect.width(), leftRad + rightRad);
- }
- if (topRad + bottomRad > rect.height()) {
- scale = SkMinScalar(scale, SkScalarDiv(rect.width(), leftRad + rightRad));
- }
-
- if (scale < SK_Scalar1) {
- leftRad = SkScalarMul(leftRad, scale);
- topRad = SkScalarMul(topRad, scale);
- rightRad = SkScalarMul(rightRad, scale);
- bottomRad = SkScalarMul(bottomRad, scale);
- }
-
- if (leftRad == rightRad && topRad == bottomRad) {
- if (leftRad >= SkScalarHalf(rect.width()) && topRad >= SkScalarHalf(rect.height())) {
- fType = kOval_Type;
- } else if (0 == leftRad || 0 == topRad) {
- // If the left and (by equality check above) right radii are zero then it is a rect.
- // Same goes for top/bottom.
- fType = kRect_Type;
- leftRad = 0;
- topRad = 0;
- rightRad = 0;
- bottomRad = 0;
- } else {
- fType = kSimple_Type;
- }
- } else {
- fType = kNinePatch_Type;
- }
-
- fRect = rect;
- fRadii[kUpperLeft_Corner].set(leftRad, topRad);
- fRadii[kUpperRight_Corner].set(rightRad, topRad);
- fRadii[kLowerRight_Corner].set(rightRad, bottomRad);
- fRadii[kLowerLeft_Corner].set(leftRad, bottomRad);
-
- SkDEBUGCODE(this->validate();)
-}
-
void SkRRect::setRectRadii(const SkRect& rect, const SkVector radii[4]) {
if (rect.isEmpty()) {
@@ -255,13 +200,6 @@
this->checkCornerContainment(rect.fLeft, rect.fBottom);
}
-static bool radii_are_nine_patch(const SkVector radii[4]) {
- return radii[SkRRect::kUpperLeft_Corner].fX == radii[SkRRect::kLowerLeft_Corner].fX &&
- radii[SkRRect::kUpperLeft_Corner].fY == radii[SkRRect::kUpperRight_Corner].fY &&
- radii[SkRRect::kUpperRight_Corner].fX == radii[SkRRect::kLowerRight_Corner].fX &&
- radii[SkRRect::kLowerLeft_Corner].fY == radii[SkRRect::kLowerRight_Corner].fY;
-}
-
// There is a simplified version of this method in setRectXY
void SkRRect::computeType() const {
SkDEBUGCODE(this->validate();)
@@ -300,11 +238,7 @@
return;
}
- if (radii_are_nine_patch(fRadii)) {
- fType = kNinePatch_Type;
- } else {
- fType = kComplex_Type;
- }
+ fType = kComplex_Type;
}
static bool matrix_only_scale_and_translate(const SkMatrix& matrix) {
@@ -457,7 +391,6 @@
allCornersSquare = false;
}
}
- bool patchesOfNine = radii_are_nine_patch(fRadii);
switch (fType) {
case kEmpty_Type:
@@ -484,15 +417,9 @@
SkASSERT(!fRect.isEmpty());
SkASSERT(!allRadiiZero && allRadiiSame && !allCornersSquare);
break;
- case kNinePatch_Type:
- SkASSERT(!fRect.isEmpty());
- SkASSERT(!allRadiiZero && !allRadiiSame && !allCornersSquare);
- SkASSERT(patchesOfNine);
- break;
case kComplex_Type:
SkASSERT(!fRect.isEmpty());
SkASSERT(!allRadiiZero && !allRadiiSame && !allCornersSquare);
- SkASSERT(!patchesOfNine);
break;
case kUnknown_Type:
// no limits on this
« no previous file with comments | « include/core/SkRRect.h ('k') | src/effects/SkBlurMaskFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698