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

Unified Diff: src/record/SkRecord.h

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 | « gyp/tests.gypi ('k') | src/record/SkRecordCulling.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/record/SkRecord.h
diff --git a/src/record/SkRecord.h b/src/record/SkRecord.h
index 4013874677825afd5ceb7adfe73a3bac374f37a9..0fe79189d4c6d8238706f619d108b3890ed9b1c7 100644
--- a/src/record/SkRecord.h
+++ b/src/record/SkRecord.h
@@ -21,33 +21,49 @@ class SkRecord : SkNoncopyable {
public:
SkRecord(size_t chunkBytes = 4096, unsigned firstReserveCount = 64 / sizeof(void*))
: fAlloc(chunkBytes), fCount(0), fReserved(0), kFirstReserveCount(firstReserveCount) {}
- ~SkRecord() { this->mutate(Destroyer()); }
+
+ ~SkRecord() {
+ Destroyer destroyer;
+ this->mutate(destroyer);
+ }
+
+ unsigned count() const { return fCount; }
// Accepts a visitor functor with this interface:
// template <typename T>
- // void operator()()(const T& record) { ... }
+ // void operator()(const T& record) { ... }
// This operator() must be defined for at least all SkRecords::*; your compiler will help you
// get this right.
- //
- // f will be called on each recorded canvas call in the order they were append()ed.
template <typename F>
- void visit(F f) const {
+ void visit(unsigned i, F& f) const {
+ SkASSERT(i < this->count());
+ fRecords[i].visit(fTypes[i], f);
+ }
+
+ // As above. f will be called on each recorded canvas call in the order they were append()ed.
+ template <typename F>
+ void visit(F& f) const {
for (unsigned i = 0; i < fCount; i++) {
- fRecords[i].visit(fTypes[i], f);
+ this->visit(i, f);
}
}
// Accepts a visitor functor with this interface:
// template <typename T>
- // void operator()()(T* record) { ... }
+ // void operator()(T* record) { ... }
// This operator() must be defined for at least all SkRecords::*; again, your compiler will help
// you get this right.
- //
- // f will be called on each recorded canvas call in the order they were append()ed.
template <typename F>
- void mutate(F f) {
+ void mutate(unsigned i, F& f) {
+ SkASSERT(i < this->count());
+ fRecords[i].mutate(fTypes[i], f);
+ }
+
+ // As above. f will be called on each recorded canvas call in the order they were append()ed.
+ template <typename F>
+ void mutate(F& f) {
for (unsigned i = 0; i < fCount; i++) {
- fRecords[i].mutate(fTypes[i], f);
+ this->mutate(i, f);
}
}
@@ -154,7 +170,7 @@ private:
// Visit this record with functor F (see public API above) assuming the record we're
// pointing to has this type.
template <typename F>
- void visit(Type8 type, F f) const {
+ void visit(Type8 type, F& f) const {
#define CASE(T) case SkRecords::T##_Type: return f(*this->ptr<SkRecords::T>());
switch(type) { SK_RECORD_TYPES(CASE) }
#undef CASE
@@ -163,7 +179,7 @@ private:
// Mutate this record with functor F (see public API above) assuming the record we're
// pointing to has this type.
template <typename F>
- void mutate(Type8 type, F f) {
+ void mutate(Type8 type, F& f) {
#define CASE(T) case SkRecords::T##_Type: return f(this->ptr<SkRecords::T>());
switch(type) { SK_RECORD_TYPES(CASE) }
#undef CASE
« no previous file with comments | « gyp/tests.gypi ('k') | src/record/SkRecordCulling.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698