OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 /* Description: | 8 /* Description: |
9 * This test defines a series of elementatry test steps that perform | 9 * This test defines a series of elementatry test steps that perform |
10 * a single or a small group of canvas API calls. Each test step is | 10 * a single or a small group of canvas API calls. Each test step is |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 const SkRect kTestRect = | 189 const SkRect kTestRect = |
190 SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0), | 190 SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0), |
191 SkIntToScalar(2), SkIntToScalar(1)); | 191 SkIntToScalar(2), SkIntToScalar(1)); |
192 static SkMatrix testMatrix() { | 192 static SkMatrix testMatrix() { |
193 SkMatrix matrix; | 193 SkMatrix matrix; |
194 matrix.reset(); | 194 matrix.reset(); |
195 matrix.setScale(SkIntToScalar(2), SkIntToScalar(3)); | 195 matrix.setScale(SkIntToScalar(2), SkIntToScalar(3)); |
196 return matrix; | 196 return matrix; |
197 } | 197 } |
198 const SkMatrix kTestMatrix = testMatrix(); | 198 const SkMatrix kTestMatrix = testMatrix(); |
199 static SkPath testPath() { | 199 static SkPath test_path() { |
200 SkPath path; | 200 SkPath path; |
201 path.addRect(SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0), | 201 path.addRect(SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0), |
202 SkIntToScalar(2), SkIntToScalar(1))); | 202 SkIntToScalar(2), SkIntToScalar(1))); |
203 return path; | 203 return path; |
204 } | 204 } |
205 const SkPath kTestPath = testPath(); | 205 const SkPath kTestPath = test_path(); |
| 206 static SkPath test_nearly_zero_length_path() { |
| 207 SkPath path; |
| 208 SkPoint pt1 = { 0, 0 }; |
| 209 SkPoint pt2 = { 0, SK_ScalarNearlyZero }; |
| 210 SkPoint pt3 = { SkIntToScalar(1), 0 }; |
| 211 SkPoint pt4 = { SkIntToScalar(1), SK_ScalarNearlyZero/2 }; |
| 212 path.moveTo(pt1); |
| 213 path.lineTo(pt2); |
| 214 path.lineTo(pt3); |
| 215 path.lineTo(pt4); |
| 216 return path; |
| 217 } |
| 218 const SkPath kNearlyZeroLengthPath = test_nearly_zero_length_path(); |
206 static SkRegion testRegion() { | 219 static SkRegion testRegion() { |
207 SkRegion region; | 220 SkRegion region; |
208 SkIRect rect = SkIRect::MakeXYWH(0, 0, 2, 1); | 221 SkIRect rect = SkIRect::MakeXYWH(0, 0, 2, 1); |
209 region.setRect(rect); | 222 region.setRect(rect); |
210 return region; | 223 return region; |
211 } | 224 } |
212 const SkIRect kTestIRect = SkIRect::MakeXYWH(0, 0, 2, 1); | 225 const SkIRect kTestIRect = SkIRect::MakeXYWH(0, 0, 2, 1); |
213 const SkRegion kTestRegion = testRegion(); | 226 const SkRegion kTestRegion = testRegion(); |
214 const SkColor kTestColor = 0x01020304; | 227 const SkColor kTestColor = 0x01020304; |
215 const SkPaint kTestPaint; | 228 const SkPaint kTestPaint; |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 | 455 |
443 // exercise fix for http://code.google.com/p/skia/issues/detail?id=560 | 456 // exercise fix for http://code.google.com/p/skia/issues/detail?id=560 |
444 // ('SkPathStroker::lineTo() fails for line with length SK_ScalarNearlyZero') | 457 // ('SkPathStroker::lineTo() fails for line with length SK_ScalarNearlyZero') |
445 static void DrawNearlyZeroLengthPathTestStep(SkCanvas* canvas, | 458 static void DrawNearlyZeroLengthPathTestStep(SkCanvas* canvas, |
446 skiatest::Reporter*, | 459 skiatest::Reporter*, |
447 CanvasTestStep*) { | 460 CanvasTestStep*) { |
448 SkPaint paint; | 461 SkPaint paint; |
449 paint.setStrokeWidth(SkIntToScalar(1)); | 462 paint.setStrokeWidth(SkIntToScalar(1)); |
450 paint.setStyle(SkPaint::kStroke_Style); | 463 paint.setStyle(SkPaint::kStroke_Style); |
451 | 464 |
452 SkPath path; | 465 canvas->drawPath(kNearlyZeroLengthPath, paint); |
453 SkPoint pt1 = { 0, 0 }; | |
454 SkPoint pt2 = { 0, SK_ScalarNearlyZero }; | |
455 SkPoint pt3 = { SkIntToScalar(1), 0 }; | |
456 SkPoint pt4 = { SkIntToScalar(1), SK_ScalarNearlyZero/2 }; | |
457 path.moveTo(pt1); | |
458 path.lineTo(pt2); | |
459 path.lineTo(pt3); | |
460 path.lineTo(pt4); | |
461 | |
462 canvas->drawPath(path, paint); | |
463 } | 466 } |
464 TEST_STEP(DrawNearlyZeroLengthPath, DrawNearlyZeroLengthPathTestStep); | 467 TEST_STEP(DrawNearlyZeroLengthPath, DrawNearlyZeroLengthPathTestStep); |
465 | 468 |
466 static void DrawVerticesShaderTestStep(SkCanvas* canvas, | 469 static void DrawVerticesShaderTestStep(SkCanvas* canvas, |
467 skiatest::Reporter*, | 470 skiatest::Reporter*, |
468 CanvasTestStep*) { | 471 CanvasTestStep*) { |
469 SkPoint pts[4]; | 472 SkPoint pts[4]; |
470 pts[0].set(0, 0); | 473 pts[0].set(0, 0); |
471 pts[1].set(SkIntToScalar(kWidth), 0); | 474 pts[1].set(SkIntToScalar(kWidth), 0); |
472 pts[2].set(SkIntToScalar(kWidth), SkIntToScalar(kHeight)); | 475 pts[2].set(SkIntToScalar(kWidth), SkIntToScalar(kHeight)); |
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 if (testStepArray()[testStep]->enablePdfTesting()) { | 946 if (testStepArray()[testStep]->enablePdfTesting()) { |
944 TestPdfDevice(reporter, testStepArray()[testStep]); | 947 TestPdfDevice(reporter, testStepArray()[testStep]); |
945 } | 948 } |
946 } | 949 } |
947 | 950 |
948 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i
s a global) | 951 // Explicitly call reset(), so we don't leak the pixels (since kTestBitmap i
s a global) |
949 kTestBitmap.reset(); | 952 kTestBitmap.reset(); |
950 | 953 |
951 test_newraster(reporter); | 954 test_newraster(reporter); |
952 } | 955 } |
OLD | NEW |