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

Unified Diff: src/core/SkRecord.h

Issue 756783002: SkRecord: outline methods that are not called O(N) times. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 1 month 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/core.gypi ('k') | src/core/SkRecord.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkRecord.h
diff --git a/src/core/SkRecord.h b/src/core/SkRecord.h
index 403110d38549fda36391e145b80e9ce397ebb927..236eb6a915454e257b03579777d75f2cc17eccfa 100644
--- a/src/core/SkRecord.h
+++ b/src/core/SkRecord.h
@@ -31,13 +31,7 @@ class SkRecord : SkNoncopyable {
};
public:
SkRecord() : fCount(0), fReserved(0) {}
-
- ~SkRecord() {
- Destroyer destroyer;
- for (unsigned i = 0; i < this->count(); i++) {
- this->mutate<void>(i, destroyer);
- }
- }
+ ~SkRecord();
// Returns the number of canvas commands in this SkRecord.
unsigned count() const { return fCount; }
@@ -76,11 +70,8 @@ public:
template <typename T>
T* append() {
if (fCount == fReserved) {
- fReserved = SkTMax<unsigned>(kFirstReserveCount, fReserved*2);
- fRecords.realloc(fReserved);
- fTypes.realloc(fReserved);
+ this->grow();
}
-
fTypes[fCount] = T::kType;
return fRecords[fCount++].set(this->allocCommand<T>());
}
@@ -115,9 +106,7 @@ public:
// Does not return the bytes in any pointers embedded in the Records; callers
// need to iterate with a visitor to measure those they care for.
- size_t bytesUsed() const { return fAlloc.approxBytesAllocated() +
- fReserved * (sizeof(Record) + sizeof(Type8)) +
- sizeof(SkRecord); }
+ size_t bytesUsed() const;
private:
// Implementation notes!
@@ -184,6 +173,9 @@ private:
template <typename T>
SK_WHEN(!SkTIsEmpty<T>, T*) allocCommand() { return this->alloc<T>(); }
+ // Called when we've run out of room to record new commands.
+ void grow();
+
// An untyped pointer to some bytes in fAlloc. This is the interface for polymorphic dispatch:
// visit() and mutate() work with the parallel fTypes array to do the work of a vtable.
struct Record {
« no previous file with comments | « gyp/core.gypi ('k') | src/core/SkRecord.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698