OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
4 * | 3 * |
5 * 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 |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
| 7 |
8 #include "Test.h" | 8 #include "Test.h" |
9 | 9 #include "TestClassDef.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkPaint.h" | 11 #include "SkPaint.h" |
12 #include "SkCubicClipper.h" | 12 #include "SkCubicClipper.h" |
13 #include "SkGeometry.h" | 13 #include "SkGeometry.h" |
14 | 14 |
15 // Currently the supersampler blitter uses int16_t for its index into an array | 15 // Currently the supersampler blitter uses int16_t for its index into an array |
16 // the width of the clip. Test that we don't crash/assert if we try to draw | 16 // the width of the clip. Test that we don't crash/assert if we try to draw |
17 // with a device/clip that is larger. | 17 // with a device/clip that is larger. |
18 static void test_giantClip() { | 18 static void test_giantClip() { |
19 SkBitmap bm; | 19 SkBitmap bm; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 float x3, float y3, | 62 float x3, float y3, |
63 SkPoint crv[4]) { | 63 SkPoint crv[4]) { |
64 crv[0].fX = x0; crv[0].fY = y0; | 64 crv[0].fX = x0; crv[0].fY = y0; |
65 crv[1].fX = x1; crv[1].fY = y1; | 65 crv[1].fX = x1; crv[1].fY = y1; |
66 crv[2].fX = x2; crv[2].fY = y2; | 66 crv[2].fX = x2; crv[2].fY = y2; |
67 crv[3].fX = x3; crv[3].fY = y3; | 67 crv[3].fX = x3; crv[3].fY = y3; |
68 return crv; | 68 return crv; |
69 } | 69 } |
70 | 70 |
71 | 71 |
72 static void TestCubicClipping(skiatest::Reporter* reporter) { | 72 DEF_TEST(ClipCubic, reporter) { |
73 static SkPoint crv[4] = { | 73 static SkPoint crv[4] = { |
74 { SkIntToScalar(0), SkIntToScalar(0) }, | 74 { SkIntToScalar(0), SkIntToScalar(0) }, |
75 { SkIntToScalar(2), SkIntToScalar(3) }, | 75 { SkIntToScalar(2), SkIntToScalar(3) }, |
76 { SkIntToScalar(1), SkIntToScalar(10) }, | 76 { SkIntToScalar(1), SkIntToScalar(10) }, |
77 { SkIntToScalar(4), SkIntToScalar(12) } | 77 { SkIntToScalar(4), SkIntToScalar(12) } |
78 }; | 78 }; |
79 | 79 |
80 SkCubicClipper clipper; | 80 SkCubicClipper clipper; |
81 SkPoint clipped[4], shouldbe[4]; | 81 SkPoint clipped[4], shouldbe[4]; |
82 SkIRect clipRect; | 82 SkIRect clipRect; |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 REPORTER_ASSERT(reporter, success == true); | 156 REPORTER_ASSERT(reporter, success == true); |
157 REPORTER_ASSERT(reporter, CurvesAreEqual(clipped, SetCurve( | 157 REPORTER_ASSERT(reporter, CurvesAreEqual(clipped, SetCurve( |
158 0, 0, | 158 0, 0, |
159 1.551193237f, 2.326789856f, | 159 1.551193237f, 2.326789856f, |
160 1.297736168f, 7.059780121f, | 160 1.297736168f, 7.059780121f, |
161 2.505550385f, 10, | 161 2.505550385f, 10, |
162 shouldbe), tol)); | 162 shouldbe), tol)); |
163 | 163 |
164 test_giantClip(); | 164 test_giantClip(); |
165 } | 165 } |
166 | |
167 | |
168 | |
169 | |
170 #include "TestClassDef.h" | |
171 DEFINE_TESTCLASS("CubicClipper", CubicClippingTestClass, TestCubicClipping) | |
OLD | NEW |