OLD | NEW |
| 1 /* |
| 2 * Copyright 2015 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
1 #include "SkRecord.h" | 8 #include "SkRecord.h" |
2 | 9 |
3 SkRecord::~SkRecord() { | 10 SkRecord::~SkRecord() { |
4 Destroyer destroyer; | 11 Destroyer destroyer; |
5 for (unsigned i = 0; i < this->count(); i++) { | 12 for (unsigned i = 0; i < this->count(); i++) { |
6 this->mutate<void>(i, destroyer); | 13 this->mutate<void>(i, destroyer); |
7 } | 14 } |
8 } | 15 } |
9 | 16 |
10 void SkRecord::grow() { | 17 void SkRecord::grow() { |
11 SkASSERT(fCount == fReserved); | 18 SkASSERT(fCount == fReserved); |
12 fReserved = SkTMax<unsigned>(kFirstReserveCount, fReserved*2); | 19 SkASSERT(fReserved > 0); |
| 20 fReserved *= 2; |
13 fRecords.realloc(fReserved); | 21 fRecords.realloc(fReserved); |
14 fTypes.realloc(fReserved); | |
15 } | 22 } |
16 | 23 |
17 size_t SkRecord::bytesUsed() const { | 24 size_t SkRecord::bytesUsed() const { |
18 return fAlloc.approxBytesAllocated() + | 25 return fAlloc.approxBytesAllocated() + |
19 fReserved * (sizeof(Record) + sizeof(Type8)) + | 26 (fReserved - kInlineRecords) * sizeof(Record) + |
20 sizeof(SkRecord); | 27 sizeof(SkRecord); |
21 } | 28 } |
OLD | NEW |