From: Fredrik Söderquist Date: Wed, 4 Jan 2017 12:31:47 +0000 (+0100) Subject: Scale the result of TightBounds when path was inverse-scaled X-Git-Tag: accepted/tizen/5.0/unified/20181102.025319~55^2~1021 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b60e8645ecddb1846cdba52073db394a633841ff;p=platform%2Fupstream%2FlibSkiaSharp.git 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 Commit-Queue: Cary Clark --- diff --git a/src/pathops/SkPathOpsTightBounds.cpp b/src/pathops/SkPathOpsTightBounds.cpp index d748ff5..f379c9e 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 8fd0fdb..a2e7bca 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); +}