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

Side by Side Diff: tests/RecordCullingTest.cpp

Issue 245853002: Refactor SkRecord opts, converting playback optimizations where possible. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: apply Created 6 years, 8 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
« no previous file with comments | « src/record/SkRecords.h ('k') | tests/RecordTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 "Test.h" 8 #include "Test.h"
9 9
10 #include "SkRecord.h" 10 #include "SkRecord.h"
11 #include "SkRecordOpts.h" 11 #include "SkRecordOpts.h"
12 #include "SkRecorder.h" 12 #include "SkRecorder.h"
13 #include "SkRecords.h" 13 #include "SkRecords.h"
14 14
15 struct PushCullScanner { 15 struct SkipScanner {
16 template <typename T> void operator()(const T&) {} 16 template <typename T> void operator()(const T&) {}
17 17
18 SkTDArray<unsigned> fPopOffsets; 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;
19 }; 25 };
20 26
21 template <> void PushCullScanner::operator()(const SkRecords::PushCull& record) { 27 template <> void SkipScanner::operator()(const SkRecords::PairedPushCull& r) {
22 *fPopOffsets.append() = record.popOffset; 28 *fSkips.append() = r.skip;
23 } 29 }
24 30
25 31
26 DEF_TEST(RecordCulling, r) { 32 DEF_TEST(RecordCulling, r) {
27 SkRecord record; 33 SkRecord record;
28 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1080); 34 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1080);
29 35
30 recorder.drawRect(SkRect::MakeWH(1000, 10000), SkPaint()); 36 recorder.drawRect(SkRect::MakeWH(1000, 10000), SkPaint());
31 37
32 recorder.pushCull(SkRect::MakeWH(100, 100)); 38 recorder.pushCull(SkRect::MakeWH(100, 100));
33 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint()); 39 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint());
34 recorder.drawRect(SkRect::MakeWH(30, 30), SkPaint()); 40 recorder.drawRect(SkRect::MakeWH(30, 30), SkPaint());
35 recorder.pushCull(SkRect::MakeWH(5, 5)); 41 recorder.pushCull(SkRect::MakeWH(5, 5));
36 recorder.drawRect(SkRect::MakeWH(1, 1), SkPaint()); 42 recorder.drawRect(SkRect::MakeWH(1, 1), SkPaint());
37 recorder.popCull(); 43 recorder.popCull();
38 recorder.popCull(); 44 recorder.popCull();
39 45
40 SkRecordAnnotateCullingPairs(&record); 46 SkRecordAnnotateCullingPairs(&record);
41 47
42 PushCullScanner scan; 48 SkipScanner scan;
43 record.visit(scan); 49 scan.apply(record);
44 50
45 REPORTER_ASSERT(r, 2 == scan.fPopOffsets.count()); 51 REPORTER_ASSERT(r, 2 == scan.fSkips.count());
46 REPORTER_ASSERT(r, 6 == scan.fPopOffsets[0]); 52 REPORTER_ASSERT(r, 6 == scan.fSkips[0]);
47 REPORTER_ASSERT(r, 2 == scan.fPopOffsets[1]); 53 REPORTER_ASSERT(r, 2 == scan.fSkips[1]);
48 } 54 }
OLDNEW
« no previous file with comments | « src/record/SkRecords.h ('k') | tests/RecordTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698