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

Unified Diff: tests/RecordTest.cpp

Issue 229523002: SkRecord: make culling work if SkRecordAnnotateCullingPairs is called. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase 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 1214b1a5de78d461ad31ecc410887b3680704c62..58e5de106c48e2bd8bbb6b706d7e1fe50de80eaa 100644
--- a/tests/RecordTest.cpp
+++ b/tests/RecordTest.cpp
@@ -3,18 +3,20 @@
#include "SkRecord.h"
#include "SkRecords.h"
-// Adds the area of any DrawRect command it sees into area.
+// Sums the area of any DrawRect command it sees.
class AreaSummer {
public:
- explicit AreaSummer(int* area) : fArea(area) {}
+ AreaSummer() : fArea(0) {}
template <typename T> void operator()(const T&) { }
+ int area() const { return fArea; }
+
private:
- int* fArea;
+ int fArea;
};
template <> void AreaSummer::operator()(const SkRecords::DrawRect& record) {
- *fArea += (int) (record.rect.width() * record.rect.height());
+ fArea += (int) (record.rect.width() * record.rect.height());
}
// Scales out the bottom-right corner of any DrawRect command it sees by 2x.
@@ -36,13 +38,15 @@ DEF_TEST(Record, r) {
SkNEW_PLACEMENT_ARGS(record.append<SkRecords::DrawRect>(), SkRecords::DrawRect, (rect, paint));
// Its area should be 100.
- int area = 0;
- record.visit(AreaSummer(&area));
- REPORTER_ASSERT(r, area == 100);
-
- // Scale 2x. Now it's area should be 400.
- record.mutate(Stretch());
- area = 0;
- record.visit(AreaSummer(&area));
- REPORTER_ASSERT(r, area == 400);
+ AreaSummer summer;
+ record.visit(summer);
+ REPORTER_ASSERT(r, summer.area() == 100);
+
+ // Scale 2x.
+ Stretch stretch;
+ record.mutate(stretch);
+
+ // Now its area should be 100 + 400.
+ record.visit(summer);
+ 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