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 "SkBBoxHierarchy.h" | 8 #include "SkBBoxHierarchy.h" |
9 #include "SkBlurImageFilter.h" | 9 #include "SkBlurImageFilter.h" |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // SkDebugf("clip\n"); | 128 // SkDebugf("clip\n"); |
129 canvas->clipRect(rect); | 129 canvas->clipRect(rect); |
130 } else { | 130 } else { |
131 // SkDebugf("draw\n"); | 131 // SkDebugf("draw\n"); |
132 canvas->drawPaint(paint); | 132 canvas->drawPaint(paint); |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 #if SK_SUPPORT_GPU | 136 #if SK_SUPPORT_GPU |
137 | 137 |
| 138 static SkPath make_convex_path() { |
| 139 SkPath path; |
| 140 path.lineTo(100, 0); |
| 141 path.lineTo(50, 100); |
| 142 path.close(); |
| 143 |
| 144 return path; |
| 145 } |
| 146 |
| 147 static SkPath make_concave_path() { |
| 148 SkPath path; |
| 149 path.lineTo(50, 50); |
| 150 path.lineTo(100, 0); |
| 151 path.lineTo(50, 100); |
| 152 path.close(); |
| 153 |
| 154 return path; |
| 155 } |
| 156 |
138 static void test_gpu_veto(skiatest::Reporter* reporter) { | 157 static void test_gpu_veto(skiatest::Reporter* reporter) { |
139 SkPictureRecorder recorder; | 158 SkPictureRecorder recorder; |
140 | 159 |
141 SkCanvas* canvas = recorder.beginRecording(100, 100); | 160 SkCanvas* canvas = recorder.beginRecording(100, 100); |
142 { | 161 { |
143 SkPath path; | 162 SkPath path; |
144 path.moveTo(0, 0); | 163 path.moveTo(0, 0); |
145 path.lineTo(50, 50); | 164 path.lineTo(50, 50); |
146 | 165 |
147 SkScalar intervals[] = { 1.0f, 1.0f }; | 166 SkScalar intervals[] = { 1.0f, 1.0f }; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 25)); | 273 paint.setPathEffect(SkDashPathEffect::Make(intervals, 2, 25)); |
255 | 274 |
256 for (int i = 0; i < 50; ++i) { | 275 for (int i = 0; i < 50; ++i) { |
257 canvas->drawRect(SkRect::MakeWH(10, 10), paint); | 276 canvas->drawRect(SkRect::MakeWH(10, 10), paint); |
258 } | 277 } |
259 } | 278 } |
260 picture = recorder.finishRecordingAsPicture(); | 279 picture = recorder.finishRecordingAsPicture(); |
261 // ... but only when applied to drawPoint() calls | 280 // ... but only when applied to drawPoint() calls |
262 REPORTER_ASSERT(reporter, !SkPictureGpuAnalyzer(picture).suitableForGpuRaste
rization()); | 281 REPORTER_ASSERT(reporter, !SkPictureGpuAnalyzer(picture).suitableForGpuRaste
rization()); |
263 | 282 |
| 283 canvas = recorder.beginRecording(100, 100); |
| 284 { |
| 285 const SkPath convexClip = make_convex_path(); |
| 286 const SkPath concaveClip = make_concave_path(); |
| 287 |
| 288 for (int i = 0; i < 50; ++i) { |
| 289 canvas->clipPath(convexClip); |
| 290 canvas->clipPath(concaveClip); |
| 291 canvas->clipPath(convexClip, SkRegion::kIntersect_Op, true); |
| 292 canvas->drawRect(SkRect::MakeWH(100, 100), SkPaint()); |
| 293 } |
| 294 } |
| 295 picture = recorder.finishRecordingAsPicture(); |
| 296 // Convex clips and non-AA concave clips are fine on the GPU. |
| 297 REPORTER_ASSERT(reporter, SkPictureGpuAnalyzer(picture).suitableForGpuRaster
ization()); |
| 298 |
| 299 canvas = recorder.beginRecording(100, 100); |
| 300 { |
| 301 const SkPath concaveClip = make_concave_path(); |
| 302 for (int i = 0; i < 50; ++i) { |
| 303 canvas->clipPath(concaveClip, SkRegion::kIntersect_Op, true); |
| 304 canvas->drawRect(SkRect::MakeWH(100, 100), SkPaint()); |
| 305 } |
| 306 } |
| 307 picture = recorder.finishRecordingAsPicture(); |
| 308 // ... but AA concave clips are not. |
| 309 REPORTER_ASSERT(reporter, !SkPictureGpuAnalyzer(picture).suitableForGpuRaste
rization()); |
| 310 |
264 // Nest the previous picture inside a new one. | 311 // Nest the previous picture inside a new one. |
265 canvas = recorder.beginRecording(100, 100); | 312 canvas = recorder.beginRecording(100, 100); |
266 { | 313 { |
267 canvas->drawPicture(picture); | 314 canvas->drawPicture(picture); |
268 } | 315 } |
269 picture = recorder.finishRecordingAsPicture(); | 316 picture = recorder.finishRecordingAsPicture(); |
270 REPORTER_ASSERT(reporter, !SkPictureGpuAnalyzer(picture).suitableForGpuRaste
rization()); | 317 REPORTER_ASSERT(reporter, !SkPictureGpuAnalyzer(picture).suitableForGpuRaste
rization()); |
271 } | 318 } |
272 | 319 |
273 #endif // SK_SUPPORT_GPU | 320 #endif // SK_SUPPORT_GPU |
(...skipping 1099 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1373 REPORTER_ASSERT(r, !analyzer.suitableForGpuRasterization()); | 1420 REPORTER_ASSERT(r, !analyzer.suitableForGpuRasterization()); |
1374 | 1421 |
1375 analyzer.reset(); | 1422 analyzer.reset(); |
1376 REPORTER_ASSERT(r, analyzer.suitableForGpuRasterization()); | 1423 REPORTER_ASSERT(r, analyzer.suitableForGpuRasterization()); |
1377 | 1424 |
1378 recorder.beginRecording(10, 10)->drawPicture(vetoPicture); | 1425 recorder.beginRecording(10, 10)->drawPicture(vetoPicture); |
1379 sk_sp<SkPicture> nestedVetoPicture(recorder.finishRecordingAsPicture()); | 1426 sk_sp<SkPicture> nestedVetoPicture(recorder.finishRecordingAsPicture()); |
1380 | 1427 |
1381 analyzer.analyze(nestedVetoPicture.get()); | 1428 analyzer.analyze(nestedVetoPicture.get()); |
1382 REPORTER_ASSERT(r, !analyzer.suitableForGpuRasterization()); | 1429 REPORTER_ASSERT(r, !analyzer.suitableForGpuRasterization()); |
| 1430 |
| 1431 analyzer.reset(); |
| 1432 |
| 1433 const SkPath convexClip = make_convex_path(); |
| 1434 const SkPath concaveClip = make_concave_path(); |
| 1435 for (int i = 0; i < 50; ++i) { |
| 1436 analyzer.analyzeClipPath(convexClip, SkRegion::kIntersect_Op, false); |
| 1437 analyzer.analyzeClipPath(convexClip, SkRegion::kIntersect_Op, true); |
| 1438 analyzer.analyzeClipPath(concaveClip, SkRegion::kIntersect_Op, false); |
| 1439 } |
| 1440 REPORTER_ASSERT(r, analyzer.suitableForGpuRasterization()); |
| 1441 |
| 1442 for (int i = 0; i < 50; ++i) { |
| 1443 analyzer.analyzeClipPath(concaveClip, SkRegion::kIntersect_Op, true); |
| 1444 } |
| 1445 REPORTER_ASSERT(r, !analyzer.suitableForGpuRasterization()); |
1383 } | 1446 } |
1384 | 1447 |
1385 #endif // SK_SUPPORT_GPU | 1448 #endif // SK_SUPPORT_GPU |
OLD | NEW |