From 506db0b7d2905c6bedba9fc5d4aeaf231a9a34ea Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Tue, 8 Apr 2014 23:31:35 +0000 Subject: SkRecord: make culling work if SkRecordAnnotateCullingPairs is called. - Allow stateful functors; allow visit()/mutate() at a given index; add count(). - Annotate cull push/pop pairs on the PushCull records. (tested) - Use those annotations to skip ahead in SkRecordDraw. (not yet tested beyond dm --skr) - Make SkRecordDraw a function, move its implementation to a .cpp. BUG=skia:2378 R=fmalita@chromium.org, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/229523002 git-svn-id: http://skia.googlecode.com/svn/trunk@14101 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tests/RecorderTest.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'tests/RecorderTest.cpp') diff --git a/tests/RecorderTest.cpp b/tests/RecorderTest.cpp index 4f8e357533..3c7b0082b1 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 void operator()(const T&) { - ++fHistogram[T::kType]; - } + template + void operator()(const T&) { ++fHistogram[T::kType]; } + + template + 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()); } -- cgit v1.2.3