aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2015-01-05 12:22:14 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-01-05 12:22:14 -0800
commit2b6ab61e2229bd76291b3d16ad7e386b3075eddb (patch)
tree54e4953e8b8a5501361952353b04ed16616f9ce8
parent5a2315e750f65a8b61faa509a65840c622f04424 (diff)
Remove SkPath::asRect
AFAICT the asRect entry point is not needed. Greg: GPU Reed: API Cary: Path Review URL: https://codereview.chromium.org/833193002
-rw-r--r--include/core/SkPath.h19
-rw-r--r--src/core/SkClipStack.cpp5
-rw-r--r--src/core/SkPath.cpp8
-rw-r--r--tests/PathTest.cpp13
4 files changed, 3 insertions, 42 deletions
diff --git a/include/core/SkPath.h b/include/core/SkPath.h
index 204a76e5b5..f895f7fe24 100644
--- a/include/core/SkPath.h
+++ b/include/core/SkPath.h
@@ -564,25 +564,6 @@ public:
return computedDir == dir;
}
- enum PathAsRect {
- /** The path can not draw the same as its bounds. */
- kNone_PathAsRect,
- /** The path draws the same as its bounds when filled. */
- kFill_PathAsRect,
- /** The path draws the same as its bounds when stroked or filled. */
- kStroke_PathAsRect,
- };
-
- /** Returns kFill_PathAsRect or kStroke_PathAsRect if drawing the path (either filled or
- stroked) will be equivalent to filling/stroking the path's bounding rect. If
- either is true, and direction is not null, sets the direction of the contour. If the
- path is not drawn equivalent to a rect, returns kNone_PathAsRect and ignores direction.
-
- @param direction If not null, set to the contour's direction when it is drawn as a rect
- @return the path's PathAsRect type
- */
- PathAsRect asRect(Direction* direction = NULL) const;
-
/**
* Returns true if the path specifies a rectangle.
*
diff --git a/src/core/SkClipStack.cpp b/src/core/SkClipStack.cpp
index d5462876d1..515596a969 100644
--- a/src/core/SkClipStack.cpp
+++ b/src/core/SkClipStack.cpp
@@ -112,8 +112,9 @@ void SkClipStack::Element::invertShapeFillType() {
void SkClipStack::Element::initPath(int saveCount, const SkPath& path, SkRegion::Op op,
bool doAA) {
if (!path.isInverseFillType()) {
- if (SkPath::kNone_PathAsRect != path.asRect()) {
- this->initRect(saveCount, path.getBounds(), op, doAA);
+ SkRect r;
+ if (path.isRect(&r)) {
+ this->initRect(saveCount, r, op, doAA);
return;
}
SkRect ovalRect;
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 9231d8bf8a..128a0cf3e4 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -526,14 +526,6 @@ bool SkPath::isRectContour(bool allowPartial, int* currVerb, const SkPoint** pts
return result;
}
-SkPath::PathAsRect SkPath::asRect(Direction* direction) const {
- SK_COMPILE_ASSERT(0 == kNone_PathAsRect, path_as_rect_mismatch);
- SK_COMPILE_ASSERT(1 == kFill_PathAsRect, path_as_rect_mismatch);
- SK_COMPILE_ASSERT(2 == kStroke_PathAsRect, path_as_rect_mismatch);
- bool isClosed = false;
- return (PathAsRect) (this->isRect(NULL, &isClosed, direction) + isClosed);
-}
-
bool SkPath::isRect(SkRect* rect, bool* isClosed, Direction* direction) const {
SkDEBUGCODE(this->validate();)
int currVerb = 0;
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 80b4fa5004..a274694b71 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -1689,7 +1689,6 @@ static void test_isRect_open_close(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, path.isRect(NULL, &isClosed, NULL));
REPORTER_ASSERT(reporter, isClosed);
- REPORTER_ASSERT(reporter, SkPath::kStroke_PathAsRect == path.asRect(NULL));
}
// Simple isRect test is inline TestPath, below.
@@ -1804,15 +1803,6 @@ static void test_isRect(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, expected == computed);
REPORTER_ASSERT(reporter, isClosed == tests[testIndex].fClose);
REPORTER_ASSERT(reporter, direction == cheapDirection);
- direction = (SkPath::Direction) -1;
- if (!tests[testIndex].fClose) {
- REPORTER_ASSERT(reporter, SkPath::kFill_PathAsRect == path.asRect());
- REPORTER_ASSERT(reporter, SkPath::kFill_PathAsRect == path.asRect(&direction));
- } else {
- REPORTER_ASSERT(reporter, SkPath::kStroke_PathAsRect == path.asRect());
- REPORTER_ASSERT(reporter, SkPath::kStroke_PathAsRect == path.asRect(&direction));
- }
- REPORTER_ASSERT(reporter, direction == cheapDirection);
} else {
SkRect computed;
computed.set(123, 456, 789, 1011);
@@ -1823,9 +1813,6 @@ static void test_isRect(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, computed.fRight == 789 && computed.fBottom == 1011);
REPORTER_ASSERT(reporter, isClosed == (bool) -1);
REPORTER_ASSERT(reporter, direction == (SkPath::Direction) -1);
- REPORTER_ASSERT(reporter, SkPath::kNone_PathAsRect == path.asRect());
- REPORTER_ASSERT(reporter, SkPath::kNone_PathAsRect == path.asRect(&direction));
- REPORTER_ASSERT(reporter, direction == (SkPath::Direction) -1);
}
}