Chromium Code Reviews| 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 DEF_TEST(Picture_RecordEmpty, r) { | |
| 1474 const SkRect cull = SkRect::MakeWH(100, 100); | |
| 1475 | |
| 1476 CanvasProc procs[] { empty_ops, clip_ops, matrix_ops, matrixclip_ops }; | |
| 1477 | |
| 1478 for (auto proc : procs) { | |
| 1479 { | |
| 1480 SkPictureRecorder rec; | |
| 1481 proc(rec.beginRecording(cull)); | |
| 1482 sk_sp<SkPicture> pic = rec.finishRecordingAsPicture(0); | |
| 1483 REPORTER_ASSERT(r, pic.get()); | |
|
mtklein
2016/06/29 19:44:19
We should also be able to assert pic->approximateO
reed1
2016/07/06 13:55:09
Done.
| |
| 1484 } | |
| 1485 { | |
| 1486 SkPictureRecorder rec; | |
| 1487 proc(rec.beginRecording(cull)); | |
| 1488 sk_sp<SkPicture> pic = rec.finishRecordingAsPicture( | |
| 1489 SkPictureRecorder::kReturnNullF orEmpty_FinishFlag); | |
| 1490 REPORTER_ASSERT(r, !pic.get()); | |
| 1491 } | |
| 1492 { | |
| 1493 SkPictureRecorder rec; | |
| 1494 proc(rec.beginRecording(cull)); | |
| 1495 sk_sp<SkDrawable> dr = rec.finishRecordingAsDrawable(0); | |
| 1496 REPORTER_ASSERT(r, dr.get()); | |
| 1497 } | |
| 1498 { | |
| 1499 SkPictureRecorder rec; | |
| 1500 proc(rec.beginRecording(cull)); | |
| 1501 sk_sp<SkDrawable> dr = rec.finishRecordingAsDrawable( | |
| 1502 SkPictureRecorder::kReturnNullF orEmpty_FinishFlag); | |
| 1503 REPORTER_ASSERT(r, !dr.get()); | |
| 1504 } | |
| 1505 } | |
| 1506 } | |
| OLD | NEW |