aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/RecordTest.cpp
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-22 16:57:20 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-22 16:57:20 +0000
commit88c3e279ab79125e5741b0b0b3175291e2e2bbee (patch)
tree6e61077d8ad91811fdba5e43605c165412fce75e /tests/RecordTest.cpp
parente221a7f5c7874c62eceef4a2409952abd0f43ed6 (diff)
Refactor SkRecord opts, converting playback optimizations where possible.
This adds back two optimizations from SkPicture: drawPosText strength reduction to drawPosTextH, and pointless save-foo-restore blocks are noop'd away. The small-T optimization in SkRecord gets in the way of implementing replace(), so I removed it. Just to keep the API focused, I removed the methods on SkRecord that iterate over i for you; it's just as efficient to do it yourself, and all of the interesting code does its own custom iteration. BUG=skia:2378 R=fmalita@chromium.org, mtklein@google.com Author: mtklein@chromium.org Review URL: https://codereview.chromium.org/245853002 git-svn-id: http://skia.googlecode.com/svn/trunk@14300 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/RecordTest.cpp')
-rw-r--r--tests/RecordTest.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/tests/RecordTest.cpp b/tests/RecordTest.cpp
index 315f15b700..e58ef10dda 100644
--- a/tests/RecordTest.cpp
+++ b/tests/RecordTest.cpp
@@ -19,6 +19,12 @@ public:
int area() const { return fArea; }
+ void apply(const SkRecord& record) {
+ for (unsigned i = 0; i < record.count(); i++) {
+ record.visit(i, *this);
+ }
+ }
+
private:
int fArea;
};
@@ -29,6 +35,12 @@ template <> void AreaSummer::operator()(const SkRecords::DrawRect& record) {
// Scales out the bottom-right corner of any DrawRect command it sees by 2x.
struct Stretch {
template <typename T> void operator()(T*) {}
+
+ void apply(SkRecord* record) {
+ for (unsigned i = 0; i < record->count(); i++) {
+ record->mutate(i, *this);
+ }
+ }
};
template <> void Stretch::operator()(SkRecords::DrawRect* record) {
record->rect.fRight *= 2;
@@ -46,14 +58,14 @@ DEF_TEST(Record, r) {
// Its area should be 100.
AreaSummer summer;
- record.visit(summer);
+ summer.apply(record);
REPORTER_ASSERT(r, summer.area() == 100);
// Scale 2x.
Stretch stretch;
- record.mutate(stretch);
+ stretch.apply(&record);
// Now its area should be 100 + 400.
- record.visit(summer);
+ summer.apply(record);
REPORTER_ASSERT(r, summer.area() == 500);
}