Bug 1305085 - don't let SkScalerContext::computeMatrices generate zero scales. r=mchang
authorLee Salzman <lsalzman@mozilla.com>
Wed, 14 Jun 2017 21:43:27 -0400
changeset 364511 a0a703ef8e421c292a63b34d72b8a309e053cf03
parent 364510 46868432ff69a48ad64d4f5f5676b99e6319b1f1
child 364512 aa6b6b627a549c9ef04caf2ff04488084b84cf39
push id32043
push userarchaeopteryx@coole-files.de
push dateSat, 17 Jun 2017 20:28:42 +0000
treeherdermozilla-central@0ef3bfc9f4b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmchang
bugs1305085
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1305085 - don't let SkScalerContext::computeMatrices generate zero scales. r=mchang MozReview-Commit-ID: 4guj6XPWB47
dom/canvas/crashtests/1305085-1.html
dom/canvas/crashtests/crashtests.list
gfx/skia/skia/src/core/SkScalerContext.cpp
new file mode 100644
--- /dev/null
+++ b/dom/canvas/crashtests/1305085-1.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<script>
+var c = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');
+var cx = c.getContext('2d');
+cx.setTransform(1, 2, 2, 4, 0.41577222277777554, 0.89);
+cx.fillText("AA",2048,4);
+</script>
+</html>
--- a/dom/canvas/crashtests/crashtests.list
+++ b/dom/canvas/crashtests/crashtests.list
@@ -33,13 +33,14 @@ load 1284356-1.html
 load 1284578-1.html
 skip-if(d2d) load 1287515-1.html
 load 1287652-1.html
 load 1288872-1.html
 load 1290628-1.html
 load 1283113-1.html
 load 1286458-1.html
 load 1299062-1.html
+load 1305085-1.html
 load 1305312-1.html
 load 1298576-1.html
 load 1334366-1.html
 load 1334647-1.html
 load 1357092.html
--- a/gfx/skia/skia/src/core/SkScalerContext.cpp
+++ b/gfx/skia/skia/src/core/SkScalerContext.cpp
@@ -755,22 +755,34 @@ bool SkScalerContextRec::computeMatrices
         GA = A;
         if (G_inv) {
             G_inv->reset();
         }
     }
 
     // At this point, given GA, create s.
     switch (preMatrixScale) {
-        case kFull_PreMatrixScale:
-            s->fX = SkScalarAbs(GA.get(SkMatrix::kMScaleX));
-            s->fY = SkScalarAbs(GA.get(SkMatrix::kMScaleY));
+        case kFull_PreMatrixScale: {
+            SkScalar xScale = SkScalarAbs(GA.get(SkMatrix::kMScaleX));
+            SkScalar yScale = SkScalarAbs(GA.get(SkMatrix::kMScaleY));
+            if (xScale <= SK_ScalarNearlyZero) {
+                xScale = SK_Scalar1;
+            }
+            if (yScale <= SK_ScalarNearlyZero) {
+                yScale = SK_Scalar1;
+            }
+            s->fX = xScale;
+            s->fY = yScale;
             break;
+        }
         case kVertical_PreMatrixScale: {
             SkScalar yScale = SkScalarAbs(GA.get(SkMatrix::kMScaleY));
+            if (yScale <= SK_ScalarNearlyZero) {
+                yScale = SK_Scalar1;
+            }
             s->fX = yScale;
             s->fY = yScale;
             break;
         }
         case kVerticalInteger_PreMatrixScale: {
             SkScalar realYScale = SkScalarAbs(GA.get(SkMatrix::kMScaleY));
             SkScalar intYScale = SkScalarRoundToScalar(realYScale);
             if (intYScale == 0) {