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"
9 
~SkRecord()10 SkRecord::~SkRecord() {
11     Destroyer destroyer;
12     for (unsigned i = 0; i < this->count(); i++) {
13         this->mutate<void>(i, destroyer);
14     }
15 }
16 
grow()17 void SkRecord::grow() {
18     SkASSERT(fCount == fReserved);
19     SkASSERT(fReserved > 0);
20     fReserved *= 2;
21     fRecords.realloc(fReserved);
22 }
23 
bytesUsed() const24 size_t SkRecord::bytesUsed() const {
25     size_t bytes = fAlloc.approxBytesAllocated() + sizeof(SkRecord);
26     // If fReserved <= kInlineRecords, we've already accounted for fRecords with sizeof(SkRecord).
27     // When we go over that limit, they're allocated on the heap (and the inline space is wasted).
28     if (fReserved > kInlineRecords) {
29         bytes += fReserved * sizeof(Record);
30     }
31     return bytes;
32 }
33