aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Fredrik Söderquist <fs@opera.com>2017-01-04 13:31:47 +0100
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-01-04 13:47:24 +0000
commitb60e8645ecddb1846cdba52073db394a633841ff (patch)
treeab6e70cd42f454ce81deff6de3be60b1596fe734
parent67116384368195913ec014972b4fc38de2087fb8 (diff)
Scale the result of TightBounds when path was inverse-scaled
When the path was "large" (as defined by ScaleFactor(...)), the computed bounds would not be adjusted to the correct space. Make sure to scale the result in those cases. BUG=chromium:678162 Change-Id: Ia2eb94050c4620286e9abb69976dbc0202ecc307 Reviewed-on: https://skia-review.googlesource.com/6501 Reviewed-by: Cary Clark <caryclark@google.com> Commit-Queue: Cary Clark <caryclark@google.com>
-rw-r--r--src/pathops/SkPathOpsTightBounds.cpp4
-rw-r--r--tests/PathOpsTightBoundsTest.cpp11
2 files changed, 15 insertions, 0 deletions
diff --git a/src/pathops/SkPathOpsTightBounds.cpp b/src/pathops/SkPathOpsTightBounds.cpp
index d748ff538a..f379c9e9a7 100644
--- a/src/pathops/SkPathOpsTightBounds.cpp
+++ b/src/pathops/SkPathOpsTightBounds.cpp
@@ -75,6 +75,10 @@ bool TightBounds(const SkPath& path, SkRect* result) {
while ((current = current->next())) {
bounds.add(current->bounds());
}
+ if (scaleFactor > SK_Scalar1) {
+ bounds.set(bounds.left() * scaleFactor, bounds.top() * scaleFactor,
+ bounds.right() * scaleFactor, bounds.bottom() * scaleFactor);
+ }
*result = bounds;
if (!moveBounds.isEmpty()) {
result->join(moveBounds);
diff --git a/tests/PathOpsTightBoundsTest.cpp b/tests/PathOpsTightBoundsTest.cpp
index 8fd0fdb453..a2e7bcae9b 100644
--- a/tests/PathOpsTightBoundsTest.cpp
+++ b/tests/PathOpsTightBoundsTest.cpp
@@ -188,3 +188,14 @@ DEF_TEST(PathOpsTightBoundsIllBehaved, reporter) {
REPORTER_ASSERT(reporter, bounds != tight);
}
+DEF_TEST(PathOpsTightBoundsIllBehavedScaled, reporter) {
+ SkPath path;
+ path.moveTo(0, 0);
+ path.quadTo(1048578, 1048577, 1048576, 1048576);
+ const SkRect& bounds = path.getBounds();
+ SkRect tight;
+ REPORTER_ASSERT(reporter, TightBounds(path, &tight));
+ REPORTER_ASSERT(reporter, bounds != tight);
+ REPORTER_ASSERT(reporter, tight.right() == 1048576);
+ REPORTER_ASSERT(reporter, tight.bottom() == 1048576);
+}