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

Side by Side Diff: tests/MatrixTest.cpp

Issue 1532963002: Make SkMatrix::get*Scale[s]() fail on NaN (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add SK_WARN_UNUSED_RESULT Created 5 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 unified diff | Download patch
« no previous file with comments | « src/core/SkMatrix.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkMath.h" 8 #include "SkMath.h"
9 #include "SkMatrix.h" 9 #include "SkMatrix.h"
10 #include "SkMatrixUtils.h" 10 #include "SkMatrixUtils.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 REPORTER_ASSERT(reporter, SK_Scalar1 == translate.getMinScale()); 198 REPORTER_ASSERT(reporter, SK_Scalar1 == translate.getMinScale());
199 REPORTER_ASSERT(reporter, SK_Scalar1 == translate.getMaxScale()); 199 REPORTER_ASSERT(reporter, SK_Scalar1 == translate.getMaxScale());
200 success = translate.getMinMaxScales(scales); 200 success = translate.getMinMaxScales(scales);
201 REPORTER_ASSERT(reporter, success && SK_Scalar1 == scales[0] && SK_Scalar1 = = scales[1]); 201 REPORTER_ASSERT(reporter, success && SK_Scalar1 == scales[0] && SK_Scalar1 = = scales[1]);
202 202
203 SkMatrix perspX; 203 SkMatrix perspX;
204 perspX.reset(); 204 perspX.reset();
205 perspX.setPerspX(SK_Scalar1 / 1000); 205 perspX.setPerspX(SK_Scalar1 / 1000);
206 REPORTER_ASSERT(reporter, -SK_Scalar1 == perspX.getMinScale()); 206 REPORTER_ASSERT(reporter, -SK_Scalar1 == perspX.getMinScale());
207 REPORTER_ASSERT(reporter, -SK_Scalar1 == perspX.getMaxScale()); 207 REPORTER_ASSERT(reporter, -SK_Scalar1 == perspX.getMaxScale());
208 // Verify that getMinMaxScales() doesn't update the scales array on failure.
209 scales[0] = -5;
210 scales[1] = -5;
211 success = perspX.getMinMaxScales(scales); 208 success = perspX.getMinMaxScales(scales);
212 REPORTER_ASSERT(reporter, !success && -5 * SK_Scalar1 == scales[0] && -5 * S K_Scalar1 == scales[1]); 209 REPORTER_ASSERT(reporter, !success);
210
211 // skbug.com/4718
212 SkMatrix big;
213 big.setAll(2.39394089e+36f, 8.85347779e+36f, 9.26526204e+36f,
214 3.9159619e+36f, 1.44823453e+37f, 1.51559342e+37f,
215 0.f, 0.f, 1.f);
216 REPORTER_ASSERT(reporter, -SK_Scalar1 == perspX.getMinScale());
217 REPORTER_ASSERT(reporter, -SK_Scalar1 == perspX.getMaxScale());
218 success = big.getMinMaxScales(scales);
219 REPORTER_ASSERT(reporter, !success);
213 220
214 SkMatrix perspY; 221 SkMatrix perspY;
215 perspY.reset(); 222 perspY.reset();
216 perspY.setPerspY(-SK_Scalar1 / 500); 223 perspY.setPerspY(-SK_Scalar1 / 500);
217 REPORTER_ASSERT(reporter, -SK_Scalar1 == perspY.getMinScale()); 224 REPORTER_ASSERT(reporter, -SK_Scalar1 == perspY.getMinScale());
218 REPORTER_ASSERT(reporter, -SK_Scalar1 == perspY.getMaxScale()); 225 REPORTER_ASSERT(reporter, -SK_Scalar1 == perspY.getMaxScale());
219 scales[0] = -5; 226 scales[0] = -5;
220 scales[1] = -5; 227 scales[1] = -5;
221 success = perspY.getMinMaxScales(scales); 228 success = perspY.getMinMaxScales(scales);
222 REPORTER_ASSERT(reporter, !success && -5 * SK_Scalar1 == scales[0] && -5 * S K_Scalar1 == scales[1]); 229 REPORTER_ASSERT(reporter, !success && -5 * SK_Scalar1 == scales[0] && -5 * S K_Scalar1 == scales[1]);
(...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 a.setTranslate(10, 20); 946 a.setTranslate(10, 20);
940 947
941 SkMatrix b; 948 SkMatrix b;
942 b.setScale(3, 5); 949 b.setScale(3, 5);
943 950
944 SkMatrix expected; 951 SkMatrix expected;
945 expected.setConcat(a,b); 952 expected.setConcat(a,b);
946 953
947 REPORTER_ASSERT(r, expected == SkMatrix::Concat(a, b)); 954 REPORTER_ASSERT(r, expected == SkMatrix::Concat(a, b));
948 } 955 }
OLDNEW
« no previous file with comments | « src/core/SkMatrix.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698