OLD | NEW |
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 "SkPictureRecorder.h" | 10 #include "SkPictureRecorder.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 Tally() { sk_bzero(&fHistogram, sizeof(fHistogram)); } | 24 Tally() { sk_bzero(&fHistogram, sizeof(fHistogram)); } |
25 | 25 |
26 template <typename T> | 26 template <typename T> |
27 void operator()(const T&) { ++fHistogram[T::kType]; } | 27 void operator()(const T&) { ++fHistogram[T::kType]; } |
28 | 28 |
29 template <typename T> | 29 template <typename T> |
30 int count() const { return fHistogram[T::kType]; } | 30 int count() const { return fHistogram[T::kType]; } |
31 | 31 |
32 void apply(const SkRecord& record) { | 32 void apply(const SkRecord& record) { |
33 for (int i = 0; i < record.count(); i++) { | 33 for (int i = 0; i < record.count(); i++) { |
34 record.visit<void>(i, *this); | 34 record.visit(i, *this); |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
38 private: | 38 private: |
39 int fHistogram[kRecordTypes]; | 39 int fHistogram[kRecordTypes]; |
40 }; | 40 }; |
41 | 41 |
42 DEF_TEST(Recorder, r) { | 42 DEF_TEST(Recorder, r) { |
43 SkRecord record; | 43 SkRecord record; |
44 SkRecorder recorder(&record, 1920, 1080); | 44 SkRecorder recorder(&record, 1920, 1080); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 recorder.drawImageRect(image, SkRect::MakeWH(100, 100), nullptr); | 101 recorder.drawImageRect(image, SkRect::MakeWH(100, 100), nullptr); |
102 REPORTER_ASSERT(reporter, !image->unique()); | 102 REPORTER_ASSERT(reporter, !image->unique()); |
103 | 103 |
104 Tally tally; | 104 Tally tally; |
105 tally.apply(record); | 105 tally.apply(record); |
106 | 106 |
107 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>()); | 107 REPORTER_ASSERT(reporter, 1 == tally.count<SkRecords::DrawImageRect>()); |
108 } | 108 } |
109 REPORTER_ASSERT(reporter, image->unique()); | 109 REPORTER_ASSERT(reporter, image->unique()); |
110 } | 110 } |
OLD | NEW |