Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "SkPath.h" | 11 #include "SkPath.h" |
| 12 #include "SkParse.h" | 12 #include "SkParse.h" |
| 13 #include "SkParsePath.h" | 13 #include "SkParsePath.h" |
| 14 #include "SkPathEffect.h" | 14 #include "SkPathEffect.h" |
| 15 #include "SkRandom.h" | 15 #include "SkRandom.h" |
| 16 #include "SkReader32.h" | 16 #include "SkReader32.h" |
| 17 #include "SkRRect.h" | 17 #include "SkRRect.h" |
| 18 #include "SkSize.h" | 18 #include "SkSize.h" |
| 19 #include "SkSurface.h" | 19 #include "SkSurface.h" |
| 20 #include "SkTypes.h" | 20 #include "SkTypes.h" |
| 21 #include "SkWriter32.h" | 21 #include "SkWriter32.h" |
| 22 | 22 |
| 23 static void make_path0(SkPath* path) { | 23 static void make_path0(SkPath* path) { |
| 24 // from * https://code.google.com/p/skia/issues/detail?id=1706 | 24 // from * https://code.google.com/p/skia/issues/detail?id=1706 |
| 25 | 25 |
| 26 path->moveTo(146.939f, 1012.84f); | 26 path->moveTo(SkFloatToScalar(146.939f), SkFloatToScalar(1012.84f)); |
|
reed1
2013/11/13 18:37:52
are these macros required?
caryclark
2013/11/13 18:52:37
Only if one day, we wanted to allow optionally SkS
reed1
2013/11/13 18:58:58
Good question. It began life when scalars could be
| |
| 27 path->lineTo(181.747f, 1009.18f); | 27 path->lineTo(SkFloatToScalar(181.747f), SkFloatToScalar(1009.18f)); |
| 28 path->lineTo(182.165f, 1013.16f); | 28 path->lineTo(SkFloatToScalar(182.165f), SkFloatToScalar(1013.16f)); |
| 29 path->lineTo(147.357f, 1016.82f); | 29 path->lineTo(SkFloatToScalar(147.357f), SkFloatToScalar(1016.82f)); |
| 30 path->lineTo(146.939f, 1012.84f); | 30 path->lineTo(SkFloatToScalar(146.939f), SkFloatToScalar(1012.84f)); |
| 31 path->close(); | 31 path->close(); |
| 32 } | 32 } |
| 33 | 33 |
| 34 static void make_path1(SkPath* path) { | 34 static void make_path1(SkPath* path) { |
| 35 path->addRect(SkRect::MakeXYWH(10, 10, 10, 1)); | 35 path->addRect(SkRect::MakeXYWH(10, 10, 10, 1)); |
| 36 } | 36 } |
| 37 | 37 |
| 38 typedef void (*PathProc)(SkPath*); | 38 typedef void (*PathProc)(SkPath*); |
| 39 | 39 |
| 40 /* | 40 /* |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 SkPath copy(original); | 136 SkPath copy(original); |
| 137 REPORTER_ASSERT(reporter, copy.getGenerationID() == original.getGenerationID ()); | 137 REPORTER_ASSERT(reporter, copy.getGenerationID() == original.getGenerationID ()); |
| 138 REPORTER_ASSERT(reporter, copy.getSourcePath() == original.getSourcePath()); | 138 REPORTER_ASSERT(reporter, copy.getSourcePath() == original.getSourcePath()); |
| 139 | 139 |
| 140 // Test assigment operator. Change generation ID, copy source path. | 140 // Test assigment operator. Change generation ID, copy source path. |
| 141 SkPath assign; | 141 SkPath assign; |
| 142 assignID = assign.getGenerationID(); | 142 assignID = assign.getGenerationID(); |
| 143 assign = original; | 143 assign = original; |
| 144 REPORTER_ASSERT(reporter, assign.getGenerationID() != assignID); | 144 REPORTER_ASSERT(reporter, assign.getGenerationID() != assignID); |
| 145 REPORTER_ASSERT(reporter, assign.getSourcePath() == original.getSourcePath() ); | 145 REPORTER_ASSERT(reporter, assign.getSourcePath() == original.getSourcePath() ); |
| 146 | 146 assignID = assign.getGenerationID(); |
| 147 assign = assign; | |
|
reed1
2013/11/13 18:37:52
this looks odd enough, perhaps we could add a comm
caryclark
2013/11/13 18:52:37
I'll add a comment.
I wouldn't be surprised if I
reed1
2013/11/13 18:58:58
It definitely is. I'm just noting that we don't *t
| |
| 148 REPORTER_ASSERT(reporter, assign.getGenerationID() == assignID); | |
| 149 | |
| 147 // Test rewind. Change generation ID, don't touch source path. | 150 // Test rewind. Change generation ID, don't touch source path. |
| 148 copyID = copy.getGenerationID(); | 151 copyID = copy.getGenerationID(); |
| 149 copy.rewind(); | 152 copy.rewind(); |
| 150 REPORTER_ASSERT(reporter, copy.getGenerationID() != copyID); | 153 REPORTER_ASSERT(reporter, copy.getGenerationID() != copyID); |
| 151 REPORTER_ASSERT(reporter, copy.getSourcePath() == original.getSourcePath()); | 154 REPORTER_ASSERT(reporter, copy.getSourcePath() == original.getSourcePath()); |
| 152 | 155 |
| 153 // Test reset. Change generation ID, don't touch source path. | 156 // Test reset. Change generation ID, don't touch source path. |
| 154 assignID = assign.getGenerationID(); | 157 assignID = assign.getGenerationID(); |
| 155 assign.reset(); | 158 assign.reset(); |
| 156 REPORTER_ASSERT(reporter, assign.getGenerationID() != assignID); | 159 REPORTER_ASSERT(reporter, assign.getGenerationID() != assignID); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 215 const uint32_t v = c.getGenerationID(); | 218 const uint32_t v = c.getGenerationID(); |
| 216 REPORTER_ASSERT(reporter, (v == w) == kExpectGenIDToIgnoreFill); | 219 REPORTER_ASSERT(reporter, (v == w) == kExpectGenIDToIgnoreFill); |
| 217 | 220 |
| 218 c.rewind(); | 221 c.rewind(); |
| 219 REPORTER_ASSERT(reporter, v != c.getGenerationID()); | 222 REPORTER_ASSERT(reporter, v != c.getGenerationID()); |
| 220 } | 223 } |
| 221 | 224 |
| 222 // This used to assert in the debug build, as the edges did not all line-up. | 225 // This used to assert in the debug build, as the edges did not all line-up. |
| 223 static void test_bad_cubic_crbug234190() { | 226 static void test_bad_cubic_crbug234190() { |
| 224 SkPath path; | 227 SkPath path; |
| 225 path.moveTo(13.8509f, 3.16858f); | 228 path.moveTo(SkFloatToScalar(13.8509f), SkFloatToScalar(3.16858f)); |
| 226 path.cubicTo(-2.35893e+08f, -4.21044e+08f, | 229 path.cubicTo(SkFloatToScalar(-2.35893e+08f), SkFloatToScalar(-4.21044e+08f), |
| 227 -2.38991e+08f, -4.26573e+08f, | 230 SkFloatToScalar(-2.38991e+08f), SkFloatToScalar(-4.26573e+08f), |
| 228 -2.41016e+08f, -4.30188e+08f); | 231 SkFloatToScalar(-2.41016e+08f), SkFloatToScalar(-4.30188e+08f)) ; |
| 229 | 232 |
| 230 SkPaint paint; | 233 SkPaint paint; |
| 231 paint.setAntiAlias(true); | 234 paint.setAntiAlias(true); |
| 232 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(84, 88)); | 235 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(84, 88)); |
| 233 surface->getCanvas()->drawPath(path, paint); | 236 surface->getCanvas()->drawPath(path, paint); |
| 234 } | 237 } |
| 235 | 238 |
| 236 static void test_bad_cubic_crbug229478() { | 239 static void test_bad_cubic_crbug229478() { |
| 237 const SkPoint pts[] = { | 240 const SkPoint pts[] = { |
| 238 { 4595.91064f, -11596.9873f }, | 241 { SkFloatToScalar(4595.91064f), SkFloatToScalar(-11596.9873f) }, |
| 239 { 4597.2168f, -11595.9414f }, | 242 { SkFloatToScalar(4597.2168f), SkFloatToScalar(-11595.9414f) }, |
| 240 { 4598.52344f, -11594.8955f }, | 243 { SkFloatToScalar(4598.52344f), SkFloatToScalar(-11594.8955f) }, |
| 241 { 4599.83008f, -11593.8496f }, | 244 { SkFloatToScalar(4599.83008f), SkFloatToScalar(-11593.8496f) }, |
| 242 }; | 245 }; |
| 243 | 246 |
| 244 SkPath path; | 247 SkPath path; |
| 245 path.moveTo(pts[0]); | 248 path.moveTo(pts[0]); |
| 246 path.cubicTo(pts[1], pts[2], pts[3]); | 249 path.cubicTo(pts[1], pts[2], pts[3]); |
| 247 | 250 |
| 248 SkPaint paint; | 251 SkPaint paint; |
| 249 paint.setStyle(SkPaint::kStroke_Style); | 252 paint.setStyle(SkPaint::kStroke_Style); |
| 250 paint.setStrokeWidth(20); | 253 paint.setStrokeWidth(20); |
| 251 | 254 |
| 252 SkPath dst; | 255 SkPath dst; |
| 253 // Before the fix, this would infinite-recurse, and run out of stack | 256 // Before the fix, this would infinite-recurse, and run out of stack |
| 254 // because we would keep trying to subdivide a degenerate cubic segment. | 257 // because we would keep trying to subdivide a degenerate cubic segment. |
| 255 paint.getFillPath(path, &dst, NULL); | 258 paint.getFillPath(path, &dst, NULL); |
| 256 } | 259 } |
| 257 | 260 |
| 258 static void build_path_170666(SkPath& path) { | 261 static void build_path_170666(SkPath& path) { |
| 259 path.moveTo(17.9459f, 21.6344f); | 262 path.moveTo(SkFloatToScalar(17.9459f), SkFloatToScalar(21.6344f)); |
| 260 path.lineTo(139.545f, -47.8105f); | 263 path.lineTo(SkFloatToScalar(139.545f), SkFloatToScalar(-47.8105f)); |
| 261 path.lineTo(139.545f, -47.8105f); | 264 path.lineTo(SkFloatToScalar(139.545f), SkFloatToScalar(-47.8105f)); |
| 262 path.lineTo(131.07f, -47.3888f); | 265 path.lineTo(SkFloatToScalar(131.07f), SkFloatToScalar(-47.3888f)); |
| 263 path.lineTo(131.07f, -47.3888f); | 266 path.lineTo(SkFloatToScalar(131.07f), SkFloatToScalar(-47.3888f)); |
| 264 path.lineTo(122.586f, -46.9532f); | 267 path.lineTo(SkFloatToScalar(122.586f), SkFloatToScalar(-46.9532f)); |
| 265 path.lineTo(122.586f, -46.9532f); | 268 path.lineTo(SkFloatToScalar(122.586f), SkFloatToScalar(-46.9532f)); |
| 266 path.lineTo(18076.6f, 31390.9f); | 269 path.lineTo(SkFloatToScalar(18076.6f), SkFloatToScalar(31390.9f)); |
| 267 path.lineTo(18076.6f, 31390.9f); | 270 path.lineTo(SkFloatToScalar(18076.6f), SkFloatToScalar(31390.9f)); |
| 268 path.lineTo(18085.1f, 31390.5f); | 271 path.lineTo(SkFloatToScalar(18085.1f), SkFloatToScalar(31390.5f)); |
| 269 path.lineTo(18085.1f, 31390.5f); | 272 path.lineTo(SkFloatToScalar(18085.1f), SkFloatToScalar(31390.5f)); |
| 270 path.lineTo(18076.6f, 31390.9f); | 273 path.lineTo(SkFloatToScalar(18076.6f), SkFloatToScalar(31390.9f)); |
| 271 path.lineTo(18076.6f, 31390.9f); | 274 path.lineTo(SkFloatToScalar(18076.6f), SkFloatToScalar(31390.9f)); |
| 272 path.lineTo(17955, 31460.3f); | 275 path.lineTo(17955, SkFloatToScalar(31460.3f)); |
| 273 path.lineTo(17955, 31460.3f); | 276 path.lineTo(17955, SkFloatToScalar(31460.3f)); |
| 274 path.lineTo(17963.5f, 31459.9f); | 277 path.lineTo(SkFloatToScalar(17963.5f), SkFloatToScalar(31459.9f)); |
| 275 path.lineTo(17963.5f, 31459.9f); | 278 path.lineTo(SkFloatToScalar(17963.5f), SkFloatToScalar(31459.9f)); |
| 276 path.lineTo(17971.9f, 31459.5f); | 279 path.lineTo(SkFloatToScalar(17971.9f), SkFloatToScalar(31459.5f)); |
| 277 path.lineTo(17971.9f, 31459.5f); | 280 path.lineTo(SkFloatToScalar(17971.9f), SkFloatToScalar(31459.5f)); |
| 278 path.lineTo(17.9551f, 21.6205f); | 281 path.lineTo(SkFloatToScalar(17.9551f), SkFloatToScalar(21.6205f)); |
| 279 path.lineTo(17.9551f, 21.6205f); | 282 path.lineTo(SkFloatToScalar(17.9551f), SkFloatToScalar(21.6205f)); |
| 280 path.lineTo(9.47091f, 22.0561f); | 283 path.lineTo(SkFloatToScalar(9.47091f), SkFloatToScalar(22.0561f)); |
| 281 path.lineTo(9.47091f, 22.0561f); | 284 path.lineTo(SkFloatToScalar(9.47091f), SkFloatToScalar(22.0561f)); |
| 282 path.lineTo(17.9459f, 21.6344f); | 285 path.lineTo(SkFloatToScalar(17.9459f), SkFloatToScalar(21.6344f)); |
| 283 path.lineTo(17.9459f, 21.6344f); | 286 path.lineTo(SkFloatToScalar(17.9459f), SkFloatToScalar(21.6344f)); |
| 284 path.close();path.moveTo(0.995934f, 22.4779f); | 287 path.close();path.moveTo(SkFloatToScalar(0.995934f), SkFloatToScalar(22.4779 f)); |
| 285 path.lineTo(0.986725f, 22.4918f); | 288 path.lineTo(SkFloatToScalar(0.986725f), SkFloatToScalar(22.4918f)); |
| 286 path.lineTo(0.986725f, 22.4918f); | 289 path.lineTo(SkFloatToScalar(0.986725f), SkFloatToScalar(22.4918f)); |
| 287 path.lineTo(17955, 31460.4f); | 290 path.lineTo(17955, SkFloatToScalar(31460.4f)); |
| 288 path.lineTo(17955, 31460.4f); | 291 path.lineTo(17955, SkFloatToScalar(31460.4f)); |
| 289 path.lineTo(17971.9f, 31459.5f); | 292 path.lineTo(SkFloatToScalar(17971.9f), SkFloatToScalar(31459.5f)); |
| 290 path.lineTo(17971.9f, 31459.5f); | 293 path.lineTo(SkFloatToScalar(17971.9f), SkFloatToScalar(31459.5f)); |
| 291 path.lineTo(18093.6f, 31390.1f); | 294 path.lineTo(SkFloatToScalar(18093.6f), SkFloatToScalar(31390.1f)); |
| 292 path.lineTo(18093.6f, 31390.1f); | 295 path.lineTo(SkFloatToScalar(18093.6f), SkFloatToScalar(31390.1f)); |
| 293 path.lineTo(18093.6f, 31390); | 296 path.lineTo(SkFloatToScalar(18093.6f), 31390); |
| 294 path.lineTo(18093.6f, 31390); | 297 path.lineTo(SkFloatToScalar(18093.6f), 31390); |
| 295 path.lineTo(139.555f, -47.8244f); | 298 path.lineTo(SkFloatToScalar(139.555f), SkFloatToScalar(-47.8244f)); |
| 296 path.lineTo(139.555f, -47.8244f); | 299 path.lineTo(SkFloatToScalar(139.555f), SkFloatToScalar(-47.8244f)); |
| 297 path.lineTo(122.595f, -46.9671f); | 300 path.lineTo(SkFloatToScalar(122.595f), SkFloatToScalar(-46.9671f)); |
| 298 path.lineTo(122.595f, -46.9671f); | 301 path.lineTo(SkFloatToScalar(122.595f), SkFloatToScalar(-46.9671f)); |
| 299 path.lineTo(0.995934f, 22.4779f); | 302 path.lineTo(SkFloatToScalar(0.995934f), SkFloatToScalar(22.4779f)); |
| 300 path.lineTo(0.995934f, 22.4779f); | 303 path.lineTo(SkFloatToScalar(0.995934f), SkFloatToScalar(22.4779f)); |
| 301 path.close(); | 304 path.close(); |
| 302 path.moveTo(5.43941f, 25.5223f); | 305 path.moveTo(SkFloatToScalar(5.43941f), SkFloatToScalar(25.5223f)); |
| 303 path.lineTo(798267, -28871.1f); | 306 path.lineTo(798267, SkFloatToScalar(-28871.1f)); |
| 304 path.lineTo(798267, -28871.1f); | 307 path.lineTo(798267, SkFloatToScalar(-28871.1f)); |
| 305 path.lineTo(3.12512e+06f, -113102); | 308 path.lineTo(SkFloatToScalar(3.12512e+06f), -113102); |
| 306 path.lineTo(3.12512e+06f, -113102); | 309 path.lineTo(SkFloatToScalar(3.12512e+06f), -113102); |
| 307 path.cubicTo(5.16324e+06f, -186882, 8.15247e+06f, -295092, 1.1957e+07f, -432 813); | 310 path.cubicTo(SkFloatToScalar(5.16324e+06f), -186882, SkFloatToScalar(8.15247 e+06f), -295092, SkFloatToScalar(1.1957e+07f), -432813); |
| 308 path.cubicTo(1.95659e+07f, -708257, 3.04359e+07f, -1.10175e+06f, 4.34798e+07 f, -1.57394e+06f); | 311 path.cubicTo(SkFloatToScalar(1.95659e+07f), -708257, SkFloatToScalar(3.04359 e+07f), SkFloatToScalar(-1.10175e+06f), SkFloatToScalar(4.34798e+07f), SkFloatTo Scalar(-1.57394e+06f)); |
| 309 path.cubicTo(6.95677e+07f, -2.51831e+06f, 1.04352e+08f, -3.77748e+06f, 1.391 35e+08f, -5.03666e+06f); | 312 path.cubicTo(SkFloatToScalar(6.95677e+07f), SkFloatToScalar(-2.51831e+06f), SkFloatToScalar(1.04352e+08f), SkFloatToScalar(-3.77748e+06f), SkFloatToScalar(1 .39135e+08f), SkFloatToScalar(-5.03666e+06f)); |
| 310 path.cubicTo(1.73919e+08f, -6.29583e+06f, 2.08703e+08f, -7.555e+06f, 2.34791 e+08f, -8.49938e+06f); | 313 path.cubicTo(SkFloatToScalar(1.73919e+08f), SkFloatToScalar(-6.29583e+06f), SkFloatToScalar(2.08703e+08f), SkFloatToScalar(-7.555e+06f), SkFloatToScalar(2.3 4791e+08f), SkFloatToScalar(-8.49938e+06f)); |
| 311 path.cubicTo(2.47835e+08f, -8.97157e+06f, 2.58705e+08f, -9.36506e+06f, 2.663 14e+08f, -9.6405e+06f); | 314 path.cubicTo(SkFloatToScalar(2.47835e+08f), SkFloatToScalar(-8.97157e+06f), SkFloatToScalar(2.58705e+08f), SkFloatToScalar(-9.36506e+06f), SkFloatToScalar(2 .66314e+08f), SkFloatToScalar(-9.6405e+06f)); |
| 312 path.cubicTo(2.70118e+08f, -9.77823e+06f, 2.73108e+08f, -9.88644e+06f, 2.751 46e+08f, -9.96022e+06f); | 315 path.cubicTo(SkFloatToScalar(2.70118e+08f), SkFloatToScalar(-9.77823e+06f), SkFloatToScalar(2.73108e+08f), SkFloatToScalar(-9.88644e+06f), SkFloatToScalar(2 .75146e+08f), SkFloatToScalar(-9.96022e+06f)); |
| 313 path.cubicTo(2.76165e+08f, -9.99711e+06f, 2.76946e+08f, -1.00254e+07f, 2.774 73e+08f, -1.00444e+07f); | 316 path.cubicTo(SkFloatToScalar(2.76165e+08f), SkFloatToScalar(-9.99711e+06f), SkFloatToScalar(2.76946e+08f), SkFloatToScalar(-1.00254e+07f), SkFloatToScalar(2 .77473e+08f), SkFloatToScalar(-1.00444e+07f)); |
| 314 path.lineTo(2.78271e+08f, -1.00733e+07f); | 317 path.lineTo(SkFloatToScalar(2.78271e+08f), SkFloatToScalar(-1.00733e+07f)); |
| 315 path.lineTo(2.78271e+08f, -1.00733e+07f); | 318 path.lineTo(SkFloatToScalar(2.78271e+08f), SkFloatToScalar(-1.00733e+07f)); |
| 316 path.cubicTo(2.78271e+08f, -1.00733e+07f, 2.08703e+08f, -7.555e+06f, 135.238 f, 23.3517f); | 319 path.cubicTo(SkFloatToScalar(2.78271e+08f), SkFloatToScalar(-1.00733e+07f), SkFloatToScalar(2.08703e+08f), SkFloatToScalar(-7.555e+06f), SkFloatToScalar(135 .238f), SkFloatToScalar(23.3517f)); |
| 317 path.cubicTo(131.191f, 23.4981f, 125.995f, 23.7976f, 123.631f, 24.0206f); | 320 path.cubicTo(SkFloatToScalar(131.191f), SkFloatToScalar(23.4981f), SkFloatTo Scalar(125.995f), SkFloatToScalar(23.7976f), SkFloatToScalar(123.631f), SkFloatT oScalar(24.0206f)); |
| 318 path.cubicTo(121.267f, 24.2436f, 122.631f, 24.3056f, 126.677f, 24.1591f); | 321 path.cubicTo(SkFloatToScalar(121.267f), SkFloatToScalar(24.2436f), SkFloatTo Scalar(122.631f), SkFloatToScalar(24.3056f), SkFloatToScalar(126.677f), SkFloatT oScalar(24.1591f)); |
| 319 path.cubicTo(2.08703e+08f, -7.555e+06f, 2.78271e+08f, -1.00733e+07f, 2.78271 e+08f, -1.00733e+07f); | 322 path.cubicTo(SkFloatToScalar(2.08703e+08f), SkFloatToScalar(-7.555e+06f), Sk FloatToScalar(2.78271e+08f), SkFloatToScalar(-1.00733e+07f), SkFloatToScalar(2.7 8271e+08f), SkFloatToScalar(-1.00733e+07f)); |
| 320 path.lineTo(2.77473e+08f, -1.00444e+07f); | 323 path.lineTo(SkFloatToScalar(2.77473e+08f), SkFloatToScalar(-1.00444e+07f)); |
| 321 path.lineTo(2.77473e+08f, -1.00444e+07f); | 324 path.lineTo(SkFloatToScalar(2.77473e+08f), SkFloatToScalar(-1.00444e+07f)); |
| 322 path.cubicTo(2.76946e+08f, -1.00254e+07f, 2.76165e+08f, -9.99711e+06f, 2.751 46e+08f, -9.96022e+06f); | 325 path.cubicTo(SkFloatToScalar(2.76946e+08f), SkFloatToScalar(-1.00254e+07f), SkFloatToScalar(2.76165e+08f), SkFloatToScalar(-9.99711e+06f), SkFloatToScalar(2 .75146e+08f), SkFloatToScalar(-9.96022e+06f)); |
| 323 path.cubicTo(2.73108e+08f, -9.88644e+06f, 2.70118e+08f, -9.77823e+06f, 2.663 14e+08f, -9.6405e+06f); | 326 path.cubicTo(SkFloatToScalar(2.73108e+08f), SkFloatToScalar(-9.88644e+06f), SkFloatToScalar(2.70118e+08f), SkFloatToScalar(-9.77823e+06f), SkFloatToScalar(2 .66314e+08f), SkFloatToScalar(-9.6405e+06f)); |
| 324 path.cubicTo(2.58705e+08f, -9.36506e+06f, 2.47835e+08f, -8.97157e+06f, 2.347 91e+08f, -8.49938e+06f); | 327 path.cubicTo(SkFloatToScalar(2.58705e+08f), SkFloatToScalar(-9.36506e+06f), SkFloatToScalar(2.47835e+08f), SkFloatToScalar(-8.97157e+06f), SkFloatToScalar(2 .34791e+08f), SkFloatToScalar(-8.49938e+06f)); |
| 325 path.cubicTo(2.08703e+08f, -7.555e+06f, 1.73919e+08f, -6.29583e+06f, 1.39135 e+08f, -5.03666e+06f); | 328 path.cubicTo(SkFloatToScalar(2.08703e+08f), SkFloatToScalar(-7.555e+06f), Sk FloatToScalar(1.73919e+08f), SkFloatToScalar(-6.29583e+06f), SkFloatToScalar(1.3 9135e+08f), SkFloatToScalar(-5.03666e+06f)); |
| 326 path.cubicTo(1.04352e+08f, -3.77749e+06f, 6.95677e+07f, -2.51831e+06f, 4.347 98e+07f, -1.57394e+06f); | 329 path.cubicTo(SkFloatToScalar(1.04352e+08f), SkFloatToScalar(-3.77749e+06f), SkFloatToScalar(6.95677e+07f), SkFloatToScalar(-2.51831e+06f), SkFloatToScalar(4 .34798e+07f), SkFloatToScalar(-1.57394e+06f)); |
| 327 path.cubicTo(3.04359e+07f, -1.10175e+06f, 1.95659e+07f, -708258, 1.1957e+07f , -432814); | 330 path.cubicTo(SkFloatToScalar(3.04359e+07f), SkFloatToScalar(-1.10175e+06f), SkFloatToScalar(1.95659e+07f), -708258, SkFloatToScalar(1.1957e+07f), -432814); |
| 328 path.cubicTo(8.15248e+06f, -295092, 5.16324e+06f, -186883, 3.12513e+06f, -11 3103); | 331 path.cubicTo(SkFloatToScalar(8.15248e+06f), -295092, SkFloatToScalar(5.16324 e+06f), -186883, SkFloatToScalar(3.12513e+06f), -113103); |
| 329 path.lineTo(798284, -28872); | 332 path.lineTo(798284, -28872); |
| 330 path.lineTo(798284, -28872); | 333 path.lineTo(798284, -28872); |
| 331 path.lineTo(22.4044f, 24.6677f); | 334 path.lineTo(SkFloatToScalar(22.4044f), SkFloatToScalar(24.6677f)); |
| 332 path.lineTo(22.4044f, 24.6677f); | 335 path.lineTo(SkFloatToScalar(22.4044f), SkFloatToScalar(24.6677f)); |
| 333 path.cubicTo(22.5186f, 24.5432f, 18.8134f, 24.6337f, 14.1287f, 24.8697f); | 336 path.cubicTo(SkFloatToScalar(22.5186f), SkFloatToScalar(24.5432f), SkFloatTo Scalar(18.8134f), SkFloatToScalar(24.6337f), SkFloatToScalar(14.1287f), SkFloatT oScalar(24.8697f)); |
| 334 path.cubicTo(9.4439f, 25.1057f, 5.55359f, 25.3978f, 5.43941f, 25.5223f); | 337 path.cubicTo(SkFloatToScalar(9.4439f), SkFloatToScalar(25.1057f), SkFloatToS calar(5.55359f), SkFloatToScalar(25.3978f), SkFloatToScalar(5.43941f), SkFloatTo Scalar(25.5223f)); |
| 335 path.close(); | 338 path.close(); |
| 336 } | 339 } |
| 337 | 340 |
| 338 static void build_path_simple_170666(SkPath& path) { | 341 static void build_path_simple_170666(SkPath& path) { |
| 339 path.moveTo(126.677f, 24.1591f); | 342 path.moveTo(SkFloatToScalar(126.677f), SkFloatToScalar(24.1591f)); |
| 340 path.cubicTo(2.08703e+08f, -7.555e+06f, 2.78271e+08f, -1.00733e+07f, 2.78271 e+08f, -1.00733e+07f); | 343 path.cubicTo(SkFloatToScalar(2.08703e+08f), SkFloatToScalar(-7.555e+06f), Sk FloatToScalar(2.78271e+08f), SkFloatToScalar(-1.00733e+07f), SkFloatToScalar(2.7 8271e+08f), SkFloatToScalar(-1.00733e+07f)); |
| 341 } | 344 } |
| 342 | 345 |
| 343 // This used to assert in the SK_DEBUG build, as the clip step would fail with | 346 // This used to assert in the SK_DEBUG build, as the clip step would fail with |
| 344 // too-few interations in our cubic-line intersection code. That code now runs | 347 // too-few interations in our cubic-line intersection code. That code now runs |
| 345 // 24 interations (instead of 16). | 348 // 24 interations (instead of 16). |
| 346 static void test_crbug_170666() { | 349 static void test_crbug_170666() { |
| 347 SkPath path; | 350 SkPath path; |
| 348 SkPaint paint; | 351 SkPaint paint; |
| 349 paint.setAntiAlias(true); | 352 paint.setAntiAlias(true); |
| 350 | 353 |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 373 | 376 |
| 374 path.reset(); | 377 path.reset(); |
| 375 REPORTER_ASSERT(reporter, path.isFinite()); | 378 REPORTER_ASSERT(reporter, path.isFinite()); |
| 376 | 379 |
| 377 path.addRect(SkRect::MakeWH(50, 100)); | 380 path.addRect(SkRect::MakeWH(50, 100)); |
| 378 REPORTER_ASSERT(reporter, path.isFinite()); | 381 REPORTER_ASSERT(reporter, path.isFinite()); |
| 379 } | 382 } |
| 380 | 383 |
| 381 static void build_big_path(SkPath* path, bool reducedCase) { | 384 static void build_big_path(SkPath* path, bool reducedCase) { |
| 382 if (reducedCase) { | 385 if (reducedCase) { |
| 383 path->moveTo(577330, 1971.72f); | 386 path->moveTo(577330, SkFloatToScalar(1971.72f)); |
| 384 path->cubicTo(10.7082f, -116.596f, 262.057f, 45.6468f, 294.694f, 1.96237 f); | 387 path->cubicTo(SkFloatToScalar(10.7082f), SkFloatToScalar(-116.596f), SkF loatToScalar(262.057f), SkFloatToScalar(45.6468f), SkFloatToScalar(294.694f), Sk FloatToScalar(1.96237f)); |
| 385 } else { | 388 } else { |
| 386 path->moveTo(60.1631f, 7.70567f); | 389 path->moveTo(SkFloatToScalar(60.1631f), SkFloatToScalar(7.70567f)); |
| 387 path->quadTo(60.1631f, 7.70567f, 0.99474f, 0.901199f); | 390 path->quadTo(SkFloatToScalar(60.1631f), SkFloatToScalar(7.70567f), SkFlo atToScalar(0.99474f), SkFloatToScalar(0.901199f)); |
| 388 path->lineTo(577379, 1977.77f); | 391 path->lineTo(577379, SkFloatToScalar(1977.77f)); |
| 389 path->quadTo(577364, 1979.57f, 577325, 1980.26f); | 392 path->quadTo(577364, SkFloatToScalar(1979.57f), 577325, SkFloatToScalar( 1980.26f)); |
| 390 path->quadTo(577286, 1980.95f, 577245, 1980.13f); | 393 path->quadTo(577286, SkFloatToScalar(1980.95f), 577245, SkFloatToScalar( 1980.13f)); |
| 391 path->quadTo(577205, 1979.3f, 577187, 1977.45f); | 394 path->quadTo(577205, SkFloatToScalar(1979.3f), 577187, SkFloatToScalar(1 977.45f)); |
| 392 path->quadTo(577168, 1975.6f, 577183, 1973.8f); | 395 path->quadTo(577168, SkFloatToScalar(1975.6f), 577183, SkFloatToScalar(1 973.8f)); |
| 393 path->quadTo(577198, 1972, 577238, 1971.31f); | 396 path->quadTo(577198, 1972, 577238, SkFloatToScalar(1971.31f)); |
| 394 path->quadTo(577277, 1970.62f, 577317, 1971.45f); | 397 path->quadTo(577277, SkFloatToScalar(1970.62f), 577317, SkFloatToScalar( 1971.45f)); |
| 395 path->quadTo(577330, 1971.72f, 577341, 1972.11f); | 398 path->quadTo(577330, SkFloatToScalar(1971.72f), 577341, SkFloatToScalar( 1972.11f)); |
| 396 path->cubicTo(10.7082f, -116.596f, 262.057f, 45.6468f, 294.694f, 1.96237 f); | 399 path->cubicTo(SkFloatToScalar(10.7082f), SkFloatToScalar(-116.596f), SkF loatToScalar(262.057f), SkFloatToScalar(45.6468f), SkFloatToScalar(294.694f), Sk FloatToScalar(1.96237f)); |
| 397 path->moveTo(306.718f, -32.912f); | 400 path->moveTo(SkFloatToScalar(306.718f), SkFloatToScalar(-32.912f)); |
| 398 path->cubicTo(30.531f, 10.0005f, 1502.47f, 13.2804f, 84.3088f, 9.99601f) ; | 401 path->cubicTo(SkFloatToScalar(30.531f), SkFloatToScalar(10.0005f), SkFlo atToScalar(1502.47f), SkFloatToScalar(13.2804f), SkFloatToScalar(84.3088f), SkFl oatToScalar(9.99601f)); |
| 399 } | 402 } |
| 400 } | 403 } |
| 401 | 404 |
| 402 static void test_clipped_cubic() { | 405 static void test_clipped_cubic() { |
| 403 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(640, 480)); | 406 SkAutoTUnref<SkSurface> surface(SkSurface::NewRasterPMColor(640, 480)); |
| 404 | 407 |
| 405 // This path used to assert, because our cubic-chopping code incorrectly | 408 // This path used to assert, because our cubic-chopping code incorrectly |
| 406 // moved control points after the chop. This test should be run in SK_DEBUG | 409 // moved control points after the chop. This test should be run in SK_DEBUG |
| 407 // mode to ensure that we no long assert. | 410 // mode to ensure that we no long assert. |
| 408 SkPath path; | 411 SkPath path; |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 439 SkSurface* surface = SkSurface::NewRasterPMColor(19, 130); | 442 SkSurface* surface = SkSurface::NewRasterPMColor(19, 130); |
| 440 surface->getCanvas()->drawPath(path, paint); | 443 surface->getCanvas()->drawPath(path, paint); |
| 441 surface->unref(); | 444 surface->unref(); |
| 442 } | 445 } |
| 443 | 446 |
| 444 // Inspired by http://code.google.com/p/chromium/issues/detail?id=141651 | 447 // Inspired by http://code.google.com/p/chromium/issues/detail?id=141651 |
| 445 // | 448 // |
| 446 static void test_isfinite_after_transform(skiatest::Reporter* reporter) { | 449 static void test_isfinite_after_transform(skiatest::Reporter* reporter) { |
| 447 SkPath path; | 450 SkPath path; |
| 448 path.quadTo(157, 366, 286, 208); | 451 path.quadTo(157, 366, 286, 208); |
| 449 path.arcTo(37, 442, 315, 163, 957494590897113.0f); | 452 path.arcTo(37, 442, 315, 163, SkFloatToScalar(957494590897113.0f)); |
| 450 | 453 |
| 451 SkMatrix matrix; | 454 SkMatrix matrix; |
| 452 matrix.setScale(1000*1000, 1000*1000); | 455 matrix.setScale(1000*1000, 1000*1000); |
| 453 | 456 |
| 454 // Be sure that path::transform correctly updates isFinite and the bounds | 457 // Be sure that path::transform correctly updates isFinite and the bounds |
| 455 // if the transformation overflows. The previous bug was that isFinite was | 458 // if the transformation overflows. The previous bug was that isFinite was |
| 456 // set to true in this case, but the bounds were not set to empty (which | 459 // set to true in this case, but the bounds were not set to empty (which |
| 457 // they should be). | 460 // they should be). |
| 458 while (path.isFinite()) { | 461 while (path.isFinite()) { |
| 459 REPORTER_ASSERT(reporter, path.getBounds().isFinite()); | 462 REPORTER_ASSERT(reporter, path.getBounds().isFinite()); |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 804 | 807 |
| 805 #ifdef SK_SCALAR_IS_FLOAT | 808 #ifdef SK_SCALAR_IS_FLOAT |
| 806 // triangle with one point really far from the origin. | 809 // triangle with one point really far from the origin. |
| 807 path.reset(); | 810 path.reset(); |
| 808 // the first point is roughly 1.05e10, 1.05e10 | 811 // the first point is roughly 1.05e10, 1.05e10 |
| 809 path.moveTo(SkFloatToScalar(SkBits2Float(0x501c7652)), SkFloatToScalar(SkBit s2Float(0x501c7652))); | 812 path.moveTo(SkFloatToScalar(SkBits2Float(0x501c7652)), SkFloatToScalar(SkBit s2Float(0x501c7652))); |
| 810 path.lineTo(110 * SK_Scalar1, -10 * SK_Scalar1); | 813 path.lineTo(110 * SK_Scalar1, -10 * SK_Scalar1); |
| 811 path.lineTo(-10 * SK_Scalar1, 60 * SK_Scalar1); | 814 path.lineTo(-10 * SK_Scalar1, 60 * SK_Scalar1); |
| 812 check_direction(reporter, path, SkPath::kCCW_Direction); | 815 check_direction(reporter, path, SkPath::kCCW_Direction); |
| 813 #endif | 816 #endif |
| 817 | |
| 818 path.reset(); | |
| 819 path.conicTo(20, 0, 20, 20, SkFloatToScalar(0.5f)); | |
| 820 path.close(); | |
| 821 check_direction(reporter, path, SkPath::kCW_Direction); | |
| 822 | |
| 823 path.reset(); | |
| 824 path.lineTo(1, SkFloatToScalar(1e7f)); | |
| 825 path.lineTo(SkFloatToScalar(1e7f), SkFloatToScalar(2e7f)); | |
| 826 path.close(); | |
| 827 REPORTER_ASSERT(reporter, SkPath::kConvex_Convexity == path.getConvexity()); | |
| 828 check_direction(reporter, path, SkPath::kCCW_Direction); | |
| 814 } | 829 } |
| 815 | 830 |
| 816 static void add_rect(SkPath* path, const SkRect& r) { | 831 static void add_rect(SkPath* path, const SkRect& r) { |
| 817 path->moveTo(r.fLeft, r.fTop); | 832 path->moveTo(r.fLeft, r.fTop); |
| 818 path->lineTo(r.fRight, r.fTop); | 833 path->lineTo(r.fRight, r.fTop); |
| 819 path->lineTo(r.fRight, r.fBottom); | 834 path->lineTo(r.fRight, r.fBottom); |
| 820 path->lineTo(r.fLeft, r.fBottom); | 835 path->lineTo(r.fLeft, r.fBottom); |
| 821 path->close(); | 836 path->close(); |
| 822 } | 837 } |
| 823 | 838 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 849 | 864 |
| 850 SkPath fill; | 865 SkPath fill; |
| 851 paint.getFillPath(path, &fill); | 866 paint.getFillPath(path, &fill); |
| 852 } | 867 } |
| 853 | 868 |
| 854 // just ensure this can run w/o any SkASSERTS firing in the debug build | 869 // just ensure this can run w/o any SkASSERTS firing in the debug build |
| 855 // we used to assert due to differences in how we determine a degenerate vector | 870 // we used to assert due to differences in how we determine a degenerate vector |
| 856 // but that was fixed with the introduction of SkPoint::CanNormalize | 871 // but that was fixed with the introduction of SkPoint::CanNormalize |
| 857 static void stroke_tiny_cubic() { | 872 static void stroke_tiny_cubic() { |
| 858 SkPoint p0[] = { | 873 SkPoint p0[] = { |
| 859 { 372.0f, 92.0f }, | 874 { SkFloatToScalar(372.0f), SkFloatToScalar(92.0f) }, |
| 860 { 372.0f, 92.0f }, | 875 { SkFloatToScalar(372.0f), SkFloatToScalar(92.0f) }, |
| 861 { 372.0f, 92.0f }, | 876 { SkFloatToScalar(372.0f), SkFloatToScalar(92.0f) }, |
| 862 { 372.0f, 92.0f }, | 877 { SkFloatToScalar(372.0f), SkFloatToScalar(92.0f) }, |
| 863 }; | 878 }; |
| 864 | 879 |
| 865 stroke_cubic(p0); | 880 stroke_cubic(p0); |
| 866 | 881 |
| 867 SkPoint p1[] = { | 882 SkPoint p1[] = { |
| 868 { 372.0f, 92.0f }, | 883 { SkFloatToScalar(372.0f), SkFloatToScalar(92.0f) }, |
| 869 { 372.0007f, 92.000755f }, | 884 { SkFloatToScalar(372.0007f), SkFloatToScalar(92.000755f) }, |
| 870 { 371.99927f, 92.003922f }, | 885 { SkFloatToScalar(371.99927f), SkFloatToScalar(92.003922f) }, |
| 871 { 371.99826f, 92.003899f }, | 886 { SkFloatToScalar(371.99826f), SkFloatToScalar(92.003899f) }, |
| 872 }; | 887 }; |
| 873 | 888 |
| 874 stroke_cubic(p1); | 889 stroke_cubic(p1); |
| 875 } | 890 } |
| 876 | 891 |
| 877 static void check_close(skiatest::Reporter* reporter, const SkPath& path) { | 892 static void check_close(skiatest::Reporter* reporter, const SkPath& path) { |
| 878 for (int i = 0; i < 2; ++i) { | 893 for (int i = 0; i < 2; ++i) { |
| 879 SkPath::Iter iter(path, SkToBool(i)); | 894 SkPath::Iter iter(path, SkToBool(i)); |
| 880 SkPoint mv; | 895 SkPoint mv; |
| 881 SkPoint pts[4]; | 896 SkPoint pts[4]; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1139 { "0 0 10 10 10 0", SkPath::kConvex_Convexity, SkPath::kCCW_Direction }, | 1154 { "0 0 10 10 10 0", SkPath::kConvex_Convexity, SkPath::kCCW_Direction }, |
| 1140 { "0 0 10 10 10 0 0 10", SkPath::kConcave_Convexity, kDontCheckDir }, | 1155 { "0 0 10 10 10 0 0 10", SkPath::kConcave_Convexity, kDontCheckDir }, |
| 1141 { "0 0 10 0 0 10 -10 -10", SkPath::kConcave_Convexity, SkPath::kCW_Direc tion }, | 1156 { "0 0 10 0 0 10 -10 -10", SkPath::kConcave_Convexity, SkPath::kCW_Direc tion }, |
| 1142 }; | 1157 }; |
| 1143 | 1158 |
| 1144 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { | 1159 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
| 1145 SkPath path; | 1160 SkPath path; |
| 1146 setFromString(&path, gRec[i].fPathStr); | 1161 setFromString(&path, gRec[i].fPathStr); |
| 1147 check_convexity(reporter, path, gRec[i].fExpectedConvexity); | 1162 check_convexity(reporter, path, gRec[i].fExpectedConvexity); |
| 1148 check_direction(reporter, path, gRec[i].fExpectedDirection); | 1163 check_direction(reporter, path, gRec[i].fExpectedDirection); |
| 1164 // check after setting the initial convex and direction | |
| 1165 if (kDontCheckDir != gRec[i].fExpectedDirection) { | |
| 1166 SkPath copy(path); | |
| 1167 SkPath::Direction dir; | |
| 1168 bool foundDir = copy.cheapComputeDirection(&dir); | |
| 1169 REPORTER_ASSERT(reporter, (gRec[i].fExpectedDirection == SkPath::kUn known_Direction) | |
| 1170 ^ foundDir); | |
| 1171 REPORTER_ASSERT(reporter, !foundDir || gRec[i].fExpectedDirection == dir); | |
| 1172 check_convexity(reporter, copy, gRec[i].fExpectedConvexity); | |
| 1173 } | |
| 1174 REPORTER_ASSERT(reporter, gRec[i].fExpectedConvexity == path.getConvexit y()); | |
| 1175 check_direction(reporter, path, gRec[i].fExpectedDirection); | |
| 1149 } | 1176 } |
| 1150 } | 1177 } |
| 1151 | 1178 |
| 1152 static void test_isLine(skiatest::Reporter* reporter) { | 1179 static void test_isLine(skiatest::Reporter* reporter) { |
| 1153 SkPath path; | 1180 SkPath path; |
| 1154 SkPoint pts[2]; | 1181 SkPoint pts[2]; |
| 1155 const SkScalar value = SkIntToScalar(5); | 1182 const SkScalar value = SkIntToScalar(5); |
| 1156 | 1183 |
| 1157 REPORTER_ASSERT(reporter, !path.isLine(NULL)); | 1184 REPORTER_ASSERT(reporter, !path.isLine(NULL)); |
| 1158 | 1185 |
| 1159 // set some non-zero values | 1186 // set some non-zero values |
| 1160 pts[0].set(value, value); | 1187 pts[0].set(value, value); |
| 1161 pts[1].set(value, value); | 1188 pts[1].set(value, value); |
| 1162 REPORTER_ASSERT(reporter, !path.isLine(pts)); | 1189 REPORTER_ASSERT(reporter, !path.isLine(pts)); |
| 1163 // check that pts was untouched | 1190 // check that pts was untouched |
| 1164 REPORTER_ASSERT(reporter, pts[0].equals(value, value)); | 1191 REPORTER_ASSERT(reporter, pts[0].equals(value, value)); |
| 1165 REPORTER_ASSERT(reporter, pts[1].equals(value, value)); | 1192 REPORTER_ASSERT(reporter, pts[1].equals(value, value)); |
| 1166 | 1193 |
| 1167 const SkScalar moveX = SkIntToScalar(1); | 1194 const SkScalar moveX = SkIntToScalar(1); |
| 1168 const SkScalar moveY = SkIntToScalar(2); | 1195 const SkScalar moveY = SkIntToScalar(2); |
| 1169 SkASSERT(value != moveX && value != moveY); | 1196 REPORTER_ASSERT(reporter, value != moveX && value != moveY); |
| 1170 | 1197 |
| 1171 path.moveTo(moveX, moveY); | 1198 path.moveTo(moveX, moveY); |
| 1172 REPORTER_ASSERT(reporter, !path.isLine(NULL)); | 1199 REPORTER_ASSERT(reporter, !path.isLine(NULL)); |
| 1173 REPORTER_ASSERT(reporter, !path.isLine(pts)); | 1200 REPORTER_ASSERT(reporter, !path.isLine(pts)); |
| 1174 // check that pts was untouched | 1201 // check that pts was untouched |
| 1175 REPORTER_ASSERT(reporter, pts[0].equals(value, value)); | 1202 REPORTER_ASSERT(reporter, pts[0].equals(value, value)); |
| 1176 REPORTER_ASSERT(reporter, pts[1].equals(value, value)); | 1203 REPORTER_ASSERT(reporter, pts[1].equals(value, value)); |
| 1177 | 1204 |
| 1178 const SkScalar lineX = SkIntToScalar(2); | 1205 const SkScalar lineX = SkIntToScalar(2); |
| 1179 const SkScalar lineY = SkIntToScalar(2); | 1206 const SkScalar lineY = SkIntToScalar(2); |
| 1180 SkASSERT(value != lineX && value != lineY); | 1207 REPORTER_ASSERT(reporter, value != lineX && value != lineY); |
| 1181 | 1208 |
| 1182 path.lineTo(lineX, lineY); | 1209 path.lineTo(lineX, lineY); |
| 1183 REPORTER_ASSERT(reporter, path.isLine(NULL)); | 1210 REPORTER_ASSERT(reporter, path.isLine(NULL)); |
| 1184 | 1211 |
| 1185 REPORTER_ASSERT(reporter, !pts[0].equals(moveX, moveY)); | 1212 REPORTER_ASSERT(reporter, !pts[0].equals(moveX, moveY)); |
| 1186 REPORTER_ASSERT(reporter, !pts[1].equals(lineX, lineY)); | 1213 REPORTER_ASSERT(reporter, !pts[1].equals(lineX, lineY)); |
| 1187 REPORTER_ASSERT(reporter, path.isLine(pts)); | 1214 REPORTER_ASSERT(reporter, path.isLine(pts)); |
| 1188 REPORTER_ASSERT(reporter, pts[0].equals(moveX, moveY)); | 1215 REPORTER_ASSERT(reporter, pts[0].equals(moveX, moveY)); |
| 1189 REPORTER_ASSERT(reporter, pts[1].equals(lineX, lineY)); | 1216 REPORTER_ASSERT(reporter, pts[1].equals(lineX, lineY)); |
| 1190 | 1217 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1207 static const SkPoint kCircleC = {kBaseRect.centerX(), kBaseRect.centerY()}; | 1234 static const SkPoint kCircleC = {kBaseRect.centerX(), kBaseRect.centerY()}; |
| 1208 | 1235 |
| 1209 // round-rect radii | 1236 // round-rect radii |
| 1210 static const SkScalar kRRRadii[] = {SkIntToScalar(5), SkIntToScalar(3)}; | 1237 static const SkScalar kRRRadii[] = {SkIntToScalar(5), SkIntToScalar(3)}; |
| 1211 | 1238 |
| 1212 static const struct SUPPRESS_VISIBILITY_WARNING { | 1239 static const struct SUPPRESS_VISIBILITY_WARNING { |
| 1213 SkRect fQueryRect; | 1240 SkRect fQueryRect; |
| 1214 bool fInRect; | 1241 bool fInRect; |
| 1215 bool fInCircle; | 1242 bool fInCircle; |
| 1216 bool fInRR; | 1243 bool fInRR; |
| 1244 bool fInCubicRR; | |
| 1217 } kQueries[] = { | 1245 } kQueries[] = { |
| 1218 {kBaseRect, true, true, false}, | 1246 {kBaseRect, true, true, false, false}, |
| 1219 | 1247 |
| 1220 // rect well inside of kBaseRect | 1248 // rect well inside of kBaseRect |
| 1221 {SkRect::MakeLTRB(kBaseRect.fLeft + SkFloatToScalar(0.25f)*kBaseRect.wid th(), | 1249 {SkRect::MakeLTRB(kBaseRect.fLeft + SkFloatToScalar(0.25f)*kBaseRect.wid th(), |
| 1222 kBaseRect.fTop + SkFloatToScalar(0.25f)*kBaseRect.heig ht(), | 1250 kBaseRect.fTop + SkFloatToScalar(0.25f)*kBaseRect.heig ht(), |
| 1223 kBaseRect.fRight - SkFloatToScalar(0.25f)*kBaseRect.wi dth(), | 1251 kBaseRect.fRight - SkFloatToScalar(0.25f)*kBaseRect.wi dth(), |
| 1224 kBaseRect.fBottom - SkFloatToScalar(0.25f)*kBaseRect.h eight()), | 1252 kBaseRect.fBottom - SkFloatToScalar(0.25f)*kBaseRect.h eight()), |
| 1225 true, true, true}, | 1253 true, true, true, true}, |
| 1226 | 1254 |
| 1227 // rects with edges off by one from kBaseRect's edges | 1255 // rects with edges off by one from kBaseRect's edges |
| 1228 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop, | 1256 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop, |
| 1229 kBaseRect.width(), kBaseRect.height() + 1), | 1257 kBaseRect.width(), kBaseRect.height() + 1), |
| 1230 false, true, false}, | 1258 false, true, false, false}, |
| 1231 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop, | 1259 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop, |
| 1232 kBaseRect.width() + 1, kBaseRect.height()), | 1260 kBaseRect.width() + 1, kBaseRect.height()), |
| 1233 false, true, false}, | 1261 false, true, false, false}, |
| 1234 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop, | 1262 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop, |
| 1235 kBaseRect.width() + 1, kBaseRect.height() + 1), | 1263 kBaseRect.width() + 1, kBaseRect.height() + 1), |
| 1236 false, true, false}, | 1264 false, true, false, false}, |
| 1237 {SkRect::MakeXYWH(kBaseRect.fLeft - 1, kBaseRect.fTop, | 1265 {SkRect::MakeXYWH(kBaseRect.fLeft - 1, kBaseRect.fTop, |
| 1238 kBaseRect.width(), kBaseRect.height()), | 1266 kBaseRect.width(), kBaseRect.height()), |
| 1239 false, true, false}, | 1267 false, true, false, false}, |
| 1240 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop - 1, | 1268 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop - 1, |
| 1241 kBaseRect.width(), kBaseRect.height()), | 1269 kBaseRect.width(), kBaseRect.height()), |
| 1242 false, true, false}, | 1270 false, true, false, false}, |
| 1243 {SkRect::MakeXYWH(kBaseRect.fLeft - 1, kBaseRect.fTop, | 1271 {SkRect::MakeXYWH(kBaseRect.fLeft - 1, kBaseRect.fTop, |
| 1244 kBaseRect.width() + 2, kBaseRect.height()), | 1272 kBaseRect.width() + 2, kBaseRect.height()), |
| 1245 false, true, false}, | 1273 false, true, false, false}, |
| 1246 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop - 1, | 1274 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop - 1, |
| 1247 kBaseRect.width() + 2, kBaseRect.height()), | 1275 kBaseRect.width() + 2, kBaseRect.height()), |
| 1248 false, true, false}, | 1276 false, true, false, false}, |
| 1249 | 1277 |
| 1250 // zero-w/h rects at each corner of kBaseRect | 1278 // zero-w/h rects at each corner of kBaseRect |
| 1251 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop, 0, 0), true, true, fa lse}, | 1279 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fTop, 0, 0), true, true, fa lse, false}, |
| 1252 {SkRect::MakeXYWH(kBaseRect.fRight, kBaseRect.fTop, 0, 0), true, true, f alse}, | 1280 {SkRect::MakeXYWH(kBaseRect.fRight, kBaseRect.fTop, 0, 0), true, true, f alse, true}, |
| 1253 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fBottom, 0, 0), true, true, false}, | 1281 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.fBottom, 0, 0), true, true, false, true}, |
| 1254 {SkRect::MakeXYWH(kBaseRect.fRight, kBaseRect.fBottom, 0, 0), true, true , false}, | 1282 {SkRect::MakeXYWH(kBaseRect.fRight, kBaseRect.fBottom, 0, 0), true, true , false, true}, |
| 1255 | 1283 |
| 1256 // far away rect | 1284 // far away rect |
| 1257 {SkRect::MakeXYWH(10 * kBaseRect.fRight, 10 * kBaseRect.fBottom, | 1285 {SkRect::MakeXYWH(10 * kBaseRect.fRight, 10 * kBaseRect.fBottom, |
| 1258 SkIntToScalar(10), SkIntToScalar(10)), | 1286 SkIntToScalar(10), SkIntToScalar(10)), |
| 1259 false, false, false}, | 1287 false, false, false, false}, |
| 1260 | 1288 |
| 1261 // very large rect containing kBaseRect | 1289 // very large rect containing kBaseRect |
| 1262 {SkRect::MakeXYWH(kBaseRect.fLeft - 5 * kBaseRect.width(), | 1290 {SkRect::MakeXYWH(kBaseRect.fLeft - 5 * kBaseRect.width(), |
| 1263 kBaseRect.fTop - 5 * kBaseRect.height(), | 1291 kBaseRect.fTop - 5 * kBaseRect.height(), |
| 1264 11 * kBaseRect.width(), 11 * kBaseRect.height()), | 1292 11 * kBaseRect.width(), 11 * kBaseRect.height()), |
| 1265 false, false, false}, | 1293 false, false, false, false}, |
| 1266 | 1294 |
| 1267 // skinny rect that spans same y-range as kBaseRect | 1295 // skinny rect that spans same y-range as kBaseRect |
| 1268 {SkRect::MakeXYWH(kBaseRect.centerX(), kBaseRect.fTop, | 1296 {SkRect::MakeXYWH(kBaseRect.centerX(), kBaseRect.fTop, |
| 1269 SkIntToScalar(1), kBaseRect.height()), | 1297 SkIntToScalar(1), kBaseRect.height()), |
| 1270 true, true, true}, | 1298 true, true, true, true}, |
| 1271 | 1299 |
| 1272 // short rect that spans same x-range as kBaseRect | 1300 // short rect that spans same x-range as kBaseRect |
| 1273 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.centerY(), kBaseRect.width( ), SkScalar(1)), | 1301 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.centerY(), kBaseRect.width( ), SkScalar(1)), |
| 1274 true, true, true}, | 1302 true, true, true, true}, |
| 1275 | 1303 |
| 1276 // skinny rect that spans slightly larger y-range than kBaseRect | 1304 // skinny rect that spans slightly larger y-range than kBaseRect |
| 1277 {SkRect::MakeXYWH(kBaseRect.centerX(), kBaseRect.fTop, | 1305 {SkRect::MakeXYWH(kBaseRect.centerX(), kBaseRect.fTop, |
| 1278 SkIntToScalar(1), kBaseRect.height() + 1), | 1306 SkIntToScalar(1), kBaseRect.height() + 1), |
| 1279 false, true, false}, | 1307 false, true, false, false}, |
| 1280 | 1308 |
| 1281 // short rect that spans slightly larger x-range than kBaseRect | 1309 // short rect that spans slightly larger x-range than kBaseRect |
| 1282 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.centerY(), | 1310 {SkRect::MakeXYWH(kBaseRect.fLeft, kBaseRect.centerY(), |
| 1283 kBaseRect.width() + 1, SkScalar(1)), | 1311 kBaseRect.width() + 1, SkScalar(1)), |
| 1284 false, true, false}, | 1312 false, true, false, false}, |
| 1285 }; | 1313 }; |
| 1286 | 1314 |
| 1287 for (int inv = 0; inv < 4; ++inv) { | 1315 for (int inv = 0; inv < 4; ++inv) { |
| 1288 for (size_t q = 0; q < SK_ARRAY_COUNT(kQueries); ++q) { | 1316 for (size_t q = 0; q < SK_ARRAY_COUNT(kQueries); ++q) { |
| 1289 SkRect qRect = kQueries[q].fQueryRect; | 1317 SkRect qRect = kQueries[q].fQueryRect; |
| 1290 if (inv & 0x1) { | 1318 if (inv & 0x1) { |
| 1291 SkTSwap(qRect.fLeft, qRect.fRight); | 1319 SkTSwap(qRect.fLeft, qRect.fRight); |
| 1292 } | 1320 } |
| 1293 if (inv & 0x2) { | 1321 if (inv & 0x2) { |
| 1294 SkTSwap(qRect.fTop, qRect.fBottom); | 1322 SkTSwap(qRect.fTop, qRect.fBottom); |
| 1295 } | 1323 } |
| 1296 for (int d = 0; d < 2; ++d) { | 1324 for (int d = 0; d < 2; ++d) { |
| 1297 SkPath::Direction dir = d ? SkPath::kCCW_Direction : SkPath::kCW _Direction; | 1325 SkPath::Direction dir = d ? SkPath::kCCW_Direction : SkPath::kCW _Direction; |
| 1298 path.reset(); | 1326 path.reset(); |
| 1299 path.addRect(kBaseRect, dir); | 1327 path.addRect(kBaseRect, dir); |
| 1300 REPORTER_ASSERT(reporter, kQueries[q].fInRect == | 1328 REPORTER_ASSERT(reporter, kQueries[q].fInRect == |
| 1301 path.conservativelyContainsRect(qRect) ); | 1329 path.conservativelyContainsRect(qRect) ); |
| 1302 | 1330 |
| 1303 path.reset(); | 1331 path.reset(); |
| 1304 path.addCircle(kCircleC.fX, kCircleC.fY, circleR, dir); | 1332 path.addCircle(kCircleC.fX, kCircleC.fY, circleR, dir); |
| 1305 REPORTER_ASSERT(reporter, kQueries[q].fInCircle == | 1333 REPORTER_ASSERT(reporter, kQueries[q].fInCircle == |
| 1306 path.conservativelyContainsRect(qRect) ); | 1334 path.conservativelyContainsRect(qRect) ); |
| 1307 | 1335 |
| 1308 path.reset(); | 1336 path.reset(); |
| 1309 path.addRoundRect(kBaseRect, kRRRadii[0], kRRRadii[1], dir); | 1337 path.addRoundRect(kBaseRect, kRRRadii[0], kRRRadii[1], dir); |
| 1310 REPORTER_ASSERT(reporter, kQueries[q].fInRR == | 1338 REPORTER_ASSERT(reporter, kQueries[q].fInRR == |
| 1311 path.conservativelyContainsRect(qRect) ); | 1339 path.conservativelyContainsRect(qRect) ); |
| 1340 | |
| 1341 path.reset(); | |
| 1342 path.moveTo(kBaseRect.fLeft + kRRRadii[0], kBaseRect.fTop); | |
| 1343 path.cubicTo(kBaseRect.fLeft + kRRRadii[0] / 2, kBaseRect.fTop, | |
| 1344 kBaseRect.fLeft, kBaseRect.fTop + kRRRadii[1] / 2, | |
| 1345 kBaseRect.fLeft, kBaseRect.fTop + kRRRadii[1]); | |
| 1346 path.lineTo(kBaseRect.fLeft, kBaseRect.fBottom); | |
| 1347 path.lineTo(kBaseRect.fRight, kBaseRect.fBottom); | |
| 1348 path.lineTo(kBaseRect.fRight, kBaseRect.fTop); | |
| 1349 path.close(); | |
| 1350 REPORTER_ASSERT(reporter, kQueries[q].fInCubicRR == | |
| 1351 path.conservativelyContainsRect(qRect) ); | |
| 1352 | |
| 1312 } | 1353 } |
| 1313 // Slightly non-convex shape, shouldn't contain any rects. | 1354 // Slightly non-convex shape, shouldn't contain any rects. |
| 1314 path.reset(); | 1355 path.reset(); |
| 1315 path.moveTo(0, 0); | 1356 path.moveTo(0, 0); |
| 1316 path.lineTo(SkIntToScalar(50), SkFloatToScalar(0.05f)); | 1357 path.lineTo(SkIntToScalar(50), SkFloatToScalar(0.05f)); |
| 1317 path.lineTo(SkIntToScalar(100), 0); | 1358 path.lineTo(SkIntToScalar(100), 0); |
| 1318 path.lineTo(SkIntToScalar(100), SkIntToScalar(100)); | 1359 path.lineTo(SkIntToScalar(100), SkIntToScalar(100)); |
| 1319 path.lineTo(0, SkIntToScalar(100)); | 1360 path.lineTo(0, SkIntToScalar(100)); |
| 1320 path.close(); | 1361 path.close(); |
| 1321 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(qRect)); | 1362 REPORTER_ASSERT(reporter, !path.conservativelyContainsRect(qRect)); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1391 // passing tests (all moveTo / lineTo... | 1432 // passing tests (all moveTo / lineTo... |
| 1392 SkPoint r1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; | 1433 SkPoint r1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; |
| 1393 SkPoint r2[] = {{1, 0}, {1, 1}, {0, 1}, {0, 0}}; | 1434 SkPoint r2[] = {{1, 0}, {1, 1}, {0, 1}, {0, 0}}; |
| 1394 SkPoint r3[] = {{1, 1}, {0, 1}, {0, 0}, {1, 0}}; | 1435 SkPoint r3[] = {{1, 1}, {0, 1}, {0, 0}, {1, 0}}; |
| 1395 SkPoint r4[] = {{0, 1}, {0, 0}, {1, 0}, {1, 1}}; | 1436 SkPoint r4[] = {{0, 1}, {0, 0}, {1, 0}, {1, 1}}; |
| 1396 SkPoint r5[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}}; | 1437 SkPoint r5[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}}; |
| 1397 SkPoint r6[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}}; | 1438 SkPoint r6[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}}; |
| 1398 SkPoint r7[] = {{1, 1}, {1, 0}, {0, 0}, {0, 1}}; | 1439 SkPoint r7[] = {{1, 1}, {1, 0}, {0, 0}, {0, 1}}; |
| 1399 SkPoint r8[] = {{1, 0}, {0, 0}, {0, 1}, {1, 1}}; | 1440 SkPoint r8[] = {{1, 0}, {0, 0}, {0, 1}, {1, 1}}; |
| 1400 SkPoint r9[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}}; | 1441 SkPoint r9[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}}; |
| 1401 SkPoint ra[] = {{0, 0}, {0, .5f}, {0, 1}, {.5f, 1}, {1, 1}, {1, .5f}, {1, 0} , {.5f, 0}}; | 1442 SkPoint ra[] = {{0, 0}, {0, SkFloatToScalar(.5f)}, {0, 1}, {SkFloatToScalar( .5f), 1}, {1, 1}, {1, SkFloatToScalar(.5f)}, {1, 0}, {SkFloatToScalar(.5f), 0}}; |
| 1402 SkPoint rb[] = {{0, 0}, {.5f, 0}, {1, 0}, {1, .5f}, {1, 1}, {.5f, 1}, {0, 1} , {0, .5f}}; | 1443 SkPoint rb[] = {{0, 0}, {SkFloatToScalar(.5f), 0}, {1, 0}, {1, SkFloatToScal ar(.5f)}, {1, 1}, {SkFloatToScalar(.5f), 1}, {0, 1}, {0, SkFloatToScalar(.5f)}}; |
| 1403 SkPoint rc[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}}; | 1444 SkPoint rc[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}}; |
| 1404 SkPoint rd[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}}; | 1445 SkPoint rd[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}}; |
| 1405 SkPoint re[] = {{0, 0}, {1, 0}, {1, 0}, {1, 1}, {0, 1}}; | 1446 SkPoint re[] = {{0, 0}, {1, 0}, {1, 0}, {1, 1}, {0, 1}}; |
| 1406 SkPoint rf[] = {{1, 0}, {8, 0}, {8, 8}, {0, 8}, {0, 0}}; | 1447 SkPoint rf[] = {{1, 0}, {8, 0}, {8, 8}, {0, 8}, {0, 0}}; |
| 1407 | 1448 |
| 1408 // failing tests | 1449 // failing tests |
| 1409 SkPoint f1[] = {{0, 0}, {1, 0}, {1, 1}}; // too few points | 1450 SkPoint f1[] = {{0, 0}, {1, 0}, {1, 1}}; // too few points |
| 1410 SkPoint f2[] = {{0, 0}, {1, 1}, {0, 1}, {1, 0}}; // diagonal | 1451 SkPoint f2[] = {{0, 0}, {1, 1}, {0, 1}, {1, 0}}; // diagonal |
| 1411 SkPoint f3[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}, {1, 0}}; // wraps | 1452 SkPoint f3[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}, {1, 0}}; // wraps |
| 1412 SkPoint f4[] = {{0, 0}, {1, 0}, {0, 0}, {1, 0}, {1, 1}, {0, 1}}; // backs up | 1453 SkPoint f4[] = {{0, 0}, {1, 0}, {0, 0}, {1, 0}, {1, 1}, {0, 1}}; // backs up |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1509 } | 1550 } |
| 1510 path1.close(); | 1551 path1.close(); |
| 1511 path1.lineTo(1, 0); | 1552 path1.lineTo(1, 0); |
| 1512 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); | 1553 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); |
| 1513 | 1554 |
| 1514 // fail, move in the middle | 1555 // fail, move in the middle |
| 1515 path1.reset(); | 1556 path1.reset(); |
| 1516 path1.moveTo(r1[0].fX, r1[0].fY); | 1557 path1.moveTo(r1[0].fX, r1[0].fY); |
| 1517 for (index = 1; index < SK_ARRAY_COUNT(r1); ++index) { | 1558 for (index = 1; index < SK_ARRAY_COUNT(r1); ++index) { |
| 1518 if (index == 2) { | 1559 if (index == 2) { |
| 1519 path1.moveTo(1, .5f); | 1560 path1.moveTo(1, SkFloatToScalar(.5f)); |
| 1520 } | 1561 } |
| 1521 path1.lineTo(r1[index].fX, r1[index].fY); | 1562 path1.lineTo(r1[index].fX, r1[index].fY); |
| 1522 } | 1563 } |
| 1523 path1.close(); | 1564 path1.close(); |
| 1524 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); | 1565 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); |
| 1525 | 1566 |
| 1526 // fail, move on the edge | 1567 // fail, move on the edge |
| 1527 path1.reset(); | 1568 path1.reset(); |
| 1528 for (index = 1; index < SK_ARRAY_COUNT(r1); ++index) { | 1569 for (index = 1; index < SK_ARRAY_COUNT(r1); ++index) { |
| 1529 path1.moveTo(r1[index - 1].fX, r1[index - 1].fY); | 1570 path1.moveTo(r1[index - 1].fX, r1[index - 1].fY); |
| 1530 path1.lineTo(r1[index].fX, r1[index].fY); | 1571 path1.lineTo(r1[index].fX, r1[index].fY); |
| 1531 } | 1572 } |
| 1532 path1.close(); | 1573 path1.close(); |
| 1533 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); | 1574 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); |
| 1534 | 1575 |
| 1535 // fail, quad | 1576 // fail, quad |
| 1536 path1.reset(); | 1577 path1.reset(); |
| 1537 path1.moveTo(r1[0].fX, r1[0].fY); | 1578 path1.moveTo(r1[0].fX, r1[0].fY); |
| 1538 for (index = 1; index < SK_ARRAY_COUNT(r1); ++index) { | 1579 for (index = 1; index < SK_ARRAY_COUNT(r1); ++index) { |
| 1539 if (index == 2) { | 1580 if (index == 2) { |
| 1540 path1.quadTo(1, .5f, 1, .5f); | 1581 path1.quadTo(1, SkFloatToScalar(.5f), 1, SkFloatToScalar(.5f)); |
| 1541 } | 1582 } |
| 1542 path1.lineTo(r1[index].fX, r1[index].fY); | 1583 path1.lineTo(r1[index].fX, r1[index].fY); |
| 1543 } | 1584 } |
| 1544 path1.close(); | 1585 path1.close(); |
| 1545 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); | 1586 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); |
| 1546 | 1587 |
| 1547 // fail, cubic | 1588 // fail, cubic |
| 1548 path1.reset(); | 1589 path1.reset(); |
| 1549 path1.moveTo(r1[0].fX, r1[0].fY); | 1590 path1.moveTo(r1[0].fX, r1[0].fY); |
| 1550 for (index = 1; index < SK_ARRAY_COUNT(r1); ++index) { | 1591 for (index = 1; index < SK_ARRAY_COUNT(r1); ++index) { |
| 1551 if (index == 2) { | 1592 if (index == 2) { |
| 1552 path1.cubicTo(1, .5f, 1, .5f, 1, .5f); | 1593 path1.cubicTo(1, SkFloatToScalar(.5f), 1, SkFloatToScalar(.5f), 1, S kFloatToScalar(.5f)); |
| 1553 } | 1594 } |
| 1554 path1.lineTo(r1[index].fX, r1[index].fY); | 1595 path1.lineTo(r1[index].fX, r1[index].fY); |
| 1555 } | 1596 } |
| 1556 path1.close(); | 1597 path1.close(); |
| 1557 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); | 1598 REPORTER_ASSERT(reporter, !path1.isRect(NULL)); |
| 1558 } | 1599 } |
| 1559 | 1600 |
| 1560 static void test_isNestedRects(skiatest::Reporter* reporter) { | 1601 static void test_isNestedRects(skiatest::Reporter* reporter) { |
| 1561 // passing tests (all moveTo / lineTo... | 1602 // passing tests (all moveTo / lineTo... |
| 1562 SkPoint r1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; // CW | 1603 SkPoint r1[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}}; // CW |
| 1563 SkPoint r2[] = {{1, 0}, {1, 1}, {0, 1}, {0, 0}}; | 1604 SkPoint r2[] = {{1, 0}, {1, 1}, {0, 1}, {0, 0}}; |
| 1564 SkPoint r3[] = {{1, 1}, {0, 1}, {0, 0}, {1, 0}}; | 1605 SkPoint r3[] = {{1, 1}, {0, 1}, {0, 0}, {1, 0}}; |
| 1565 SkPoint r4[] = {{0, 1}, {0, 0}, {1, 0}, {1, 1}}; | 1606 SkPoint r4[] = {{0, 1}, {0, 0}, {1, 0}, {1, 1}}; |
| 1566 SkPoint r5[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}}; // CCW | 1607 SkPoint r5[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}}; // CCW |
| 1567 SkPoint r6[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}}; | 1608 SkPoint r6[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}}; |
| 1568 SkPoint r7[] = {{1, 1}, {1, 0}, {0, 0}, {0, 1}}; | 1609 SkPoint r7[] = {{1, 1}, {1, 0}, {0, 0}, {0, 1}}; |
| 1569 SkPoint r8[] = {{1, 0}, {0, 0}, {0, 1}, {1, 1}}; | 1610 SkPoint r8[] = {{1, 0}, {0, 0}, {0, 1}, {1, 1}}; |
| 1570 SkPoint r9[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}}; | 1611 SkPoint r9[] = {{0, 1}, {1, 1}, {1, 0}, {0, 0}}; |
| 1571 SkPoint ra[] = {{0, 0}, {0, .5f}, {0, 1}, {.5f, 1}, {1, 1}, {1, .5f}, {1, 0} , {.5f, 0}}; // CCW | 1612 SkPoint ra[] = {{0, 0}, {0, SkFloatToScalar(.5f)}, {0, 1}, {SkFloatToScalar( .5f), 1}, {1, 1}, {1, SkFloatToScalar(.5f)}, {1, 0}, {SkFloatToScalar(.5f), 0}}; // CCW |
| 1572 SkPoint rb[] = {{0, 0}, {.5f, 0}, {1, 0}, {1, .5f}, {1, 1}, {.5f, 1}, {0, 1} , {0, .5f}}; // CW | 1613 SkPoint rb[] = {{0, 0}, {SkFloatToScalar(.5f), 0}, {1, 0}, {1, SkFloatToScal ar(.5f)}, {1, 1}, {SkFloatToScalar(.5f), 1}, {0, 1}, {0, SkFloatToScalar(.5f)}}; // CW |
| 1573 SkPoint rc[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}}; // CW | 1614 SkPoint rc[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}}; // CW |
| 1574 SkPoint rd[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}}; // CCW | 1615 SkPoint rd[] = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}}; // CCW |
| 1575 SkPoint re[] = {{0, 0}, {1, 0}, {1, 0}, {1, 1}, {0, 1}}; // CW | 1616 SkPoint re[] = {{0, 0}, {1, 0}, {1, 0}, {1, 1}, {0, 1}}; // CW |
| 1576 | 1617 |
| 1577 // failing tests | 1618 // failing tests |
| 1578 SkPoint f1[] = {{0, 0}, {1, 0}, {1, 1}}; // too few points | 1619 SkPoint f1[] = {{0, 0}, {1, 0}, {1, 1}}; // too few points |
| 1579 SkPoint f2[] = {{0, 0}, {1, 1}, {0, 1}, {1, 0}}; // diagonal | 1620 SkPoint f2[] = {{0, 0}, {1, 1}, {0, 1}, {1, 0}}; // diagonal |
| 1580 SkPoint f3[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}, {1, 0}}; // wraps | 1621 SkPoint f3[] = {{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}, {1, 0}}; // wraps |
| 1581 SkPoint f4[] = {{0, 0}, {1, 0}, {0, 0}, {1, 0}, {1, 1}, {0, 1}}; // backs up | 1622 SkPoint f4[] = {{0, 0}, {1, 0}, {0, 0}, {1, 0}, {1, 1}, {0, 1}}; // backs up |
| 1582 SkPoint f5[] = {{0, 0}, {1, 0}, {1, 1}, {2, 0}}; // end overshoots | 1623 SkPoint f5[] = {{0, 0}, {1, 0}, {1, 1}, {2, 0}}; // end overshoots |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1680 REPORTER_ASSERT(reporter, !path1.isNestedRects(NULL)); | 1721 REPORTER_ASSERT(reporter, !path1.isNestedRects(NULL)); |
| 1681 | 1722 |
| 1682 // fail, move in the middle | 1723 // fail, move in the middle |
| 1683 path1.reset(); | 1724 path1.reset(); |
| 1684 if (rectFirst) { | 1725 if (rectFirst) { |
| 1685 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); | 1726 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); |
| 1686 } | 1727 } |
| 1687 path1.moveTo(r1[0].fX, r1[0].fY); | 1728 path1.moveTo(r1[0].fX, r1[0].fY); |
| 1688 for (index = 1; index < SK_ARRAY_COUNT(r1); ++index) { | 1729 for (index = 1; index < SK_ARRAY_COUNT(r1); ++index) { |
| 1689 if (index == 2) { | 1730 if (index == 2) { |
| 1690 path1.moveTo(1, .5f); | 1731 path1.moveTo(1, SkFloatToScalar(.5f)); |
| 1691 } | 1732 } |
| 1692 path1.lineTo(r1[index].fX, r1[index].fY); | 1733 path1.lineTo(r1[index].fX, r1[index].fY); |
| 1693 } | 1734 } |
| 1694 path1.close(); | 1735 path1.close(); |
| 1695 if (!rectFirst) { | 1736 if (!rectFirst) { |
| 1696 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); | 1737 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); |
| 1697 } | 1738 } |
| 1698 REPORTER_ASSERT(reporter, !path1.isNestedRects(NULL)); | 1739 REPORTER_ASSERT(reporter, !path1.isNestedRects(NULL)); |
| 1699 | 1740 |
| 1700 // fail, move on the edge | 1741 // fail, move on the edge |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1713 REPORTER_ASSERT(reporter, !path1.isNestedRects(NULL)); | 1754 REPORTER_ASSERT(reporter, !path1.isNestedRects(NULL)); |
| 1714 | 1755 |
| 1715 // fail, quad | 1756 // fail, quad |
| 1716 path1.reset(); | 1757 path1.reset(); |
| 1717 if (rectFirst) { | 1758 if (rectFirst) { |
| 1718 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); | 1759 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); |
| 1719 } | 1760 } |
| 1720 path1.moveTo(r1[0].fX, r1[0].fY); | 1761 path1.moveTo(r1[0].fX, r1[0].fY); |
| 1721 for (index = 1; index < SK_ARRAY_COUNT(r1); ++index) { | 1762 for (index = 1; index < SK_ARRAY_COUNT(r1); ++index) { |
| 1722 if (index == 2) { | 1763 if (index == 2) { |
| 1723 path1.quadTo(1, .5f, 1, .5f); | 1764 path1.quadTo(1, SkFloatToScalar(.5f), 1, SkFloatToScalar(.5f)); |
| 1724 } | 1765 } |
| 1725 path1.lineTo(r1[index].fX, r1[index].fY); | 1766 path1.lineTo(r1[index].fX, r1[index].fY); |
| 1726 } | 1767 } |
| 1727 path1.close(); | 1768 path1.close(); |
| 1728 if (!rectFirst) { | 1769 if (!rectFirst) { |
| 1729 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); | 1770 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); |
| 1730 } | 1771 } |
| 1731 REPORTER_ASSERT(reporter, !path1.isNestedRects(NULL)); | 1772 REPORTER_ASSERT(reporter, !path1.isNestedRects(NULL)); |
| 1732 | 1773 |
| 1733 // fail, cubic | 1774 // fail, cubic |
| 1734 path1.reset(); | 1775 path1.reset(); |
| 1735 if (rectFirst) { | 1776 if (rectFirst) { |
| 1736 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); | 1777 path1.addRect(-1, -1, 2, 2, SkPath::kCW_Direction); |
| 1737 } | 1778 } |
| 1738 path1.moveTo(r1[0].fX, r1[0].fY); | 1779 path1.moveTo(r1[0].fX, r1[0].fY); |
| 1739 for (index = 1; index < SK_ARRAY_COUNT(r1); ++index) { | 1780 for (index = 1; index < SK_ARRAY_COUNT(r1); ++index) { |
| 1740 if (index == 2) { | 1781 if (index == 2) { |
| 1741 path1.cubicTo(1, .5f, 1, .5f, 1, .5f); | 1782 path1.cubicTo(1, SkFloatToScalar(.5f), 1, SkFloatToScalar(.5f), 1, SkFloatToScalar(.5f)); |
| 1742 } | 1783 } |
| 1743 path1.lineTo(r1[index].fX, r1[index].fY); | 1784 path1.lineTo(r1[index].fX, r1[index].fY); |
| 1744 } | 1785 } |
| 1745 path1.close(); | 1786 path1.close(); |
| 1746 if (!rectFirst) { | 1787 if (!rectFirst) { |
| 1747 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); | 1788 path1.addRect(-1, -1, 2, 2, SkPath::kCCW_Direction); |
| 1748 } | 1789 } |
| 1749 REPORTER_ASSERT(reporter, !path1.isNestedRects(NULL)); | 1790 REPORTER_ASSERT(reporter, !path1.isNestedRects(NULL)); |
| 1750 | 1791 |
| 1751 // fail, not nested | 1792 // fail, not nested |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1829 SkRect rect = SkRect::MakeWH(10, 10); | 1870 SkRect rect = SkRect::MakeWH(10, 10); |
| 1830 oval.addOval(rect); | 1871 oval.addOval(rect); |
| 1831 | 1872 |
| 1832 write_and_read_back(reporter, oval); | 1873 write_and_read_back(reporter, oval); |
| 1833 } | 1874 } |
| 1834 } | 1875 } |
| 1835 | 1876 |
| 1836 static void test_transform(skiatest::Reporter* reporter) { | 1877 static void test_transform(skiatest::Reporter* reporter) { |
| 1837 SkPath p, p1; | 1878 SkPath p, p1; |
| 1838 | 1879 |
| 1880 #define CONIC_PERSPECTIVE_BUG_FIXED 0 | |
| 1839 static const SkPoint pts[] = { | 1881 static const SkPoint pts[] = { |
| 1840 { 0, 0 }, | 1882 { 0, 0 }, // move |
| 1841 { SkIntToScalar(10), SkIntToScalar(10) }, | 1883 { SkIntToScalar(10), SkIntToScalar(10) }, // line |
| 1842 { SkIntToScalar(20), SkIntToScalar(10) }, { SkIntToScalar(20), 0 }, | 1884 { SkIntToScalar(20), SkIntToScalar(10) }, { SkIntToScalar(20), 0 }, // quad |
| 1843 { 0, 0 }, { 0, SkIntToScalar(10) }, { SkIntToScalar(1), SkIntToScalar(10 ) } | 1885 { 0, 0 }, { 0, SkIntToScalar(10) }, { SkIntToScalar(1), SkIntToScalar(10 ) }, // cubic |
| 1886 #if CONIC_PERSPECTIVE_BUG_FIXED | |
| 1887 { 0, 0 }, { SkIntToScalar(20), SkIntToScalar(10) }, // conic | |
| 1888 #endif | |
| 1844 }; | 1889 }; |
| 1890 const int kPtCount = SK_ARRAY_COUNT(pts); | |
| 1845 p.moveTo(pts[0]); | 1891 p.moveTo(pts[0]); |
| 1846 p.lineTo(pts[1]); | 1892 p.lineTo(pts[1]); |
| 1847 p.quadTo(pts[2], pts[3]); | 1893 p.quadTo(pts[2], pts[3]); |
| 1848 p.cubicTo(pts[4], pts[5], pts[6]); | 1894 p.cubicTo(pts[4], pts[5], pts[6]); |
| 1849 | 1895 #if CONIC_PERSPECTIVE_BUG_FIXED |
| 1896 p.conicTo(pts[4], pts[5], SkFloatToScalar(0.5f)); | |
| 1897 #endif | |
| 1898 p.close(); | |
| 1850 SkMatrix matrix; | 1899 SkMatrix matrix; |
| 1851 matrix.reset(); | 1900 matrix.reset(); |
| 1852 p.transform(matrix, &p1); | 1901 p.transform(matrix, &p1); |
| 1853 REPORTER_ASSERT(reporter, p == p1); | 1902 REPORTER_ASSERT(reporter, p == p1); |
| 1854 | 1903 |
| 1855 matrix.setScale(SK_Scalar1 * 2, SK_Scalar1 * 3); | 1904 matrix.setScale(SK_Scalar1 * 2, SK_Scalar1 * 3); |
| 1856 p.transform(matrix, &p1); | 1905 p.transform(matrix, &p1); |
| 1857 SkPoint pts1[7]; | 1906 SkPoint pts1[kPtCount]; |
| 1858 int count = p1.getPoints(pts1, 7); | 1907 int count = p1.getPoints(pts1, kPtCount); |
| 1859 REPORTER_ASSERT(reporter, 7 == count); | 1908 REPORTER_ASSERT(reporter, kPtCount == count); |
| 1860 for (int i = 0; i < count; ++i) { | 1909 for (int i = 0; i < count; ++i) { |
| 1861 SkPoint newPt = SkPoint::Make(pts[i].fX * 2, pts[i].fY * 3); | 1910 SkPoint newPt = SkPoint::Make(pts[i].fX * 2, pts[i].fY * 3); |
| 1862 REPORTER_ASSERT(reporter, newPt == pts1[i]); | 1911 REPORTER_ASSERT(reporter, newPt == pts1[i]); |
| 1863 } | 1912 } |
| 1913 matrix.reset(); | |
| 1914 matrix.setPerspX(SkScalarToPersp(4)); | |
| 1915 p.transform(matrix, &p1); | |
| 1916 REPORTER_ASSERT(reporter, matrix.invert(&matrix)); | |
| 1917 p1.transform(matrix, NULL); | |
| 1918 SkRect pBounds = p.getBounds(); | |
| 1919 SkRect p1Bounds = p1.getBounds(); | |
| 1920 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fLeft, p1Bounds.fLeft) ); | |
| 1921 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fTop, p1Bounds.fTop)); | |
| 1922 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fRight, p1Bounds.fRigh t)); | |
| 1923 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(pBounds.fBottom, p1Bounds.fBot tom)); | |
| 1924 | |
| 1925 matrix.reset(); | |
| 1926 p.reset(); | |
| 1927 p.addCircle(0, 0, 1, SkPath::kCW_Direction); | |
| 1928 p.transform(matrix, &p1); | |
| 1929 REPORTER_ASSERT(reporter, p1.cheapIsDirection(SkPath::kCW_Direction)); | |
| 1930 matrix.setScaleX(-1); | |
| 1931 p.transform(matrix, &p1); | |
| 1932 REPORTER_ASSERT(reporter, p1.cheapIsDirection(SkPath::kCCW_Direction)); | |
| 1933 matrix.setAll(1, 1, 0, 1, 1, 0, 0, 0, 1); | |
| 1934 p.transform(matrix, &p1); | |
| 1935 REPORTER_ASSERT(reporter, p1.cheapIsDirection(SkPath::kUnknown_Direction)); | |
| 1864 } | 1936 } |
| 1865 | 1937 |
| 1866 static void test_zero_length_paths(skiatest::Reporter* reporter) { | 1938 static void test_zero_length_paths(skiatest::Reporter* reporter) { |
| 1867 SkPath p; | 1939 SkPath p; |
| 1868 uint8_t verbs[32]; | 1940 uint8_t verbs[32]; |
| 1869 | 1941 |
| 1870 struct SUPPRESS_VISIBILITY_WARNING zeroPathTestData { | 1942 struct SUPPRESS_VISIBILITY_WARNING zeroPathTestData { |
| 1871 const char* testPath; | 1943 const char* testPath; |
| 1872 const size_t numResultPts; | 1944 const size_t numResultPts; |
| 1873 const SkRect resultBound; | 1945 const SkRect resultBound; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2057 int j = 0, l = 0; | 2129 int j = 0, l = 0; |
| 2058 do { | 2130 do { |
| 2059 REPORTER_ASSERT(reporter, iter.next(pts, gIterTests[i].consumeDegene rates) == gIterTests[i].resultVerbs[j]); | 2131 REPORTER_ASSERT(reporter, iter.next(pts, gIterTests[i].consumeDegene rates) == gIterTests[i].resultVerbs[j]); |
| 2060 for (int k = 0; k < (int)gIterTests[i].numResultPtsPerVerb[j]; ++k) { | 2132 for (int k = 0; k < (int)gIterTests[i].numResultPtsPerVerb[j]; ++k) { |
| 2061 REPORTER_ASSERT(reporter, pts[k] == gIterTests[i].resultPts[l++] ); | 2133 REPORTER_ASSERT(reporter, pts[k] == gIterTests[i].resultPts[l++] ); |
| 2062 } | 2134 } |
| 2063 } while (gIterTests[i].resultVerbs[j++] != SkPath::kDone_Verb); | 2135 } while (gIterTests[i].resultVerbs[j++] != SkPath::kDone_Verb); |
| 2064 REPORTER_ASSERT(reporter, j == (int)gIterTests[i].numResultVerbs); | 2136 REPORTER_ASSERT(reporter, j == (int)gIterTests[i].numResultVerbs); |
| 2065 } | 2137 } |
| 2066 | 2138 |
| 2139 p.reset(); | |
| 2140 iter.setPath(p, false); | |
| 2141 REPORTER_ASSERT(reporter, !iter.isClosedContour()); | |
| 2142 p.lineTo(1, 1); | |
| 2143 p.close(); | |
| 2144 iter.setPath(p, false); | |
| 2145 REPORTER_ASSERT(reporter, iter.isClosedContour()); | |
| 2146 p.reset(); | |
| 2147 iter.setPath(p, true); | |
| 2148 REPORTER_ASSERT(reporter, !iter.isClosedContour()); | |
| 2149 p.lineTo(1, 1); | |
| 2150 iter.setPath(p, true); | |
| 2151 REPORTER_ASSERT(reporter, iter.isClosedContour()); | |
| 2152 p.moveTo(0, 0); | |
| 2153 p.lineTo(2, 2); | |
| 2154 iter.setPath(p, false); | |
| 2155 REPORTER_ASSERT(reporter, !iter.isClosedContour()); | |
| 2156 | |
| 2157 // this checks to see if the NaN logic is executed in SkPath::autoClose(), b ut does not | |
| 2158 // check to see if the result is correct. | |
| 2159 for (int setNaN = 0; setNaN < 4; ++setNaN) { | |
| 2160 p.reset(); | |
| 2161 p.moveTo(setNaN == 0 ? SK_ScalarNaN : 0, setNaN == 1 ? SK_ScalarNaN : 0) ; | |
| 2162 p.lineTo(setNaN == 2 ? SK_ScalarNaN : 1, setNaN == 3 ? SK_ScalarNaN : 1) ; | |
| 2163 iter.setPath(p, true); | |
| 2164 iter.next(pts, false); | |
| 2165 iter.next(pts, false); | |
| 2166 REPORTER_ASSERT(reporter, SkPath::kClose_Verb == iter.next(pts, false)); | |
| 2167 } | |
| 2168 | |
| 2169 p.reset(); | |
| 2170 p.quadTo(0, 0, 0, 0); | |
| 2171 iter.setPath(p, false); | |
| 2172 iter.next(pts, false); | |
| 2173 REPORTER_ASSERT(reporter, SkPath::kQuad_Verb == iter.next(pts, false)); | |
| 2174 iter.setPath(p, false); | |
| 2175 iter.next(pts, false); | |
| 2176 REPORTER_ASSERT(reporter, SkPath::kDone_Verb == iter.next(pts, true)); | |
| 2177 | |
| 2178 p.reset(); | |
| 2179 p.cubicTo(0, 0, 0, 0, 0, 0); | |
| 2180 iter.setPath(p, false); | |
| 2181 iter.next(pts, false); | |
| 2182 REPORTER_ASSERT(reporter, SkPath::kCubic_Verb == iter.next(pts, false)); | |
| 2183 iter.setPath(p, false); | |
| 2184 iter.next(pts, false); | |
| 2185 REPORTER_ASSERT(reporter, SkPath::kDone_Verb == iter.next(pts, true)); | |
| 2186 | |
| 2067 // The GM degeneratesegments.cpp test is more extensive | 2187 // The GM degeneratesegments.cpp test is more extensive |
| 2068 } | 2188 } |
| 2069 | 2189 |
| 2070 static void test_raw_iter(skiatest::Reporter* reporter) { | 2190 static void test_raw_iter(skiatest::Reporter* reporter) { |
| 2071 SkPath p; | 2191 SkPath p; |
| 2072 SkPoint pts[4]; | 2192 SkPoint pts[4]; |
| 2073 | 2193 |
| 2074 // Test an iterator with no path | 2194 // Test an iterator with no path |
| 2075 SkPath::RawIter noPathIter; | 2195 SkPath::RawIter noPathIter; |
| 2076 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb); | 2196 REPORTER_ASSERT(reporter, noPathIter.next(pts) == SkPath::kDone_Verb); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2316 SkPath::Direction dir) { | 2436 SkPath::Direction dir) { |
| 2317 SkPath tmp; | 2437 SkPath tmp; |
| 2318 | 2438 |
| 2319 SkMatrix m; | 2439 SkMatrix m; |
| 2320 m.setSkew(SkIntToScalar(3), SkIntToScalar(5)); | 2440 m.setSkew(SkIntToScalar(3), SkIntToScalar(5)); |
| 2321 path.transform(m, &tmp); | 2441 path.transform(m, &tmp); |
| 2322 // this matrix reverses the direction. | 2442 // this matrix reverses the direction. |
| 2323 if (SkPath::kCCW_Direction == dir) { | 2443 if (SkPath::kCCW_Direction == dir) { |
| 2324 dir = SkPath::kCW_Direction; | 2444 dir = SkPath::kCW_Direction; |
| 2325 } else { | 2445 } else { |
| 2326 SkASSERT(SkPath::kCW_Direction == dir); | 2446 REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir); |
| 2327 dir = SkPath::kCCW_Direction; | 2447 dir = SkPath::kCCW_Direction; |
| 2328 } | 2448 } |
| 2329 check_for_circle(reporter, tmp, false, dir); | 2449 check_for_circle(reporter, tmp, false, dir); |
| 2330 } | 2450 } |
| 2331 | 2451 |
| 2332 static void test_circle_translate(skiatest::Reporter* reporter, | 2452 static void test_circle_translate(skiatest::Reporter* reporter, |
| 2333 const SkPath& path, | 2453 const SkPath& path, |
| 2334 SkPath::Direction dir) { | 2454 SkPath::Direction dir) { |
| 2335 SkPath tmp; | 2455 SkPath tmp; |
| 2336 | 2456 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2374 SkPath::Direction dir) { | 2494 SkPath::Direction dir) { |
| 2375 SkPath tmp; | 2495 SkPath tmp; |
| 2376 SkMatrix m; | 2496 SkMatrix m; |
| 2377 m.reset(); | 2497 m.reset(); |
| 2378 m.setScaleX(-SK_Scalar1); | 2498 m.setScaleX(-SK_Scalar1); |
| 2379 path.transform(m, &tmp); | 2499 path.transform(m, &tmp); |
| 2380 | 2500 |
| 2381 if (SkPath::kCW_Direction == dir) { | 2501 if (SkPath::kCW_Direction == dir) { |
| 2382 dir = SkPath::kCCW_Direction; | 2502 dir = SkPath::kCCW_Direction; |
| 2383 } else { | 2503 } else { |
| 2384 SkASSERT(SkPath::kCCW_Direction == dir); | 2504 REPORTER_ASSERT(reporter, SkPath::kCCW_Direction == dir); |
| 2385 dir = SkPath::kCW_Direction; | 2505 dir = SkPath::kCW_Direction; |
| 2386 } | 2506 } |
| 2387 | 2507 |
| 2388 check_for_circle(reporter, tmp, true, dir); | 2508 check_for_circle(reporter, tmp, true, dir); |
| 2389 } | 2509 } |
| 2390 | 2510 |
| 2391 static void test_circle_mirror_y(skiatest::Reporter* reporter, | 2511 static void test_circle_mirror_y(skiatest::Reporter* reporter, |
| 2392 const SkPath& path, | 2512 const SkPath& path, |
| 2393 SkPath::Direction dir) { | 2513 SkPath::Direction dir) { |
| 2394 SkPath tmp; | 2514 SkPath tmp; |
| 2395 SkMatrix m; | 2515 SkMatrix m; |
| 2396 m.reset(); | 2516 m.reset(); |
| 2397 m.setScaleY(-SK_Scalar1); | 2517 m.setScaleY(-SK_Scalar1); |
| 2398 path.transform(m, &tmp); | 2518 path.transform(m, &tmp); |
| 2399 | 2519 |
| 2400 if (SkPath::kCW_Direction == dir) { | 2520 if (SkPath::kCW_Direction == dir) { |
| 2401 dir = SkPath::kCCW_Direction; | 2521 dir = SkPath::kCCW_Direction; |
| 2402 } else { | 2522 } else { |
| 2403 SkASSERT(SkPath::kCCW_Direction == dir); | 2523 REPORTER_ASSERT(reporter, SkPath::kCCW_Direction == dir); |
| 2404 dir = SkPath::kCW_Direction; | 2524 dir = SkPath::kCW_Direction; |
| 2405 } | 2525 } |
| 2406 | 2526 |
| 2407 check_for_circle(reporter, tmp, true, dir); | 2527 check_for_circle(reporter, tmp, true, dir); |
| 2408 } | 2528 } |
| 2409 | 2529 |
| 2410 static void test_circle_mirror_xy(skiatest::Reporter* reporter, | 2530 static void test_circle_mirror_xy(skiatest::Reporter* reporter, |
| 2411 const SkPath& path, | 2531 const SkPath& path, |
| 2412 SkPath::Direction dir) { | 2532 SkPath::Direction dir) { |
| 2413 SkPath tmp; | 2533 SkPath tmp; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2566 REPORTER_ASSERT(reporter, 0 == p.countPoints()); | 2686 REPORTER_ASSERT(reporter, 0 == p.countPoints()); |
| 2567 REPORTER_ASSERT(reporter, 0 == p.countVerbs()); | 2687 REPORTER_ASSERT(reporter, 0 == p.countVerbs()); |
| 2568 REPORTER_ASSERT(reporter, 0 == p.getSegmentMasks()); | 2688 REPORTER_ASSERT(reporter, 0 == p.getSegmentMasks()); |
| 2569 REPORTER_ASSERT(reporter, p.isConvex()); | 2689 REPORTER_ASSERT(reporter, p.isConvex()); |
| 2570 REPORTER_ASSERT(reporter, p.getFillType() == SkPath::kWinding_FillType); | 2690 REPORTER_ASSERT(reporter, p.getFillType() == SkPath::kWinding_FillType); |
| 2571 REPORTER_ASSERT(reporter, !p.isInverseFillType()); | 2691 REPORTER_ASSERT(reporter, !p.isInverseFillType()); |
| 2572 REPORTER_ASSERT(reporter, p == empty); | 2692 REPORTER_ASSERT(reporter, p == empty); |
| 2573 REPORTER_ASSERT(reporter, !(p != empty)); | 2693 REPORTER_ASSERT(reporter, !(p != empty)); |
| 2574 } | 2694 } |
| 2575 | 2695 |
| 2576 static void test_rrect_is_convex(skiatest::Reporter* reporter, SkPath* path) { | 2696 static void test_rrect_is_convex(skiatest::Reporter* reporter, SkPath* path, |
| 2697 SkPath::Direction dir) { | |
| 2577 REPORTER_ASSERT(reporter, path->isConvex()); | 2698 REPORTER_ASSERT(reporter, path->isConvex()); |
| 2699 REPORTER_ASSERT(reporter, path->cheapIsDirection(dir)); | |
| 2578 path->setConvexity(SkPath::kUnknown_Convexity); | 2700 path->setConvexity(SkPath::kUnknown_Convexity); |
| 2579 REPORTER_ASSERT(reporter, path->isConvex()); | 2701 REPORTER_ASSERT(reporter, path->isConvex()); |
| 2580 path->reset(); | 2702 path->reset(); |
| 2581 } | 2703 } |
| 2582 | 2704 |
| 2583 static void test_rrect(skiatest::Reporter* reporter) { | 2705 static void test_rrect(skiatest::Reporter* reporter) { |
| 2584 SkPath p; | 2706 SkPath p; |
| 2585 SkRRect rr; | 2707 SkRRect rr; |
| 2586 SkVector radii[] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}}; | 2708 SkVector radii[] = {{1, 2}, {3, 4}, {5, 6}, {7, 8}}; |
| 2587 SkRect r = {10, 20, 30, 40}; | 2709 SkRect r = {10, 20, 30, 40}; |
| 2588 rr.setRectRadii(r, radii); | 2710 rr.setRectRadii(r, radii); |
| 2589 p.addRRect(rr); | 2711 p.addRRect(rr); |
| 2590 test_rrect_is_convex(reporter, &p); | 2712 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); |
| 2591 p.addRRect(rr, SkPath::kCCW_Direction); | 2713 p.addRRect(rr, SkPath::kCCW_Direction); |
| 2592 test_rrect_is_convex(reporter, &p); | 2714 test_rrect_is_convex(reporter, &p, SkPath::kCCW_Direction); |
| 2593 p.addRoundRect(r, &radii[0].fX); | 2715 p.addRoundRect(r, &radii[0].fX); |
| 2594 test_rrect_is_convex(reporter, &p); | 2716 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); |
| 2595 p.addRoundRect(r, &radii[0].fX, SkPath::kCCW_Direction); | 2717 p.addRoundRect(r, &radii[0].fX, SkPath::kCCW_Direction); |
| 2596 test_rrect_is_convex(reporter, &p); | 2718 test_rrect_is_convex(reporter, &p, SkPath::kCCW_Direction); |
| 2597 p.addRoundRect(r, radii[1].fX, radii[1].fY); | 2719 p.addRoundRect(r, radii[1].fX, radii[1].fY); |
| 2598 test_rrect_is_convex(reporter, &p); | 2720 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); |
| 2599 p.addRoundRect(r, radii[1].fX, radii[1].fY, SkPath::kCCW_Direction); | 2721 p.addRoundRect(r, radii[1].fX, radii[1].fY, SkPath::kCCW_Direction); |
| 2600 test_rrect_is_convex(reporter, &p); | 2722 test_rrect_is_convex(reporter, &p, SkPath::kCCW_Direction); |
| 2601 } | 2723 for (size_t i = 0; i < SK_ARRAY_COUNT(radii); ++i) { |
| 2724 SkVector save = radii[i]; | |
| 2725 radii[i].set(0, 0); | |
| 2726 rr.setRectRadii(r, radii); | |
| 2727 p.addRRect(rr); | |
| 2728 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); | |
| 2729 radii[i] = save; | |
| 2730 } | |
| 2731 p.addRoundRect(r, 0, 0); | |
| 2732 SkRect returnedRect; | |
| 2733 REPORTER_ASSERT(reporter, p.isRect(&returnedRect)); | |
| 2734 REPORTER_ASSERT(reporter, returnedRect == r); | |
| 2735 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); | |
| 2736 SkVector zeroRadii[] = {{0, 0}, {0, 0}, {0, 0}, {0, 0}}; | |
| 2737 rr.setRectRadii(r, zeroRadii); | |
| 2738 p.addRRect(rr); | |
| 2739 bool closed; | |
| 2740 SkPath::Direction dir; | |
| 2741 REPORTER_ASSERT(reporter, p.isRect(&closed, &dir)); | |
| 2742 REPORTER_ASSERT(reporter, closed); | |
| 2743 REPORTER_ASSERT(reporter, SkPath::kCW_Direction == dir); | |
| 2744 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); | |
| 2745 p.addRRect(rr, SkPath::kCW_Direction); | |
| 2746 p.addRRect(rr, SkPath::kCW_Direction); | |
| 2747 REPORTER_ASSERT(reporter, !p.isConvex()); | |
| 2748 p.reset(); | |
| 2749 p.addRRect(rr, SkPath::kCCW_Direction); | |
| 2750 p.addRRect(rr, SkPath::kCCW_Direction); | |
| 2751 REPORTER_ASSERT(reporter, !p.isConvex()); | |
| 2752 p.reset(); | |
| 2753 SkRect emptyR = {10, 20, 10, 30}; | |
| 2754 rr.setRectRadii(emptyR, radii); | |
| 2755 p.addRRect(rr); | |
| 2756 REPORTER_ASSERT(reporter, p.isEmpty()); | |
| 2757 SkRect largeR = {0, 0, SK_ScalarMax, SK_ScalarMax}; | |
| 2758 rr.setRectRadii(largeR, radii); | |
| 2759 p.addRRect(rr); | |
| 2760 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); | |
| 2761 SkRect infR = {0, 0, SK_ScalarMax, SK_ScalarInfinity}; | |
| 2762 rr.setRectRadii(infR, radii); | |
| 2763 p.addRRect(rr); | |
| 2764 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); | |
| 2765 SkRect tinyR = {0, 0, SkFloatToScalar(1e-9), SkFloatToScalar(1e-9)}; | |
| 2766 p.addRoundRect(tinyR, SkFloatToScalar(5e-11), SkFloatToScalar(5e-11)); | |
| 2767 test_rrect_is_convex(reporter, &p, SkPath::kCW_Direction); | |
| 2768 } | |
| 2769 | |
| 2770 static void test_arc(skiatest::Reporter* reporter) { | |
| 2771 SkPath p; | |
| 2772 SkRect emptyOval = {10, 20, 30, 20}; | |
| 2773 REPORTER_ASSERT(reporter, emptyOval.isEmpty()); | |
| 2774 p.addArc(emptyOval, 1, 2); | |
| 2775 REPORTER_ASSERT(reporter, p.isEmpty()); | |
| 2776 p.reset(); | |
| 2777 SkRect oval = {10, 20, 30, 40}; | |
| 2778 p.addArc(oval, 1, 0); | |
| 2779 REPORTER_ASSERT(reporter, p.isEmpty()); | |
| 2780 p.reset(); | |
| 2781 SkPath cwOval; | |
| 2782 cwOval.addOval(oval); | |
| 2783 p.addArc(oval, 1, 360); | |
| 2784 REPORTER_ASSERT(reporter, p == cwOval); | |
| 2785 p.reset(); | |
| 2786 SkPath ccwOval; | |
| 2787 ccwOval.addOval(oval, SkPath::kCCW_Direction); | |
| 2788 p.addArc(oval, 1, -360); | |
| 2789 REPORTER_ASSERT(reporter, p == ccwOval); | |
| 2790 p.reset(); | |
| 2791 p.addArc(oval, 1, 180); | |
| 2792 REPORTER_ASSERT(reporter, p.isConvex()); | |
| 2793 REPORTER_ASSERT(reporter, p.cheapIsDirection(SkPath::kCW_Direction)); | |
| 2794 p.setConvexity(SkPath::kUnknown_Convexity); | |
| 2795 REPORTER_ASSERT(reporter, p.isConvex()); | |
| 2796 } | |
| 2797 | |
| 2798 static void check_move(skiatest::Reporter* reporter, SkPath::RawIter* iter, | |
| 2799 SkScalar x0, SkScalar y0) { | |
| 2800 SkPoint pts[4]; | |
| 2801 SkPath::Verb v = iter->next(pts); | |
| 2802 REPORTER_ASSERT(reporter, v == SkPath::kMove_Verb); | |
| 2803 REPORTER_ASSERT(reporter, pts[0].fX == x0); | |
| 2804 REPORTER_ASSERT(reporter, pts[0].fY == y0); | |
| 2805 } | |
| 2806 | |
| 2807 static void check_line(skiatest::Reporter* reporter, SkPath::RawIter* iter, | |
| 2808 SkScalar x1, SkScalar y1) { | |
| 2809 SkPoint pts[4]; | |
| 2810 SkPath::Verb v = iter->next(pts); | |
| 2811 REPORTER_ASSERT(reporter, v == SkPath::kLine_Verb); | |
| 2812 REPORTER_ASSERT(reporter, pts[1].fX == x1); | |
| 2813 REPORTER_ASSERT(reporter, pts[1].fY == y1); | |
| 2814 } | |
| 2815 | |
| 2816 static void check_quad(skiatest::Reporter* reporter, SkPath::RawIter* iter, | |
| 2817 SkScalar x1, SkScalar y1, SkScalar x2, SkScalar y2) { | |
| 2818 SkPoint pts[4]; | |
| 2819 SkPath::Verb v = iter->next(pts); | |
| 2820 REPORTER_ASSERT(reporter, v == SkPath::kQuad_Verb); | |
| 2821 REPORTER_ASSERT(reporter, pts[1].fX == x1); | |
| 2822 REPORTER_ASSERT(reporter, pts[1].fY == y1); | |
| 2823 REPORTER_ASSERT(reporter, pts[2].fX == x2); | |
| 2824 REPORTER_ASSERT(reporter, pts[2].fY == y2); | |
| 2825 } | |
| 2826 | |
| 2827 static void check_done(skiatest::Reporter* reporter, SkPath* p, SkPath::RawIter* iter) { | |
| 2828 SkPoint pts[4]; | |
| 2829 SkPath::Verb v = iter->next(pts); | |
| 2830 REPORTER_ASSERT(reporter, v == SkPath::kDone_Verb); | |
| 2831 } | |
| 2832 | |
| 2833 static void check_done_and_reset(skiatest::Reporter* reporter, SkPath* p, SkPath ::RawIter* iter) { | |
| 2834 check_done(reporter, p, iter); | |
| 2835 p->reset(); | |
| 2836 } | |
| 2837 | |
| 2838 static void check_path_is_move_and_reset(skiatest::Reporter* reporter, SkPath* p , | |
| 2839 SkScalar x0, SkScalar y0) { | |
| 2840 SkPath::RawIter iter(*p); | |
| 2841 check_move(reporter, &iter, x0, y0); | |
| 2842 check_done_and_reset(reporter, p, &iter); | |
| 2843 } | |
| 2844 | |
| 2845 static void check_path_is_line_and_reset(skiatest::Reporter* reporter, SkPath* p , | |
| 2846 SkScalar x1, SkScalar y1) { | |
| 2847 SkPath::RawIter iter(*p); | |
| 2848 check_move(reporter, &iter, 0, 0); | |
| 2849 check_line(reporter, &iter, x1, y1); | |
| 2850 check_done_and_reset(reporter, p, &iter); | |
| 2851 } | |
| 2852 | |
| 2853 static void check_path_is_line(skiatest::Reporter* reporter, SkPath* p, | |
| 2854 SkScalar x1, SkScalar y1) { | |
| 2855 SkPath::RawIter iter(*p); | |
| 2856 check_move(reporter, &iter, 0, 0); | |
| 2857 check_line(reporter, &iter, x1, y1); | |
| 2858 check_done(reporter, p, &iter); | |
| 2859 } | |
| 2860 | |
| 2861 static void check_path_is_line_pair_and_reset(skiatest::Reporter* reporter, SkPa th* p, | |
| 2862 SkScalar x1, SkScalar y1, SkScalar x2, SkSca lar y2) { | |
| 2863 SkPath::RawIter iter(*p); | |
| 2864 check_move(reporter, &iter, 0, 0); | |
| 2865 check_line(reporter, &iter, x1, y1); | |
| 2866 check_line(reporter, &iter, x2, y2); | |
| 2867 check_done_and_reset(reporter, p, &iter); | |
| 2868 } | |
| 2869 | |
| 2870 static void check_path_is_quad_and_reset(skiatest::Reporter* reporter, SkPath* p , | |
| 2871 SkScalar x1, SkScalar y1, SkScalar x2, SkSca lar y2) { | |
| 2872 SkPath::RawIter iter(*p); | |
| 2873 check_move(reporter, &iter, 0, 0); | |
| 2874 check_quad(reporter, &iter, x1, y1, x2, y2); | |
| 2875 check_done_and_reset(reporter, p, &iter); | |
| 2876 } | |
| 2877 | |
| 2878 static void test_arcTo(skiatest::Reporter* reporter) { | |
| 2879 SkPath p; | |
| 2880 p.arcTo(0, 0, 1, 2, 1); | |
| 2881 check_path_is_line_and_reset(reporter, &p, 0, 0); | |
| 2882 p.arcTo(1, 2, 1, 2, 1); | |
| 2883 check_path_is_line_and_reset(reporter, &p, 1, 2); | |
| 2884 p.arcTo(1, 2, 3, 4, 0); | |
| 2885 check_path_is_line_and_reset(reporter, &p, 1, 2); | |
| 2886 p.arcTo(1, 2, 0, 0, 1); | |
| 2887 check_path_is_line_and_reset(reporter, &p, 1, 2); | |
| 2888 p.arcTo(1, 0, 1, 1, 1); | |
| 2889 SkPoint pt; | |
| 2890 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt.fX == 1 && pt.fY == 1); | |
| 2891 p.reset(); | |
| 2892 p.arcTo(1, 0, 1, -1, 1); | |
| 2893 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt.fX == 1 && pt.fY == -1); | |
| 2894 p.reset(); | |
| 2895 SkRect oval = {1, 2, 3, 4}; | |
| 2896 p.arcTo(oval, 0, 0, true); | |
| 2897 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY()); | |
| 2898 p.arcTo(oval, 0, 0, false); | |
| 2899 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY()); | |
| 2900 p.arcTo(oval, 360, 0, true); | |
| 2901 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY()); | |
| 2902 p.arcTo(oval, 360, 0, false); | |
| 2903 check_path_is_move_and_reset(reporter, &p, oval.fRight, oval.centerY()); | |
| 2904 for (float sweep = 359, delta = 0.5f; sweep != (float) (sweep + delta); ) { | |
| 2905 p.arcTo(oval, 0, SkFloatToScalar(sweep), false); | |
| 2906 REPORTER_ASSERT(reporter, p.getBounds() == oval); | |
| 2907 sweep += delta; | |
| 2908 delta /= 2; | |
| 2909 } | |
| 2910 for (float sweep = 361, delta = 0.5f; sweep != (float) (sweep - delta);) { | |
| 2911 p.arcTo(oval, 0, SkFloatToScalar(sweep), false); | |
| 2912 REPORTER_ASSERT(reporter, p.getBounds() == oval); | |
| 2913 sweep -= delta; | |
| 2914 delta /= 2; | |
| 2915 } | |
| 2916 } | |
| 2917 | |
| 2918 static void test_addPath(skiatest::Reporter* reporter) { | |
| 2919 SkPath p, q; | |
| 2920 p.lineTo(1, 2); | |
| 2921 q.moveTo(4, 4); | |
| 2922 q.lineTo(7, 8); | |
| 2923 q.conicTo(8, 7, 6, 5, SkFloatToScalar(0.5f)); | |
| 2924 q.quadTo(6, 7, 8, 6); | |
| 2925 q.cubicTo(5, 6, 7, 8, 7, 5); | |
| 2926 q.close(); | |
| 2927 p.addPath(q, -4, -4); | |
| 2928 SkRect expected = {0, 0, 4, 4}; | |
| 2929 REPORTER_ASSERT(reporter, p.getBounds() == expected); | |
| 2930 p.reset(); | |
| 2931 p.reverseAddPath(q); | |
| 2932 SkRect reverseExpected = {4, 4, 8, 8}; | |
| 2933 REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected); | |
| 2934 } | |
| 2935 | |
| 2936 static void test_conicTo_special_case(skiatest::Reporter* reporter) { | |
| 2937 SkPath p; | |
| 2938 p.conicTo(1, 2, 3, 4, -1); | |
| 2939 check_path_is_line_and_reset(reporter, &p, 3, 4); | |
| 2940 p.conicTo(1, 2, 3, 4, SK_ScalarInfinity); | |
| 2941 check_path_is_line_pair_and_reset(reporter, &p, 1, 2, 3, 4); | |
| 2942 p.conicTo(1, 2, 3, 4, 1); | |
| 2943 check_path_is_quad_and_reset(reporter, &p, 1, 2, 3, 4); | |
| 2944 } | |
| 2945 | |
| 2946 static void test_get_point(skiatest::Reporter* reporter) { | |
| 2947 SkPath p; | |
| 2948 SkPoint pt = p.getPoint(0); | |
| 2949 REPORTER_ASSERT(reporter, pt == SkPoint::Make(0, 0)); | |
| 2950 REPORTER_ASSERT(reporter, !p.getLastPt(NULL)); | |
| 2951 REPORTER_ASSERT(reporter, !p.getLastPt(&pt) && pt == SkPoint::Make(0, 0)); | |
| 2952 p.setLastPt(10, 10); | |
| 2953 pt = p.getPoint(0); | |
| 2954 REPORTER_ASSERT(reporter, pt == SkPoint::Make(10, 10)); | |
| 2955 REPORTER_ASSERT(reporter, p.getLastPt(NULL)); | |
| 2956 p.rMoveTo(10, 10); | |
| 2957 REPORTER_ASSERT(reporter, p.getLastPt(&pt) && pt == SkPoint::Make(20, 20)); | |
| 2958 } | |
| 2959 | |
| 2960 class PathTest_Private { | |
| 2961 public: | |
| 2962 static void TestPathTo(skiatest::Reporter* reporter) { | |
| 2963 SkPath p, q; | |
| 2964 p.lineTo(4, 4); | |
| 2965 p.reversePathTo(q); | |
| 2966 check_path_is_line(reporter, &p, 4, 4); | |
| 2967 q.moveTo(-4, -4); | |
| 2968 p.reversePathTo(q); | |
| 2969 check_path_is_line(reporter, &p, 4, 4); | |
| 2970 q.lineTo(7, 8); | |
| 2971 q.conicTo(8, 7, 6, 5, SkFloatToScalar(0.5f)); | |
| 2972 q.quadTo(6, 7, 8, 6); | |
| 2973 q.cubicTo(5, 6, 7, 8, 7, 5); | |
| 2974 q.close(); | |
| 2975 p.reversePathTo(q); | |
| 2976 SkRect reverseExpected = {-4, -4, 8, 8}; | |
| 2977 REPORTER_ASSERT(reporter, p.getBounds() == reverseExpected); | |
| 2978 } | |
| 2979 }; | |
| 2602 | 2980 |
| 2603 static void TestPath(skiatest::Reporter* reporter) { | 2981 static void TestPath(skiatest::Reporter* reporter) { |
| 2604 SkTSize<SkScalar>::Make(3,4); | 2982 SkTSize<SkScalar>::Make(3,4); |
| 2605 | 2983 |
| 2606 SkPath p, empty; | 2984 SkPath p, empty; |
| 2607 SkRect bounds, bounds2; | 2985 SkRect bounds, bounds2; |
| 2608 test_empty(reporter, p); | 2986 test_empty(reporter, p); |
| 2609 | 2987 |
| 2610 REPORTER_ASSERT(reporter, p.getBounds().isEmpty()); | 2988 REPORTER_ASSERT(reporter, p.getBounds().isEmpty()); |
| 2611 | 2989 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2695 test_tricky_cubic(); | 3073 test_tricky_cubic(); |
| 2696 test_clipped_cubic(); | 3074 test_clipped_cubic(); |
| 2697 test_crbug_170666(); | 3075 test_crbug_170666(); |
| 2698 test_bad_cubic_crbug229478(); | 3076 test_bad_cubic_crbug229478(); |
| 2699 test_bad_cubic_crbug234190(); | 3077 test_bad_cubic_crbug234190(); |
| 2700 test_android_specific_behavior(reporter); | 3078 test_android_specific_behavior(reporter); |
| 2701 test_gen_id(reporter); | 3079 test_gen_id(reporter); |
| 2702 test_path_close_issue1474(reporter); | 3080 test_path_close_issue1474(reporter); |
| 2703 test_path_to_region(reporter); | 3081 test_path_to_region(reporter); |
| 2704 test_rrect(reporter); | 3082 test_rrect(reporter); |
| 3083 test_arc(reporter); | |
| 3084 test_arcTo(reporter); | |
| 3085 test_addPath(reporter); | |
| 3086 test_conicTo_special_case(reporter); | |
| 3087 test_get_point(reporter); | |
| 3088 PathTest_Private::TestPathTo(reporter); | |
| 2705 } | 3089 } |
| 2706 | 3090 |
| 2707 #include "TestClassDef.h" | 3091 #include "TestClassDef.h" |
| 2708 DEFINE_TESTCLASS("Path", PathTestClass, TestPath) | 3092 DEFINE_TESTCLASS("Path", PathTestClass, TestPath) |
| OLD | NEW |