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

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

Issue 1317593004: Clean up SkTLogic. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove no longer true comment. Created 5 years, 3 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 | « include/private/SkTemplates.h ('k') | src/gpu/effects/GrPorterDuffXferProcessor.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 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 // We store the types of each of the pointers alongside the pointer. 127 // We store the types of each of the pointers alongside the pointer.
128 // The cost to append a T to this structure is 8 + sizeof(T) bytes. 128 // The cost to append a T to this structure is 8 + sizeof(T) bytes.
129 129
130 // A mutator that can be used with replace to destroy canvas commands. 130 // A mutator that can be used with replace to destroy canvas commands.
131 struct Destroyer { 131 struct Destroyer {
132 template <typename T> 132 template <typename T>
133 void operator()(T* record) { record->~T(); } 133 void operator()(T* record) { record->~T(); }
134 }; 134 };
135 135
136 template <typename T> 136 template <typename T>
137 SK_WHEN(SkTIsEmpty<T>, T*) allocCommand() { 137 SK_WHEN(skstd::is_empty<T>, T*) allocCommand() {
138 static T singleton = {}; 138 static T singleton = {};
139 return &singleton; 139 return &singleton;
140 } 140 }
141 141
142 template <typename T> 142 template <typename T>
143 SK_WHEN(!SkTIsEmpty<T>, T*) allocCommand() { return this->alloc<T>(); } 143 SK_WHEN(!skstd::is_empty<T>, T*) allocCommand() { return this->alloc<T>(); }
144 144
145 void grow(); 145 void grow();
146 146
147 // A typed pointer to some bytes in fAlloc. visit() and mutate() allow poly morphic dispatch. 147 // A typed pointer to some bytes in fAlloc. visit() and mutate() allow poly morphic dispatch.
148 struct Record { 148 struct Record {
149 // On 32-bit machines we store type in 4 bytes, followed by a pointer. Simple. 149 // On 32-bit machines we store type in 4 bytes, followed by a pointer. Simple.
150 // On 64-bit machines we store a pointer with the type slotted into two top (unused) bytes. 150 // On 64-bit machines we store a pointer with the type slotted into two top (unused) bytes.
151 // FWIW, SkRecords::Type is tiny. It can easily fit in one byte. 151 // FWIW, SkRecords::Type is tiny. It can easily fit in one byte.
152 uint64_t fTypeAndPtr; 152 uint64_t fTypeAndPtr;
153 static const int kTypeShift = sizeof(void*) == 4 ? 32 : 48; 153 static const int kTypeShift = sizeof(void*) == 4 ? 32 : 48;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 int fCount, fReserved; 189 int fCount, fReserved;
190 SkAutoSTMalloc<kInlineRecords, Record> fRecords; 190 SkAutoSTMalloc<kInlineRecords, Record> fRecords;
191 191
192 // fAlloc needs to be a data structure which can append variable length data in contiguous 192 // fAlloc needs to be a data structure which can append variable length data in contiguous
193 // chunks, returning a stable handle to that data for later retrieval. 193 // chunks, returning a stable handle to that data for later retrieval.
194 SkVarAlloc fAlloc; 194 SkVarAlloc fAlloc;
195 char fInlineAlloc[1 << kInlineAllocLgBytes]; 195 char fInlineAlloc[1 << kInlineAllocLgBytes];
196 }; 196 };
197 197
198 #endif//SkRecord_DEFINED 198 #endif//SkRecord_DEFINED
OLDNEW
« no previous file with comments | « include/private/SkTemplates.h ('k') | src/gpu/effects/GrPorterDuffXferProcessor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698