From e37514d0b540a25471fe12ba6412dc4c8b9f9c88 Mon Sep 17 00:00:00 2001 From: bungeman Date: Thu, 25 Feb 2016 11:34:10 -0800 Subject: Fully check basis vectors for extent degeneracy. The test for 'nearly singular matrix' in SkScalerContext::computeMatrices is actually a check to see if anything will draw. Unfortunately, the current test only checks when the a skew causes nothing to draw. This adds the check for when the scale causes nothing to draw. BUG=skia:4998 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1735613002 Review URL: https://codereview.chromium.org/1735613002 --- src/core/SkScalerContext.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/core/SkScalerContext.cpp b/src/core/SkScalerContext.cpp index 29f794a99f..caef2d1377 100644 --- a/src/core/SkScalerContext.cpp +++ b/src/core/SkScalerContext.cpp @@ -724,13 +724,17 @@ void SkScalerContextRec::computeMatrices(PreMatrixScale preMatrixScale, SkVector // If the 'total' matrix is singular, set the 'scale' to something finite and zero the matrices. // All underlying ports have issues with zero text size, so use the matricies to zero. - // Map the vectors [1,1] and [1,-1] (the EM) through the 'total' matrix. + // Map the vectors [0,1], [1,0], [1,1] and [1,-1] (the EM) through the 'total' matrix. // If the length of one of these vectors is less than 1/256 then an EM filling square will // never affect any pixels. - SkVector diag[2] = { { A.getScaleX() + A.getSkewX(), A.getScaleY() + A.getSkewY() }, + SkVector diag[4] = { { A.getScaleX() , A.getSkewY() }, + { A.getSkewX(), A.getScaleY() }, + { A.getScaleX() + A.getSkewX(), A.getScaleY() + A.getSkewY() }, { A.getScaleX() - A.getSkewX(), A.getScaleY() - A.getSkewY() }, }; if (diag[0].lengthSqd() <= SK_ScalarNearlyZero * SK_ScalarNearlyZero || - diag[1].lengthSqd() <= SK_ScalarNearlyZero * SK_ScalarNearlyZero) + diag[1].lengthSqd() <= SK_ScalarNearlyZero * SK_ScalarNearlyZero || + diag[2].lengthSqd() <= SK_ScalarNearlyZero * SK_ScalarNearlyZero || + diag[3].lengthSqd() <= SK_ScalarNearlyZero * SK_ScalarNearlyZero) { s->fX = SK_Scalar1; s->fY = SK_Scalar1; -- cgit v1.2.3