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

Unified Diff: tests/RecordTest.cpp

Issue 245853002: Refactor SkRecord opts, converting playback optimizations where possible. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: apply 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/RecordCullingTest.cpp ('k') | tests/RecorderTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/RecordTest.cpp
diff --git a/tests/RecordTest.cpp b/tests/RecordTest.cpp
index 315f15b700a1c1dcd065e51b9b6838d01993fa74..e58ef10ddac457153e272529427cab383361f787 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);
}
« no previous file with comments | « tests/RecordCullingTest.cpp ('k') | tests/RecorderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698