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 1429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 } | 1440 } |
1441 REPORTER_ASSERT(r, analyzer.suitableForGpuRasterization()); | 1441 REPORTER_ASSERT(r, analyzer.suitableForGpuRasterization()); |
1442 | 1442 |
1443 for (int i = 0; i < 50; ++i) { | 1443 for (int i = 0; i < 50; ++i) { |
1444 analyzer.analyzeClipPath(concaveClip, SkRegion::kIntersect_Op, true); | 1444 analyzer.analyzeClipPath(concaveClip, SkRegion::kIntersect_Op, true); |
1445 } | 1445 } |
1446 REPORTER_ASSERT(r, !analyzer.suitableForGpuRasterization()); | 1446 REPORTER_ASSERT(r, !analyzer.suitableForGpuRasterization()); |
1447 } | 1447 } |
1448 | 1448 |
1449 #endif // SK_SUPPORT_GPU | 1449 #endif // SK_SUPPORT_GPU |
| 1450 |
| 1451 ////////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 1452 |
| 1453 static void empty_ops(SkCanvas* canvas) { |
| 1454 } |
| 1455 static void clip_ops(SkCanvas* canvas) { |
| 1456 canvas->save(); |
| 1457 canvas->clipRect(SkRect::MakeWH(20, 20)); |
| 1458 canvas->restore(); |
| 1459 } |
| 1460 static void matrix_ops(SkCanvas* canvas) { |
| 1461 canvas->save(); |
| 1462 canvas->scale(2, 3); |
| 1463 canvas->restore(); |
| 1464 } |
| 1465 static void matrixclip_ops(SkCanvas* canvas) { |
| 1466 canvas->save(); |
| 1467 canvas->scale(2, 3); |
| 1468 canvas->clipRect(SkRect::MakeWH(20, 20)); |
| 1469 canvas->restore(); |
| 1470 } |
| 1471 typedef void (*CanvasProc)(SkCanvas*); |
| 1472 |
| 1473 // Test the kReturnNullForEmpty_FinishFlag option when recording |
| 1474 // |
| 1475 DEF_TEST(Picture_RecordEmpty, r) { |
| 1476 const SkRect cull = SkRect::MakeWH(100, 100); |
| 1477 |
| 1478 CanvasProc procs[] { empty_ops, clip_ops, matrix_ops, matrixclip_ops }; |
| 1479 |
| 1480 for (auto proc : procs) { |
| 1481 { |
| 1482 SkPictureRecorder rec; |
| 1483 proc(rec.beginRecording(cull)); |
| 1484 sk_sp<SkPicture> pic = rec.finishRecordingAsPicture(0); |
| 1485 REPORTER_ASSERT(r, pic.get()); |
| 1486 REPORTER_ASSERT(r, pic->approximateOpCount() == 0); |
| 1487 } |
| 1488 { |
| 1489 SkPictureRecorder rec; |
| 1490 proc(rec.beginRecording(cull)); |
| 1491 sk_sp<SkPicture> pic = rec.finishRecordingAsPicture( |
| 1492 SkPictureRecorder::kReturnNullF
orEmpty_FinishFlag); |
| 1493 REPORTER_ASSERT(r, !pic.get()); |
| 1494 } |
| 1495 { |
| 1496 SkPictureRecorder rec; |
| 1497 proc(rec.beginRecording(cull)); |
| 1498 sk_sp<SkDrawable> dr = rec.finishRecordingAsDrawable(0); |
| 1499 REPORTER_ASSERT(r, dr.get()); |
| 1500 } |
| 1501 { |
| 1502 SkPictureRecorder rec; |
| 1503 proc(rec.beginRecording(cull)); |
| 1504 sk_sp<SkDrawable> dr = rec.finishRecordingAsDrawable( |
| 1505 SkPictureRecorder::kReturnNullF
orEmpty_FinishFlag); |
| 1506 REPORTER_ASSERT(r, !dr.get()); |
| 1507 } |
| 1508 } |
| 1509 } |
OLD | NEW |