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

Unified Diff: tests/RecorderTest.cpp

Issue 229523002: SkRecord: make culling work if SkRecordAnnotateCullingPairs is called. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/RecordTest.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RecorderTest.cpp
diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp
index 4f8e357533c5a5614794b4dddba4760e5bca9efa..3c7b0082b1a71475a48edad368807606da3e1f9b 100644
--- a/tests/RecorderTest.cpp
+++ b/tests/RecorderTest.cpp
@@ -8,17 +8,19 @@
static const int kRecordTypes = SK_RECORD_TYPES(COUNT);
#undef COUNT
-// Tallies the types of commands it sees into histogram.
+// Tallies the types of commands it sees into a histogram.
class Tally {
public:
- explicit Tally(int histogram[kRecordTypes]) : fHistogram(histogram) {}
+ Tally() { sk_bzero(&fHistogram, sizeof(fHistogram)); }
- template <typename T> void operator()(const T&) {
- ++fHistogram[T::kType];
- }
+ template <typename T>
+ void operator()(const T&) { ++fHistogram[T::kType]; }
+
+ template <typename T>
+ int count() const { return fHistogram[T::kType]; }
private:
- int* fHistogram;
+ int fHistogram[kRecordTypes];
};
DEF_TEST(Recorder, r) {
@@ -27,10 +29,8 @@ DEF_TEST(Recorder, r) {
recorder.drawRect(SkRect::MakeWH(10, 10), SkPaint());
- int histogram[kRecordTypes];
- sk_bzero(&histogram, sizeof(histogram));
-
- record.visit(Tally(histogram));
+ Tally tally;
+ record.visit(tally);
- REPORTER_ASSERT(r, 1 == histogram[SkRecords::DrawRect::kType]);
+ REPORTER_ASSERT(r, 1 == tally.count<SkRecords::DrawRect>());
}
« no previous file with comments | « tests/RecordTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698