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 | |
8 #include "SkRecord.h" | 1 #include "SkRecord.h" |
9 | 2 |
10 SkRecord::~SkRecord() { | 3 SkRecord::~SkRecord() { |
11 Destroyer destroyer; | 4 Destroyer destroyer; |
12 for (unsigned i = 0; i < this->count(); i++) { | 5 for (unsigned i = 0; i < this->count(); i++) { |
13 this->mutate<void>(i, destroyer); | 6 this->mutate<void>(i, destroyer); |
14 } | 7 } |
15 } | 8 } |
16 | 9 |
17 void SkRecord::grow() { | 10 void SkRecord::grow() { |
18 SkASSERT(fCount == fReserved); | 11 SkASSERT(fCount == fReserved); |
19 SkASSERT(fReserved > 0); | 12 fReserved = SkTMax<unsigned>(kFirstReserveCount, fReserved*2); |
20 fReserved *= 2; | |
21 fRecords.realloc(fReserved); | 13 fRecords.realloc(fReserved); |
| 14 fTypes.realloc(fReserved); |
22 } | 15 } |
23 | 16 |
24 size_t SkRecord::bytesUsed() const { | 17 size_t SkRecord::bytesUsed() const { |
25 return fAlloc.approxBytesAllocated() + | 18 return fAlloc.approxBytesAllocated() + |
26 (fReserved - kInlineRecords) * sizeof(Record) + | 19 fReserved * (sizeof(Record) + sizeof(Type8)) + |
27 sizeof(SkRecord); | 20 sizeof(SkRecord); |
28 } | 21 } |
OLD | NEW |