diff options
-rw-r--r-- | include/core/SkMatrix.h | 12 | ||||
-rw-r--r-- | src/core/SkBitmapProcShader.cpp | 4 | ||||
-rw-r--r-- | src/core/SkMatrix.cpp | 12 | ||||
-rw-r--r-- | src/gpu/GrPathUtils.cpp | 4 | ||||
-rw-r--r-- | src/gpu/SkGpuDevice.cpp | 4 | ||||
-rw-r--r-- | src/gpu/gl/GrGpuGL.cpp | 4 | ||||
-rw-r--r-- | tests/MatrixTest.cpp | 54 |
7 files changed, 47 insertions, 47 deletions
diff --git a/include/core/SkMatrix.h b/include/core/SkMatrix.h index e225336bd8..d52ab67f8c 100644 --- a/include/core/SkMatrix.h +++ b/include/core/SkMatrix.h @@ -563,20 +563,20 @@ public: SK_TO_STRING_NONVIRT() /** - * Calculates the minimum stretching factor of the matrix. If the matrix has + * Calculates the minimum scaling factor of the matrix. If the matrix has * perspective -1 is returned. * - * @return minumum strecthing factor + * @return minumum scale factor */ - SkScalar getMinStretch() const; + SkScalar getMinScale() const; /** - * Calculates the maximum stretching factor of the matrix. If the matrix has + * Calculates the maximum scale factor of the matrix. If the matrix has * perspective -1 is returned. * - * @return maximum strecthing factor + * @return maximum scale factor */ - SkScalar getMaxStretch() const; + SkScalar getMaxScale() const; /** * Return a reference to a const identity matrix diff --git a/src/core/SkBitmapProcShader.cpp b/src/core/SkBitmapProcShader.cpp index d726a46f11..3ac26f0a19 100644 --- a/src/core/SkBitmapProcShader.cpp +++ b/src/core/SkBitmapProcShader.cpp @@ -385,11 +385,11 @@ void SkBitmapProcShader::toString(SkString* str) const { // Note that this will return -1 if either matrix is perspective. static SkScalar get_combined_min_stretch(const SkMatrix& viewMatrix, const SkMatrix& localMatrix) { if (localMatrix.isIdentity()) { - return viewMatrix.getMinStretch(); + return viewMatrix.getMinScale(); } else { SkMatrix combined; combined.setConcat(viewMatrix, localMatrix); - return combined.getMinStretch(); + return combined.getMinScale(); } } diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp index 0929440e7a..483c6c83e4 100644 --- a/src/core/SkMatrix.cpp +++ b/src/core/SkMatrix.cpp @@ -1456,8 +1456,8 @@ enum MinOrMax { kMax_MinOrMax }; -template <MinOrMax MIN_OR_MAX> SkScalar get_stretch_factor(SkMatrix::TypeMask typeMask, - const SkScalar m[9]) { +template <MinOrMax MIN_OR_MAX> SkScalar get_scale_factor(SkMatrix::TypeMask typeMask, + const SkScalar m[9]) { if (typeMask & SkMatrix::kPerspective_Mask) { return -1; } @@ -1510,12 +1510,12 @@ template <MinOrMax MIN_OR_MAX> SkScalar get_stretch_factor(SkMatrix::TypeMask ty return SkScalarSqrt(chosenRoot); } -SkScalar SkMatrix::getMinStretch() const { - return get_stretch_factor<kMin_MinOrMax>(this->getType(), fMat); +SkScalar SkMatrix::getMinScale() const { + return get_scale_factor<kMin_MinOrMax>(this->getType(), fMat); } -SkScalar SkMatrix::getMaxStretch() const { - return get_stretch_factor<kMax_MinOrMax>(this->getType(), fMat); +SkScalar SkMatrix::getMaxScale() const { + return get_scale_factor<kMax_MinOrMax>(this->getType(), fMat); } static void reset_identity_matrix(SkMatrix* identity) { diff --git a/src/gpu/GrPathUtils.cpp b/src/gpu/GrPathUtils.cpp index 5fead5dea2..81921e36c8 100644 --- a/src/gpu/GrPathUtils.cpp +++ b/src/gpu/GrPathUtils.cpp @@ -14,8 +14,8 @@ SkScalar GrPathUtils::scaleToleranceToSrc(SkScalar devTol, const SkMatrix& viewM, const SkRect& pathBounds) { // In order to tesselate the path we get a bound on how much the matrix can - // stretch when mapping to screen coordinates. - SkScalar stretch = viewM.getMaxStretch(); + // scale when mapping to screen coordinates. + SkScalar stretch = viewM.getMaxScale(); SkScalar srcTol = devTol; if (stretch < 0) { diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 854839de2c..cddf50a98c 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1184,7 +1184,7 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw, break; case SkPaint::kMedium_FilterLevel: tileFilterPad = 1; - if (fContext->getMatrix().getMinStretch() < SK_Scalar1) { + if (fContext->getMatrix().getMinScale() < SK_Scalar1) { textureFilterMode = GrTextureParams::kMipMap_FilterMode; } else { // Don't trigger MIP level generation unnecessarily. @@ -1193,7 +1193,7 @@ void SkGpuDevice::drawBitmapCommon(const SkDraw& draw, break; case SkPaint::kHigh_FilterLevel: // Minification can look bad with the bicubic effect. - if (fContext->getMatrix().getMinStretch() >= SK_Scalar1) { + if (fContext->getMatrix().getMinScale() >= SK_Scalar1) { // We will install an effect that does the filtering in the shader. textureFilterMode = GrTextureParams::kNone_FilterMode; tileFilterPad = GrBicubicEffect::kFilterTexelPad; diff --git a/src/gpu/gl/GrGpuGL.cpp b/src/gpu/gl/GrGpuGL.cpp index a670eae613..c4d1c27c00 100644 --- a/src/gpu/gl/GrGpuGL.cpp +++ b/src/gpu/gl/GrGpuGL.cpp @@ -1725,7 +1725,7 @@ void GrGpuGL::onGpuDrawPath(const GrPath* path, SkPath::FillType fill) { vmi.mapRect(&bounds); // theoretically could set bloat = 0, instead leave it because of matrix inversion // precision. - SkScalar bloat = drawState->getViewMatrix().getMaxStretch() * SK_ScalarHalf; + SkScalar bloat = drawState->getViewMatrix().getMaxScale() * SK_ScalarHalf; bounds.outset(bloat, bloat); } else { avmr.setIdentity(drawState); @@ -1818,7 +1818,7 @@ void GrGpuGL::onGpuDrawPaths(int pathCount, const GrPath** paths, vmi.mapRect(&bounds); // theoretically could set bloat = 0, instead leave it because of matrix inversion // precision. - SkScalar bloat = drawState->getViewMatrix().getMaxStretch() * SK_ScalarHalf; + SkScalar bloat = drawState->getViewMatrix().getMaxScale() * SK_ScalarHalf; bounds.outset(bloat, bloat); } else { avmr.setIdentity(drawState); diff --git a/tests/MatrixTest.cpp b/tests/MatrixTest.cpp index ab406fb65d..1897554bc8 100644 --- a/tests/MatrixTest.cpp +++ b/tests/MatrixTest.cpp @@ -119,44 +119,44 @@ static void test_flatten(skiatest::Reporter* reporter, const SkMatrix& m) { REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0); } -static void test_matrix_min_max_stretch(skiatest::Reporter* reporter) { +static void test_matrix_min_max_scale(skiatest::Reporter* reporter) { SkMatrix identity; identity.reset(); - REPORTER_ASSERT(reporter, SK_Scalar1 == identity.getMinStretch()); - REPORTER_ASSERT(reporter, SK_Scalar1 == identity.getMaxStretch()); + REPORTER_ASSERT(reporter, SK_Scalar1 == identity.getMinScale()); + REPORTER_ASSERT(reporter, SK_Scalar1 == identity.getMaxScale()); SkMatrix scale; scale.setScale(SK_Scalar1 * 2, SK_Scalar1 * 4); - REPORTER_ASSERT(reporter, SK_Scalar1 * 2 == scale.getMinStretch()); - REPORTER_ASSERT(reporter, SK_Scalar1 * 4 == scale.getMaxStretch()); + REPORTER_ASSERT(reporter, SK_Scalar1 * 2 == scale.getMinScale()); + REPORTER_ASSERT(reporter, SK_Scalar1 * 4 == scale.getMaxScale()); SkMatrix rot90Scale; rot90Scale.setRotate(90 * SK_Scalar1); rot90Scale.postScale(SK_Scalar1 / 4, SK_Scalar1 / 2); - REPORTER_ASSERT(reporter, SK_Scalar1 / 4 == rot90Scale.getMinStretch()); - REPORTER_ASSERT(reporter, SK_Scalar1 / 2 == rot90Scale.getMaxStretch()); + REPORTER_ASSERT(reporter, SK_Scalar1 / 4 == rot90Scale.getMinScale()); + REPORTER_ASSERT(reporter, SK_Scalar1 / 2 == rot90Scale.getMaxScale()); SkMatrix rotate; rotate.setRotate(128 * SK_Scalar1); - REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SK_Scalar1, rotate.getMinStretch() ,SK_ScalarNearlyZero)); - REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SK_Scalar1, rotate.getMaxStretch(), SK_ScalarNearlyZero)); + REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SK_Scalar1, rotate.getMinScale() ,SK_ScalarNearlyZero)); + REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SK_Scalar1, rotate.getMaxScale(), SK_ScalarNearlyZero)); SkMatrix translate; translate.setTranslate(10 * SK_Scalar1, -5 * SK_Scalar1); - REPORTER_ASSERT(reporter, SK_Scalar1 == translate.getMinStretch()); - REPORTER_ASSERT(reporter, SK_Scalar1 == translate.getMaxStretch()); + REPORTER_ASSERT(reporter, SK_Scalar1 == translate.getMinScale()); + REPORTER_ASSERT(reporter, SK_Scalar1 == translate.getMaxScale()); SkMatrix perspX; perspX.reset(); perspX.setPerspX(SkScalarToPersp(SK_Scalar1 / 1000)); - REPORTER_ASSERT(reporter, -SK_Scalar1 == perspX.getMinStretch()); - REPORTER_ASSERT(reporter, -SK_Scalar1 == perspX.getMaxStretch()); + REPORTER_ASSERT(reporter, -SK_Scalar1 == perspX.getMinScale()); + REPORTER_ASSERT(reporter, -SK_Scalar1 == perspX.getMaxScale()); SkMatrix perspY; perspY.reset(); perspY.setPerspY(SkScalarToPersp(-SK_Scalar1 / 500)); - REPORTER_ASSERT(reporter, -SK_Scalar1 == perspY.getMinStretch()); - REPORTER_ASSERT(reporter, -SK_Scalar1 == perspY.getMaxStretch()); + REPORTER_ASSERT(reporter, -SK_Scalar1 == perspY.getMinScale()); + REPORTER_ASSERT(reporter, -SK_Scalar1 == perspY.getMaxScale()); SkMatrix baseMats[] = {scale, rot90Scale, rotate, translate, perspX, perspY}; @@ -175,20 +175,20 @@ static void test_matrix_min_max_stretch(skiatest::Reporter* reporter) { mat.postConcat(mats[x]); } - SkScalar minStretch = mat.getMinStretch(); - SkScalar maxStretch = mat.getMaxStretch(); - REPORTER_ASSERT(reporter, (minStretch < 0) == (maxStretch < 0)); - REPORTER_ASSERT(reporter, (maxStretch < 0) == mat.hasPerspective()); + SkScalar minScale = mat.getMinScale(); + SkScalar maxScale = mat.getMaxScale(); + REPORTER_ASSERT(reporter, (minScale < 0) == (maxScale < 0)); + REPORTER_ASSERT(reporter, (maxScale < 0) == mat.hasPerspective()); if (mat.hasPerspective()) { m -= 1; // try another non-persp matrix continue; } - // test a bunch of vectors. All should be scaled by between minStretch and maxStretch + // test a bunch of vectors. All should be scaled by between minScale and maxScale // (modulo some error) and we should find a vector that is scaled by almost each. - static const SkScalar gVectorStretchTol = (105 * SK_Scalar1) / 100; - static const SkScalar gClosestStretchTol = (97 * SK_Scalar1) / 100; + static const SkScalar gVectorScaleTol = (105 * SK_Scalar1) / 100; + static const SkScalar gCloseScaleTol = (97 * SK_Scalar1) / 100; SkScalar max = 0, min = SK_ScalarMax; SkVector vectors[1000]; for (size_t i = 0; i < SK_ARRAY_COUNT(vectors); ++i) { @@ -202,8 +202,8 @@ static void test_matrix_min_max_stretch(skiatest::Reporter* reporter) { mat.mapVectors(vectors, SK_ARRAY_COUNT(vectors)); for (size_t i = 0; i < SK_ARRAY_COUNT(vectors); ++i) { SkScalar d = vectors[i].length(); - REPORTER_ASSERT(reporter, SkScalarDiv(d, maxStretch) < gVectorStretchTol); - REPORTER_ASSERT(reporter, SkScalarDiv(minStretch, d) < gVectorStretchTol); + REPORTER_ASSERT(reporter, SkScalarDiv(d, maxScale) < gVectorScaleTol); + REPORTER_ASSERT(reporter, SkScalarDiv(minScale, d) < gVectorScaleTol); if (max < d) { max = d; } @@ -211,8 +211,8 @@ static void test_matrix_min_max_stretch(skiatest::Reporter* reporter) { min = d; } } - REPORTER_ASSERT(reporter, SkScalarDiv(max, maxStretch) >= gClosestStretchTol); - REPORTER_ASSERT(reporter, SkScalarDiv(minStretch, min) >= gClosestStretchTol); + REPORTER_ASSERT(reporter, SkScalarDiv(max, maxScale) >= gCloseScaleTol); + REPORTER_ASSERT(reporter, SkScalarDiv(minScale, min) >= gCloseScaleTol); } } @@ -779,7 +779,7 @@ DEF_TEST(Matrix, reporter) { mat2.set(SkMatrix::kMSkewX, SK_ScalarNaN); REPORTER_ASSERT(reporter, !are_equal(reporter, mat, mat2)); - test_matrix_min_max_stretch(reporter); + test_matrix_min_max_scale(reporter); test_matrix_is_similarity(reporter); test_matrix_recttorect(reporter); test_matrix_decomposition(reporter); |