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

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

Issue 449933002: change drawPicture in SkRecord to just ref the picture (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 4 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 | src/core/SkRecordDraw.cpp » ('j') | src/core/SkRecords.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2014 Google Inc. 2 * Copyright 2014 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 #ifndef SkRecord_DEFINED 8 #ifndef SkRecord_DEFINED
9 #define SkRecord_DEFINED 9 #define SkRecord_DEFINED
10 10
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 template <typename R, typename F> 57 template <typename R, typename F>
58 R mutate(unsigned i, F& f) { 58 R mutate(unsigned i, F& f) {
59 SkASSERT(i < this->count()); 59 SkASSERT(i < this->count());
60 return fRecords[i].mutate<R>(fTypes[i], f); 60 return fRecords[i].mutate<R>(fTypes[i], f);
61 } 61 }
62 // TODO: It'd be nice to infer R from F for visit and mutate if we ever get std::result_of. 62 // TODO: It'd be nice to infer R from F for visit and mutate if we ever get std::result_of.
63 63
64 // Allocate contiguous space for count Ts, to be freed when the SkRecord is destroyed. 64 // Allocate contiguous space for count Ts, to be freed when the SkRecord is destroyed.
65 // Here T can be any class, not just those from SkRecords. Throws on failur e. 65 // Here T can be any class, not just those from SkRecords. Throws on failur e.
66 template <typename T> 66 template <typename T>
67 T* alloc(unsigned count = 1) { 67 T* alloc(size_t count = 1) {
68 return (T*)fAlloc.allocThrow(sizeof(T) * count); 68 return (T*)fAlloc.allocThrow(sizeof(T) * count);
69 } 69 }
70 70
71 // Add a new command of type T to the end of this SkRecord. 71 // Add a new command of type T to the end of this SkRecord.
72 // You are expected to placement new an object of type T onto this pointer. 72 // You are expected to placement new an object of type T onto this pointer.
73 template <typename T> 73 template <typename T>
74 T* append() { 74 T* append() {
75 if (fCount == fReserved) { 75 if (fCount == fReserved) {
76 fReserved = SkTMax(kFirstReserveCount, fReserved*2); 76 fReserved = SkTMax(kFirstReserveCount, fReserved*2);
77 fRecords.realloc(fReserved); 77 fRecords.realloc(fReserved);
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 SkChunkAlloc fAlloc; 225 SkChunkAlloc fAlloc;
226 SkAutoTMalloc<Record> fRecords; 226 SkAutoTMalloc<Record> fRecords;
227 SkAutoTMalloc<Type8> fTypes; 227 SkAutoTMalloc<Type8> fTypes;
228 // fCount and fReserved measure both fRecords and fTypes, which always grow in lock step. 228 // fCount and fReserved measure both fRecords and fTypes, which always grow in lock step.
229 unsigned fCount; 229 unsigned fCount;
230 unsigned fReserved; 230 unsigned fReserved;
231 const unsigned kFirstReserveCount; 231 const unsigned kFirstReserveCount;
232 }; 232 };
233 233
234 #endif//SkRecord_DEFINED 234 #endif//SkRecord_DEFINED
OLDNEW
« no previous file with comments | « no previous file | src/core/SkRecordDraw.cpp » ('j') | src/core/SkRecords.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698