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

Side by Side Diff: tests/RecordCullingTest.cpp

Issue 251133008: Backfill unit tests for SkRecord (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 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
(Empty)
1 /*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "Test.h"
9
10 #include "SkRecord.h"
11 #include "SkRecordOpts.h"
12 #include "SkRecorder.h"
13 #include "SkRecords.h"
14
15 struct SkipScanner {
16 template <typename T> void operator()(const T&) {}
17
18 void apply(const SkRecord& record) {
19 for (unsigned i = 0; i < record.count(); i++) {
20 record.visit(i, *this);
21 }
22 }
23
24 SkTDArray<unsigned> fSkips;
25 };
26
27 template <> void SkipScanner::operator()(const SkRecords::PairedPushCull& r) {
28 *fSkips.append() = r.skip;
29 }
30
31
32 DEF_TEST(RecordCulling, r) {
33 SkRecord record;
34 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1080);
35
36 recorder.drawRect(SkRect::MakeWH(1000, 10000), SkPaint());
37
38 recorder.pushCull(SkRect::MakeWH(100, 100));
39 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint());
40 recorder.drawRect(SkRect::MakeWH(30, 30), SkPaint());
41 recorder.pushCull(SkRect::MakeWH(5, 5));
42 recorder.drawRect(SkRect::MakeWH(1, 1), SkPaint());
43 recorder.popCull();
44 recorder.popCull();
45
46 SkRecordAnnotateCullingPairs(&record);
47
48 SkipScanner scan;
49 scan.apply(record);
50
51 REPORTER_ASSERT(r, 2 == scan.fSkips.count());
52 REPORTER_ASSERT(r, 6 == scan.fSkips[0]);
53 REPORTER_ASSERT(r, 2 == scan.fSkips[1]);
54 }
OLDNEW
« no previous file with comments | « src/record/SkRecordOpts.h ('k') | tests/RecordDrawTest.cpp » ('j') | tests/RecordOptsTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698