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

Side by Side Diff: tests/PathTest.cpp

Issue 85463005: remove SkFloatToScalar macro (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: add flag to expose SkFloatToScalar to chromium 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/PathOpsOpTest.cpp ('k') | tests/PointTest.cpp » ('j') | 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 "Test.h" 8 #include "Test.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkPaint.h" 10 #include "SkPaint.h"
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 826
827 path.reset(); 827 path.reset();
828 path.addCircle(0, 0, SkIntToScalar(1), SkPath::kCW_Direction); 828 path.addCircle(0, 0, SkIntToScalar(1), SkPath::kCW_Direction);
829 path.addCircle(0, 0, SkIntToScalar(2), SkPath::kCCW_Direction); 829 path.addCircle(0, 0, SkIntToScalar(2), SkPath::kCCW_Direction);
830 check_direction(reporter, path, SkPath::kCCW_Direction); 830 check_direction(reporter, path, SkPath::kCCW_Direction);
831 831
832 #ifdef SK_SCALAR_IS_FLOAT 832 #ifdef SK_SCALAR_IS_FLOAT
833 // triangle with one point really far from the origin. 833 // triangle with one point really far from the origin.
834 path.reset(); 834 path.reset();
835 // the first point is roughly 1.05e10, 1.05e10 835 // the first point is roughly 1.05e10, 1.05e10
836 path.moveTo(SkFloatToScalar(SkBits2Float(0x501c7652)), SkFloatToScalar(SkBit s2Float(0x501c7652))); 836 path.moveTo(SkBits2Float(0x501c7652), SkBits2Float(0x501c7652));
837 path.lineTo(110 * SK_Scalar1, -10 * SK_Scalar1); 837 path.lineTo(110 * SK_Scalar1, -10 * SK_Scalar1);
838 path.lineTo(-10 * SK_Scalar1, 60 * SK_Scalar1); 838 path.lineTo(-10 * SK_Scalar1, 60 * SK_Scalar1);
839 check_direction(reporter, path, SkPath::kCCW_Direction); 839 check_direction(reporter, path, SkPath::kCCW_Direction);
840 #endif 840 #endif
841 841
842 path.reset(); 842 path.reset();
843 path.conicTo(20, 0, 20, 20, 0.5f); 843 path.conicTo(20, 0, 20, 20, 0.5f);
844 path.close(); 844 path.close();
845 check_direction(reporter, path, SkPath::kCW_Direction); 845 check_direction(reporter, path, SkPath::kCW_Direction);
846 846
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 static const struct SUPPRESS_VISIBILITY_WARNING { 1267 static const struct SUPPRESS_VISIBILITY_WARNING {
1268 SkRect fQueryRect; 1268 SkRect fQueryRect;
1269 bool fInRect; 1269 bool fInRect;
1270 bool fInCircle; 1270 bool fInCircle;
1271 bool fInRR; 1271 bool fInRR;
1272 bool fInCubicRR; 1272 bool fInCubicRR;
1273 } kQueries[] = { 1273 } kQueries[] = {
1274 {kBaseRect, true, true, false, false}, 1274 {kBaseRect, true, true, false, false},
1275 1275
1276 // rect well inside of kBaseRect 1276 // rect well inside of kBaseRect
1277 {SkRect::MakeLTRB(kBaseRect.fLeft + SkFloatToScalar(0.25f)*kBaseRect.wid th(), 1277 {SkRect::MakeLTRB(kBaseRect.fLeft + 0.25f*kBaseRect.width(),
1278 kBaseRect.fTop + SkFloatToScalar(0.25f)*kBaseRect.heig ht(), 1278 kBaseRect.fTop + 0.25f*kBaseRect.height(),
1279 kBaseRect.fRight - SkFloatToScalar(0.25f)*kBaseRect.wi dth(), 1279 kBaseRect.fRight - 0.25f*kBaseRect.width(),
1280 kBaseRect.fBottom - SkFloatToScalar(0.25f)*kBaseRect.h eight()), 1280 kBaseRect.fBottom - 0.25f*kBaseRect.height()),
1281 true, true, true, true}, 1281 true, true, true, true},
1282 1282
1283 // rects with edges off by one from kBaseRect's edges 1283 // rects with edges off by one from kBaseRect's edges
1284 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop, 1284 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop,
1285 kBaseRect.width(), kBaseRect.height() + 1), 1285 kBaseRect.width(), kBaseRect.height() + 1),
1286 false, true, false, false}, 1286 false, true, false, false},
1287 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop, 1287 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop,
1288 kBaseRect.width() + 1, kBaseRect.height()), 1288 kBaseRect.width() + 1, kBaseRect.height()),
1289 false, true, false, false}, 1289 false, true, false, false},
1290 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop, 1290 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 path.lineTo(kBaseRect.fRight, kBaseRect.fBottom); 1375 path.lineTo(kBaseRect.fRight, kBaseRect.fBottom);
1376 path.lineTo(kBaseRect.fRight, kBaseRect.fTop); 1376 path.lineTo(kBaseRect.fRight, kBaseRect.fTop);
1377 path.close(); 1377 path.close();
1378 REPORTER_ASSERT(reporter, kQueries[q].fInCubicRR == 1378 REPORTER_ASSERT(reporter, kQueries[q].fInCubicRR ==
1379 path.conservativelyContainsRect(qRect) ); 1379 path.conservativelyContainsRect(qRect) );
1380 1380
1381 } 1381 }
1382 // Slightly non-convex shape, shouldn't contain any rects. 1382 // Slightly non-convex shape, shouldn't contain any rects.
1383 path.reset(); 1383 path.reset();
1384 path.moveTo(0, 0); 1384 path.moveTo(0, 0);
1385 path.lineTo(SkIntToScalar(50), SkFloatToScalar(0.05f)); 1385 path.lineTo(SkIntToScalar(50), 0.05f);
1386 path.lineTo(SkIntToScalar(100), 0); 1386 path.lineTo(SkIntToScalar(100), 0);
1387 path.lineTo(SkIntToScalar(100), SkIntToScalar(100)); 1387 path.lineTo(SkIntToScalar(100), SkIntToScalar(100));
1388 path.lineTo(0, SkIntToScalar(100)); 1388 path.lineTo(0, SkIntToScalar(100));
1389 path.close(); 1389 path.close();
1390 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(qRect)); 1390 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(qRect));
1391 } 1391 }
1392 } 1392 }
1393 1393
1394 // make sure a minimal convex shape works, a right tri with edges along pos x and y axes. 1394 // make sure a minimal convex shape works, a right tri with edges along pos x and y axes.
1395 path.reset(); 1395 path.reset();
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after
2955 SkRect oval = {1, 2, 3, 4}; 2955 SkRect oval = {1, 2, 3, 4};
2956 p.arcTo(oval, 0, 0, true); 2956 p.arcTo(oval, 0, 0, true);
2957 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY()); 2957 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY());
2958 p.arcTo(oval, 0, 0, false); 2958 p.arcTo(oval, 0, 0, false);
2959 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY()); 2959 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY());
2960 p.arcTo(oval, 360, 0, true); 2960 p.arcTo(oval, 360, 0, true);
2961 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY()); 2961 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY());
2962 p.arcTo(oval, 360, 0, false); 2962 p.arcTo(oval, 360, 0, false);
2963 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY()); 2963 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY());
2964 for (float sweep = 359, delta = 0.5f; sweep != (float) (sweep + delta); ) { 2964 for (float sweep = 359, delta = 0.5f; sweep != (float) (sweep + delta); ) {
2965 p.arcTo(oval, 0, SkFloatToScalar(sweep), false); 2965 p.arcTo(oval, 0, sweep, false);
2966 REPORTER_ASSERT(reporter, p.getBounds() == oval); 2966 REPORTER_ASSERT(reporter, p.getBounds() == oval);
2967 sweep += delta; 2967 sweep += delta;
2968 delta /= 2; 2968 delta /= 2;
2969 } 2969 }
2970 for (float sweep = 361, delta = 0.5f; sweep != (float) (sweep - delta);) { 2970 for (float sweep = 361, delta = 0.5f; sweep != (float) (sweep - delta);) {
2971 p.arcTo(oval, 0, SkFloatToScalar(sweep), false); 2971 p.arcTo(oval, 0, sweep, false);
2972 REPORTER_ASSERT(reporter, p.getBounds() == oval); 2972 REPORTER_ASSERT(reporter, p.getBounds() == oval);
2973 sweep -= delta; 2973 sweep -= delta;
2974 delta /= 2; 2974 delta /= 2;
2975 } 2975 }
2976 SkRect noOvalWidth = {1, 2, 0, 3}; 2976 SkRect noOvalWidth = {1, 2, 0, 3};
2977 p.reset(); 2977 p.reset();
2978 p.arcTo(noOvalWidth, 0, 360, false); 2978 p.arcTo(noOvalWidth, 0, 360, false);
2979 REPORTER_ASSERT(reporter, p.isEmpty()); 2979 REPORTER_ASSERT(reporter, p.isEmpty());
2980 2980
2981 SkRect noOvalHeight = {1, 2, 3, 1}; 2981 SkRect noOvalHeight = {1, 2, 3, 1};
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
3251 test_arcTo(reporter); 3251 test_arcTo(reporter);
3252 test_addPath(reporter); 3252 test_addPath(reporter);
3253 test_conicTo_special_case(reporter); 3253 test_conicTo_special_case(reporter);
3254 test_get_point(reporter); 3254 test_get_point(reporter);
3255 test_contains(reporter); 3255 test_contains(reporter);
3256 PathTest_Private::TestPathTo(reporter); 3256 PathTest_Private::TestPathTo(reporter);
3257 } 3257 }
3258 3258
3259 #include "TestClassDef.h" 3259 #include "TestClassDef.h"
3260 DEFINE_TESTCLASS("Path", PathTestClass, TestPath) 3260 DEFINE_TESTCLASS("Path", PathTestClass, TestPath)
OLDNEW
« no previous file with comments | « tests/PathOpsOpTest.cpp ('k') | tests/PointTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698