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

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: 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
« src/record/SkRecorder.cpp ('K') | « 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 e04a9e9f6033d1919411cca3d0f5f5f93085de46..8ce9f7b748aaaa02008f42f0ac0115c1442d1b79 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() { bzero(&fHistogram, sizeof(fHistogram)); }
f(malita) 2014/04/08 23:08:31 sk_bzero?
mtklein 2014/04/08 23:11:56 ooooops, done.
- 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];
- 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>());
}
« src/record/SkRecorder.cpp ('K') | « tests/RecordTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698