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

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

Issue 1824983003: SkRecord: infer return type for visit() and mutate(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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 | « src/core/SkRecord.h ('k') | src/core/SkRecordDraw.cpp » ('j') | 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 #include <algorithm> 9 #include <algorithm>
10 10
11 SkRecord::~SkRecord() { 11 SkRecord::~SkRecord() {
12 Destroyer destroyer; 12 Destroyer destroyer;
13 for (int i = 0; i < this->count(); i++) { 13 for (int i = 0; i < this->count(); i++) {
14 this->mutate<void>(i, destroyer); 14 this->mutate(i, destroyer);
15 } 15 }
16 } 16 }
17 17
18 void SkRecord::grow() { 18 void SkRecord::grow() {
19 SkASSERT(fCount == fReserved); 19 SkASSERT(fCount == fReserved);
20 SkASSERT(fReserved > 0); 20 SkASSERT(fReserved > 0);
21 fReserved *= 2; 21 fReserved *= 2;
22 fRecords.realloc(fReserved); 22 fRecords.realloc(fReserved);
23 } 23 }
24 24
25 size_t SkRecord::bytesUsed() const { 25 size_t SkRecord::bytesUsed() const {
26 size_t bytes = fAlloc.approxBytesAllocated() + sizeof(SkRecord); 26 size_t bytes = fAlloc.approxBytesAllocated() + sizeof(SkRecord);
27 // If fReserved <= kInlineRecords, we've already accounted for fRecords with sizeof(SkRecord). 27 // If fReserved <= kInlineRecords, we've already accounted for fRecords with sizeof(SkRecord).
28 // When we go over that limit, they're allocated on the heap (and the inline space is wasted). 28 // When we go over that limit, they're allocated on the heap (and the inline space is wasted).
29 if (fReserved > kInlineRecords) { 29 if (fReserved > kInlineRecords) {
30 bytes += fReserved * sizeof(Record); 30 bytes += fReserved * sizeof(Record);
31 } 31 }
32 return bytes; 32 return bytes;
33 } 33 }
34 34
35 void SkRecord::defrag() { 35 void SkRecord::defrag() {
36 // Remove all the NoOps, preserving the order of other ops, e.g. 36 // Remove all the NoOps, preserving the order of other ops, e.g.
37 // Save, ClipRect, NoOp, DrawRect, NoOp, NoOp, Restore 37 // Save, ClipRect, NoOp, DrawRect, NoOp, NoOp, Restore
38 // -> Save, ClipRect, DrawRect, Restore 38 // -> Save, ClipRect, DrawRect, Restore
39 Record* noops = std::remove_if(fRecords.get(), fRecords.get() + fCount, 39 Record* noops = std::remove_if(fRecords.get(), fRecords.get() + fCount,
40 [](Record op) { return op.type() == SkRecords ::NoOp_Type; }); 40 [](Record op) { return op.type() == SkRecords ::NoOp_Type; });
41 fCount = noops - fRecords.get(); 41 fCount = noops - fRecords.get();
42 } 42 }
OLDNEW
« no previous file with comments | « src/core/SkRecord.h ('k') | src/core/SkRecordDraw.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698