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

Side by Side Diff: src/core/SkRecord.cpp

Issue 1081433002: Fix minor undercounting in SkRecord::bytesUsed(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add a comment Created 5 years, 8 months 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkRecord.h" 8 #include "SkRecord.h"
9 9
10 SkRecord::~SkRecord() { 10 SkRecord::~SkRecord() {
11 Destroyer destroyer; 11 Destroyer destroyer;
12 for (unsigned i = 0; i < this->count(); i++) { 12 for (unsigned i = 0; i < this->count(); i++) {
13 this->mutate<void>(i, destroyer); 13 this->mutate<void>(i, destroyer);
14 } 14 }
15 } 15 }
16 16
17 void SkRecord::grow() { 17 void SkRecord::grow() {
18 SkASSERT(fCount == fReserved); 18 SkASSERT(fCount == fReserved);
19 SkASSERT(fReserved > 0); 19 SkASSERT(fReserved > 0);
20 fReserved *= 2; 20 fReserved *= 2;
21 fRecords.realloc(fReserved); 21 fRecords.realloc(fReserved);
22 } 22 }
23 23
24 size_t SkRecord::bytesUsed() const { 24 size_t SkRecord::bytesUsed() const {
25 return fAlloc.approxBytesAllocated() + 25 size_t bytes = fAlloc.approxBytesAllocated() + sizeof(SkRecord);
26 (fReserved - kInlineRecords) * sizeof(Record) + 26 // If fReserved <= kInlineRecords, we've already accounted for fRecords with sizeof(SkRecord).
27 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;
28 } 32 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698