aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2018-05-21 16:50:01 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-05-21 21:11:44 +0000
commitbc721ba4be626e3ba753f55341a7019d98044102 (patch)
tree2271839219aa876383e37f5a264a9df18d645965
parent18934c653fd6f31fd464dc7db83d583c864884dc (diff)
remove fragile hack in addOval to avoid computing bounds
Bug: skia: Change-Id: Ide917f54633370f1fce46a115fa923794b981e2e Reviewed-on: https://skia-review.googlesource.com/129461 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Reed <reed@google.com>
-rw-r--r--src/core/SkPath.cpp4
-rw-r--r--tests/PathTest.cpp21
2 files changed, 24 insertions, 1 deletions
diff --git a/src/core/SkPath.cpp b/src/core/SkPath.cpp
index 510efd6d9d..7a0f82800c 100644
--- a/src/core/SkPath.cpp
+++ b/src/core/SkPath.cpp
@@ -1252,7 +1252,9 @@ void SkPath::addOval(const SkRect &oval, Direction dir, unsigned startPointIndex
}
SkAutoDisableDirectionCheck addc(this);
- SkAutoPathBoundsUpdate apbu(this, oval);
+ // unlike addRect(), we can't use SkAutoPathBoundsUpdate here, since even with a finite
+ // bounds, we might (due to an overflow in intermediate calculations) create a nonfinite
+ // path.
SkDEBUGCODE(int initialVerbCount = this->countVerbs());
const int kVerbs = 6; // moveTo + 4x conicTo + close
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 9d8c18f997..9885a92351 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -5051,3 +5051,24 @@ DEF_TEST(Path_isRect, reporter) {
compare.set(&points53[1], 4);
REPORTER_ASSERT(reporter, rect == compare);
}
+
+/*
+ * addOval (which is called by bitmapdevice::drawOval) used to assume that if the bounds were
+ * finite, then the resulting path would be too. However, with the right (i.e. nasty) coordinates,
+ * its possible to make the calculation of the path overflow float and produce a nonfinite path.
+ * The fix was easy -- we just remove that assumption from addOval, and instead let it (lazily)
+ * compute the path as normal (i.e. just the same as if the client has made the calls to construct
+ * a path from conics).
+ *
+ * Before the fix, this test would assert
+ */
+DEF_TEST(giant_ovals, reporter) {
+ SkPaint paint;
+ SkRect r = { -3.01901558E+38f, 0, -5.32108205E+37f, 10 };
+
+ auto surface(SkSurface::MakeRasterN32Premul(84, 88));
+ SkCanvas* canvas = surface->getCanvas();
+
+ canvas->translate(-r.fLeft, 0);
+ canvas->drawOval(r, paint);
+}