Bug 1305085 - don't let SkScalerContext::computeMatrices generate zero scales. r=mchang

MozReview-Commit-ID: 4guj6XPWB47
This commit is contained in:
Lee Salzman 2017-06-14 21:43:27 -04:00
parent e4cbb5aad8
commit 29a9c9d166
3 changed files with 25 additions and 3 deletions

View File

@ -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>

View File

@ -38,6 +38,7 @@ 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

View File

@ -760,12 +760,24 @@ bool SkScalerContextRec::computeMatrices(PreMatrixScale preMatrixScale, SkVector
// 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;