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

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: notes 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
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 SkTDArray<unsigned> fSkips;
19 }; 19 };
20 20
21 template <> void PushCullScanner::operator()(const SkRecords::PushCull& record) { 21 template <> void SkipScanner::operator()(const SkRecords::PairedPushCull& r) {
22 *fPopOffsets.append() = record.popOffset; 22 *fSkips.append() = r.skip;
23 } 23 }
24 24
25 25
26 DEF_TEST(RecordCulling, r) { 26 DEF_TEST(RecordCulling, r) {
27 SkRecord record; 27 SkRecord record;
28 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1080); 28 SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1080);
29 29
30 recorder.drawRect(SkRect::MakeWH(1000, 10000), SkPaint()); 30 recorder.drawRect(SkRect::MakeWH(1000, 10000), SkPaint());
31 31
32 recorder.pushCull(SkRect::MakeWH(100, 100)); 32 recorder.pushCull(SkRect::MakeWH(100, 100));
33 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint()); 33 recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint());
34 recorder.drawRect(SkRect::MakeWH(30, 30), SkPaint()); 34 recorder.drawRect(SkRect::MakeWH(30, 30), SkPaint());
35 recorder.pushCull(SkRect::MakeWH(5, 5)); 35 recorder.pushCull(SkRect::MakeWH(5, 5));
36 recorder.drawRect(SkRect::MakeWH(1, 1), SkPaint()); 36 recorder.drawRect(SkRect::MakeWH(1, 1), SkPaint());
37 recorder.popCull(); 37 recorder.popCull();
38 recorder.popCull(); 38 recorder.popCull();
39 39
40 SkRecordAnnotateCullingPairs(&record); 40 SkRecordAnnotateCullingPairs(&record);
41 41
42 PushCullScanner scan; 42 SkipScanner scan;
43 record.visit(scan); 43 for (unsigned i = 0; i < record.count(); i++) {
44 record.visit(i, scan);
45 }
44 46
45 REPORTER_ASSERT(r, 2 == scan.fPopOffsets.count()); 47 REPORTER_ASSERT(r, 2 == scan.fSkips.count());
46 REPORTER_ASSERT(r, 6 == scan.fPopOffsets[0]); 48 REPORTER_ASSERT(r, 6 == scan.fSkips[0]);
47 REPORTER_ASSERT(r, 2 == scan.fPopOffsets[1]); 49 REPORTER_ASSERT(r, 2 == scan.fSkips[1]);
48 } 50 }
OLDNEW
« no previous file with comments | « src/record/SkRecords.h ('k') | tests/RecordTest.cpp » ('j') | tests/RecordTest.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698