Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: tests/PictureTest.cpp

Issue 2106843004: Experiment: add flag for finish-recording to return null (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix test Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698