OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrTestUtils.h" | 8 #include "GrTestUtils.h" |
9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
| 10 #include "SkPath.h" |
10 #include "SkRRect.h" | 11 #include "SkRRect.h" |
11 | 12 |
12 #ifdef GR_TEST_UTILS | 13 #ifdef GR_TEST_UTILS |
13 | 14 |
14 namespace GrTest { | 15 namespace GrTest { |
15 const SkMatrix& TestMatrix(SkRandom* random) { | 16 const SkMatrix& TestMatrix(SkRandom* random) { |
16 static SkMatrix gMatrices[5]; | 17 static SkMatrix gMatrices[5]; |
17 static bool gOnce; | 18 static bool gOnce; |
18 if (!gOnce) { | 19 if (!gOnce) { |
19 gOnce = true; | 20 gOnce = true; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // true round rect with elliptical corners | 114 // true round rect with elliptical corners |
114 gRRect[3].setRectXY(rectangle, 2.0f, 1.0f); | 115 gRRect[3].setRectXY(rectangle, 2.0f, 1.0f); |
115 | 116 |
116 for (size_t i = 0; i < SK_ARRAY_COUNT(gRRect); i++) { | 117 for (size_t i = 0; i < SK_ARRAY_COUNT(gRRect); i++) { |
117 SkASSERT(gRRect[i].isSimple()); | 118 SkASSERT(gRRect[i].isSimple()); |
118 } | 119 } |
119 } | 120 } |
120 return gRRect[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gRR
ect)))]; | 121 return gRRect[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gRR
ect)))]; |
121 } | 122 } |
122 | 123 |
| 124 const SkPath& TestPath(SkRandom* random) { |
| 125 static SkPath gPath[7]; |
| 126 static bool gOnce; |
| 127 if (!gOnce) { |
| 128 gOnce = true; |
| 129 // line |
| 130 gPath[0].moveTo(0.f, 0.f); |
| 131 gPath[0].lineTo(10.f, 10.f); |
| 132 // quad |
| 133 gPath[1].moveTo(0.f, 0.f); |
| 134 gPath[1].quadTo(10.f, 10.f, 20.f, 20.f); |
| 135 // conic |
| 136 gPath[2].moveTo(0.f, 0.f); |
| 137 gPath[2].conicTo(10.f, 10.f, 20.f, 20.f, 1.f); |
| 138 // cubic |
| 139 gPath[3].moveTo(0.f, 0.f); |
| 140 gPath[3].cubicTo(10.f, 10.f, 20.f, 20.f, 30.f, 30.f); |
| 141 // all three |
| 142 gPath[4].moveTo(0.f, 0.f); |
| 143 gPath[4].lineTo(10.f, 10.f); |
| 144 gPath[4].quadTo(10.f, 10.f, 20.f, 20.f); |
| 145 gPath[4].conicTo(10.f, 10.f, 20.f, 20.f, 1.f); |
| 146 gPath[4].cubicTo(10.f, 10.f, 20.f, 20.f, 30.f, 30.f); |
| 147 // convex |
| 148 gPath[5].moveTo(0.0f, 0.0f); |
| 149 gPath[5].lineTo(10.0f, 0.0f); |
| 150 gPath[5].lineTo(10.0f, 10.0f); |
| 151 gPath[5].lineTo(0.0f, 10.0f); |
| 152 gPath[5].close(); |
| 153 // concave |
| 154 gPath[6].moveTo(0.0f, 0.0f); |
| 155 gPath[6].lineTo(5.0f, 5.0f); |
| 156 gPath[6].lineTo(10.0f, 0.0f); |
| 157 gPath[6].lineTo(10.0f, 10.0f); |
| 158 gPath[6].lineTo(0.0f, 10.0f); |
| 159 gPath[6].close(); |
| 160 } |
| 161 |
| 162 return gPath[random->nextULessThan(static_cast<uint32_t>(SK_ARRAY_COUNT(gPat
h)))]; |
| 163 } |
| 164 |
123 }; | 165 }; |
124 | 166 |
125 #endif | 167 #endif |
OLD | NEW |