skia2/tests/RecordCullingTest.cpp
commit-bot@chromium.org ad8ce572f6 anticipate more optimizations by renaming some files and methods
also, call the new SkRecordOptimize in bench_playback

BUG=skia:2378
R=fmalita@chromium.org, mtklein@google.com

Author: mtklein@chromium.org

Review URL: https://codereview.chromium.org/243243003

git-svn-id: http://skia.googlecode.com/svn/trunk@14277 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-21 15:03:36 +00:00

49 lines
1.3 KiB
C++

/*
* 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]);
}