1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/*
* Copyright 2014 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "Test.h"
#include "SkRecord.h"
#include "SkRecordOpts.h"
#include "SkRecorder.h"
#include "SkRecords.h"
struct PushCullScanner {
template <typename T> void operator()(const T&) {}
SkTDArray<unsigned> fPopOffsets;
};
template <> void PushCullScanner::operator()(const SkRecords::PushCull& record) {
*fPopOffsets.append() = record.popOffset;
}
DEF_TEST(RecordCulling, r) {
SkRecord record;
SkRecorder recorder(SkRecorder::kWriteOnly_Mode, &record, 1920, 1080);
recorder.drawRect(SkRect::MakeWH(1000, 10000), SkPaint());
recorder.pushCull(SkRect::MakeWH(100, 100));
recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint());
recorder.drawRect(SkRect::MakeWH(30, 30), SkPaint());
recorder.pushCull(SkRect::MakeWH(5, 5));
recorder.drawRect(SkRect::MakeWH(1, 1), SkPaint());
recorder.popCull();
recorder.popCull();
SkRecordAnnotateCullingPairs(&record);
PushCullScanner scan;
record.visit(scan);
REPORTER_ASSERT(r, 2 == scan.fPopOffsets.count());
REPORTER_ASSERT(r, 6 == scan.fPopOffsets[0]);
REPORTER_ASSERT(r, 2 == scan.fPopOffsets[1]);
}
|