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

Unified Diff: tests/MatrixTest.cpp

Issue 2143133005: Guard SkMatrix::get*Scale[s]() against negative nearly-zero values. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: guard against inf too, update the condition to better suit negative nearly-zeros and added unit tes… Created 4 years, 5 months 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
« src/core/SkMatrix.cpp ('K') | « src/core/SkMatrix.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 c4eb9c7011e35c6f72bdd5fde6b42360fda90155..414aab2f9a85b77e3d4118bb7b97859486f2c053 100644
--- a/tests/MatrixTest.cpp
+++ b/tests/MatrixTest.cpp
@@ -213,11 +213,17 @@ static void test_matrix_min_max_scale(skiatest::Reporter* reporter) {
big.setAll(2.39394089e+36f, 8.85347779e+36f, 9.26526204e+36f,
3.9159619e+36f, 1.44823453e+37f, 1.51559342e+37f,
0.f, 0.f, 1.f);
- REPORTER_ASSERT(reporter, -SK_Scalar1 == perspX.getMinScale());
- REPORTER_ASSERT(reporter, -SK_Scalar1 == perspX.getMaxScale());
success = big.getMinMaxScales(scales);
REPORTER_ASSERT(reporter, !success);
+ // skbug.com/4718
+ SkMatrix givingNegativeNearlyZeros;
+ givingNegativeNearlyZeros.setAll(0.00436534f, 0.114138f, 0.37141f,
+ 0.00358857f, 0.0936228f, -0.0174198f,
+ 0.f, 0.f, 1.f);
+ success = givingNegativeNearlyZeros.getMinMaxScales(scales);
+ REPORTER_ASSERT(reporter, success && 0 == scales[0]);
+
SkMatrix perspY;
perspY.reset();
perspY.setPerspY(-SK_Scalar1 / 500);
« src/core/SkMatrix.cpp ('K') | « src/core/SkMatrix.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698