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 #include "Test.h" | 8 #include "Test.h" |
9 #include "TestClassDef.h" | 9 #include "TestClassDef.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 canvas.get()->clipRect(SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(19), | 174 canvas.get()->clipRect(SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(19), |
175 SkIntToScalar(19), SkIntToScalar(11)
)); | 175 SkIntToScalar(19), SkIntToScalar(11)
)); |
176 | 176 |
177 paint.setAntiAlias(false); | 177 paint.setAntiAlias(false); |
178 canvas.get()->drawPath(path, paint); | 178 canvas.get()->drawPath(path, paint); |
179 paint.setAntiAlias(true); | 179 paint.setAntiAlias(true); |
180 canvas.get()->drawPath(path, paint); | 180 canvas.get()->drawPath(path, paint); |
181 } | 181 } |
182 | 182 |
183 static void test_bug533() { | 183 static void test_bug533() { |
184 #ifdef SK_SCALAR_IS_FLOAT | |
185 /* | 184 /* |
186 http://code.google.com/p/skia/issues/detail?id=533 | 185 http://code.google.com/p/skia/issues/detail?id=533 |
187 This particular test/bug only applies to the float case, where the | 186 This particular test/bug only applies to the float case, where the |
188 coordinates are very large. | 187 coordinates are very large. |
189 */ | 188 */ |
190 SkPath path; | 189 SkPath path; |
191 path.moveTo(64, 3); | 190 path.moveTo(64, 3); |
192 path.quadTo(-329936, -100000000, 1153, 330003); | 191 path.quadTo(-329936, -100000000, 1153, 330003); |
193 | 192 |
194 SkPaint paint; | 193 SkPaint paint; |
195 paint.setAntiAlias(true); | 194 paint.setAntiAlias(true); |
196 | 195 |
197 SkAutoTUnref<SkCanvas> canvas(new_canvas(640, 480)); | 196 SkAutoTUnref<SkCanvas> canvas(new_canvas(640, 480)); |
198 canvas.get()->drawPath(path, paint); | 197 canvas.get()->drawPath(path, paint); |
199 #endif | |
200 } | 198 } |
201 | 199 |
202 static void test_crbug_140642() { | 200 static void test_crbug_140642() { |
203 /* | 201 /* |
204 * We used to see this construct, and due to rounding as we accumulated | 202 * We used to see this construct, and due to rounding as we accumulated |
205 * our length, the loop where we apply the phase would run off the end of | 203 * our length, the loop where we apply the phase would run off the end of |
206 * the array, since it relied on just -= each interval value, which did not | 204 * the array, since it relied on just -= each interval value, which did not |
207 * behave as "expected". Now the code explicitly checks for walking off the | 205 * behave as "expected". Now the code explicitly checks for walking off the |
208 * end of that array. | 206 * end of that array. |
209 | 207 |
210 * A different (better) fix might be to rewrite dashing to do all of its | 208 * A different (better) fix might be to rewrite dashing to do all of its |
211 * length/phase/measure math using double, but this may need to be | 209 * length/phase/measure math using double, but this may need to be |
212 * coordinated with SkPathMeasure, to be consistent between the two. | 210 * coordinated with SkPathMeasure, to be consistent between the two. |
213 | 211 |
214 <path stroke="mintcream" stroke-dasharray="27734 35660 2157846850 247" | 212 <path stroke="mintcream" stroke-dasharray="27734 35660 2157846850 247" |
215 stroke-dashoffset="-248.135982067"> | 213 stroke-dashoffset="-248.135982067"> |
216 */ | 214 */ |
217 | 215 |
218 #ifdef SK_SCALAR_IS_FLOAT | |
219 const SkScalar vals[] = { 27734, 35660, 2157846850.0f, 247 }; | 216 const SkScalar vals[] = { 27734, 35660, 2157846850.0f, 247 }; |
220 SkDashPathEffect dontAssert(vals, 4, -248.135982067f); | 217 SkDashPathEffect dontAssert(vals, 4, -248.135982067f); |
221 #endif | |
222 } | 218 } |
223 | 219 |
224 static void test_crbug_124652() { | 220 static void test_crbug_124652() { |
225 #ifdef SK_SCALAR_IS_FLOAT | |
226 /* | 221 /* |
227 http://code.google.com/p/chromium/issues/detail?id=124652 | 222 http://code.google.com/p/chromium/issues/detail?id=124652 |
228 This particular test/bug only applies to the float case, where | 223 This particular test/bug only applies to the float case, where |
229 large values can "swamp" small ones. | 224 large values can "swamp" small ones. |
230 */ | 225 */ |
231 SkScalar intervals[2] = {837099584, 33450}; | 226 SkScalar intervals[2] = {837099584, 33450}; |
232 SkAutoTUnref<SkDashPathEffect> dash( | 227 SkAutoTUnref<SkDashPathEffect> dash( |
233 new SkDashPathEffect(intervals, 2, -10, false)); | 228 new SkDashPathEffect(intervals, 2, -10, false)); |
234 #endif | |
235 } | 229 } |
236 | 230 |
237 static void test_bigcubic() { | 231 static void test_bigcubic() { |
238 #ifdef SK_SCALAR_IS_FLOAT | |
239 SkPath path; | 232 SkPath path; |
240 path.moveTo(64, 3); | 233 path.moveTo(64, 3); |
241 path.cubicTo(-329936, -100000000, -329936, 100000000, 1153, 330003); | 234 path.cubicTo(-329936, -100000000, -329936, 100000000, 1153, 330003); |
242 | 235 |
243 SkPaint paint; | 236 SkPaint paint; |
244 paint.setAntiAlias(true); | 237 paint.setAntiAlias(true); |
245 | 238 |
246 SkAutoTUnref<SkCanvas> canvas(new_canvas(640, 480)); | 239 SkAutoTUnref<SkCanvas> canvas(new_canvas(640, 480)); |
247 canvas.get()->drawPath(path, paint); | 240 canvas.get()->drawPath(path, paint); |
248 #endif | |
249 } | 241 } |
250 | 242 |
251 // we used to assert if the bounds of the device (clip) was larger than 32K | 243 // we used to assert if the bounds of the device (clip) was larger than 32K |
252 // even when the path itself was smaller. We just draw and hope in the debug | 244 // even when the path itself was smaller. We just draw and hope in the debug |
253 // version to not assert. | 245 // version to not assert. |
254 static void test_giantaa() { | 246 static void test_giantaa() { |
255 const int W = 400; | 247 const int W = 400; |
256 const int H = 400; | 248 const int H = 400; |
257 SkAutoTUnref<SkCanvas> canvas(new_canvas(33000, 10)); | 249 SkAutoTUnref<SkCanvas> canvas(new_canvas(33000, 10)); |
258 canvas.get()->clear(SK_ColorTRANSPARENT); | 250 canvas.get()->clear(SK_ColorTRANSPARENT); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 test_crbug_124652(); | 305 test_crbug_124652(); |
314 test_crbug_140642(); | 306 test_crbug_140642(); |
315 test_crbug_140803(); | 307 test_crbug_140803(); |
316 test_inversepathwithclip(); | 308 test_inversepathwithclip(); |
317 // why? | 309 // why? |
318 if (false) test_crbug131181(); | 310 if (false) test_crbug131181(); |
319 test_infinite_dash(reporter); | 311 test_infinite_dash(reporter); |
320 test_crbug_165432(reporter); | 312 test_crbug_165432(reporter); |
321 test_big_aa_rect(reporter); | 313 test_big_aa_rect(reporter); |
322 } | 314 } |
OLD | NEW |