Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1824)

Unified Diff: tests/MatrixTest.cpp

Issue 105353002: Do not use GrBicubic effect when downscaling. Also, don't use glTexStorage as it interferes with de… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: address comments Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/gl/GrGpuGL.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/MatrixTest.cpp
diff --git a/tests/MatrixTest.cpp b/tests/MatrixTest.cpp
index e9886941eb4e3b45f561e3eae06a9fe5645bad5d..9f4babfed91b0cd117ab37700111ca2060e21408 100644
--- a/tests/MatrixTest.cpp
+++ b/tests/MatrixTest.cpp
@@ -130,36 +130,43 @@ static void test_flatten(skiatest::Reporter* reporter, const SkMatrix& m) {
REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0);
}
-static void test_matrix_max_stretch(skiatest::Reporter* reporter) {
+static void test_matrix_min_max_stretch(skiatest::Reporter* reporter) {
SkMatrix identity;
identity.reset();
+ REPORTER_ASSERT(reporter, SK_Scalar1 == identity.getMinStretch());
REPORTER_ASSERT(reporter, SK_Scalar1 == identity.getMaxStretch());
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());
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());
SkMatrix rotate;
rotate.setRotate(128 * SK_Scalar1);
- REPORTER_ASSERT(reporter, SkScalarAbs(SK_Scalar1 - rotate.getMaxStretch()) <= SK_ScalarNearlyZero);
+ REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SK_Scalar1, rotate.getMinStretch() ,SK_ScalarNearlyZero));
+ REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SK_Scalar1, rotate.getMaxStretch(), 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());
SkMatrix perspX;
perspX.reset();
perspX.setPerspX(SkScalarToPersp(SK_Scalar1 / 1000));
+ REPORTER_ASSERT(reporter, -SK_Scalar1 == perspX.getMinStretch());
REPORTER_ASSERT(reporter, -SK_Scalar1 == perspX.getMaxStretch());
SkMatrix perspY;
perspY.reset();
- perspY.setPerspX(SkScalarToPersp(-SK_Scalar1 / 500));
+ perspY.setPerspY(SkScalarToPersp(-SK_Scalar1 / 500));
+ REPORTER_ASSERT(reporter, -SK_Scalar1 == perspY.getMinStretch());
REPORTER_ASSERT(reporter, -SK_Scalar1 == perspY.getMaxStretch());
SkMatrix baseMats[] = {scale, rot90Scale, rotate,
@@ -178,25 +185,22 @@ static void test_matrix_max_stretch(skiatest::Reporter* reporter) {
int x = rand.nextU() % SK_ARRAY_COUNT(mats);
mat.postConcat(mats[x]);
}
- SkScalar stretch = mat.getMaxStretch();
- if ((stretch < 0) != mat.hasPerspective()) {
- stretch = mat.getMaxStretch();
- }
-
- REPORTER_ASSERT(reporter, (stretch < 0) == mat.hasPerspective());
+ SkScalar minStretch = mat.getMinStretch();
+ SkScalar maxStretch = mat.getMaxStretch();
+ REPORTER_ASSERT(reporter, (minStretch < 0) == (maxStretch < 0));
+ REPORTER_ASSERT(reporter, (maxStretch < 0) == mat.hasPerspective());
if (mat.hasPerspective()) {
m -= 1; // try another non-persp matrix
continue;
}
- // test a bunch of vectors. None should be scaled by more than stretch
- // (modulo some error) and we should find a vector that is scaled by
- // almost stretch.
- static const SkScalar gStretchTol = (105 * SK_Scalar1) / 100;
- static const SkScalar gMaxStretchTol = (97 * SK_Scalar1) / 100;
- SkScalar max = 0;
+ // test a bunch of vectors. All should be scaled by between minStretch and maxStretch
+ // (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;
+ SkScalar max = 0, min = SK_ScalarMax;
SkVector vectors[1000];
for (size_t i = 0; i < SK_ARRAY_COUNT(vectors); ++i) {
vectors[i].fX = rand.nextSScalar1();
@@ -209,12 +213,17 @@ static void test_matrix_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, stretch) < gStretchTol);
+ REPORTER_ASSERT(reporter, SkScalarDiv(d, maxStretch) < gVectorStretchTol);
+ REPORTER_ASSERT(reporter, SkScalarDiv(minStretch, d) < gVectorStretchTol);
if (max < d) {
max = d;
}
+ if (min > d) {
+ min = d;
+ }
}
- REPORTER_ASSERT(reporter, SkScalarDiv(max, stretch) >= gMaxStretchTol);
+ REPORTER_ASSERT(reporter, SkScalarDiv(max, maxStretch) >= gClosestStretchTol);
+ REPORTER_ASSERT(reporter, SkScalarDiv(minStretch, min) >= gClosestStretchTol);
}
}
@@ -797,7 +806,7 @@ static void TestMatrix(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, !are_equal(reporter, mat, mat2));
#endif
- test_matrix_max_stretch(reporter);
+ test_matrix_min_max_stretch(reporter);
test_matrix_is_similarity(reporter);
test_matrix_recttorect(reporter);
test_matrix_decomposition(reporter);
« no previous file with comments | « src/gpu/gl/GrGpuGL.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698