diff options
author | Mike Klein <mtklein@chromium.org> | 2017-04-11 10:36:48 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-11 16:51:17 +0000 |
commit | 0fa156fcfba3b430801b5448ddfc254732bf7386 (patch) | |
tree | ca6806767079c45eeeda0ce14175f275e0e14f9a /src/core/SkRecord.cpp | |
parent | 7a542c559a6e584107b94e6254ac3c7f9f24b591 (diff) |
remove inline allocation in SkRecord
This is part one of many to making SkPicture simpler.
SkMiniPicture covers the really small allocations,
so there's really no reason for us to have these inline allocations.
BUG=skia:6484
Change-Id: I0e27ac747a6b15cf178db9639128fef757bc137b
Reviewed-on: https://skia-review.googlesource.com/13137
Commit-Queue: Mike Klein <mtklein@chromium.org>
Reviewed-by: Herb Derby <herb@google.com>
Diffstat (limited to 'src/core/SkRecord.cpp')
-rw-r--r-- | src/core/SkRecord.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/src/core/SkRecord.cpp b/src/core/SkRecord.cpp index 3685b2d16d..3d098c6c89 100644 --- a/src/core/SkRecord.cpp +++ b/src/core/SkRecord.cpp @@ -8,6 +8,9 @@ #include "SkRecord.h" #include <algorithm> +SkRecord::SkRecord() + : fCount(0), fReserved(0), fAlloc(8/*first malloc at 256 bytes*/) {} + SkRecord::~SkRecord() { Destroyer destroyer; for (int i = 0; i < this->count(); i++) { @@ -17,19 +20,14 @@ SkRecord::~SkRecord() { void SkRecord::grow() { SkASSERT(fCount == fReserved); - SkASSERT(fReserved > 0); - fReserved *= 2; + fReserved = fReserved ? fReserved * 2 : 4; fRecords.realloc(fReserved); } size_t SkRecord::bytesUsed() const { - size_t bytes = fAlloc.approxBytesAllocated() + sizeof(SkRecord); - // If fReserved <= kInlineRecords, we've already accounted for fRecords with sizeof(SkRecord). - // When we go over that limit, they're allocated on the heap (and the inline space is wasted). - if (fReserved > kInlineRecords) { - bytes += fReserved * sizeof(Record); - } - return bytes; + return sizeof(SkRecord) + + fReserved * sizeof(Record) + + fAlloc.approxBytesAllocated(); } void SkRecord::defrag() { |