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

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

Issue 226183018: SkNonCopyable should be used with private inheritance. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: name resolution Created 6 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 | « src/core/SkMatrixClipStateMgr.h ('k') | src/core/SkTLList.h » ('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 SkSmallAllocator_DEFINED 8 #ifndef SkSmallAllocator_DEFINED
9 #define SkSmallAllocator_DEFINED 9 #define SkSmallAllocator_DEFINED
10 10
(...skipping 11 matching lines...) Expand all
22 * allocations. kMaxObjects is a hard limit on the number of objects that can 22 * allocations. kMaxObjects is a hard limit on the number of objects that can
23 * be allocated using this class. After that, attempts to create more objects 23 * be allocated using this class. After that, attempts to create more objects
24 * with this class will assert and return NULL. 24 * with this class will assert and return NULL.
25 * kTotalBytes is the total number of bytes provided for storage for all 25 * kTotalBytes is the total number of bytes provided for storage for all
26 * objects created by this allocator. If an object to be created is larger 26 * objects created by this allocator. If an object to be created is larger
27 * than the storage (minus storage already used), it will be allocated on the 27 * than the storage (minus storage already used), it will be allocated on the
28 * heap. This class's destructor will handle calling the destructor for each 28 * heap. This class's destructor will handle calling the destructor for each
29 * object it allocated and freeing its memory. 29 * object it allocated and freeing its memory.
30 */ 30 */
31 template<uint32_t kMaxObjects, size_t kTotalBytes> 31 template<uint32_t kMaxObjects, size_t kTotalBytes>
32 class SkSmallAllocator : public SkNoncopyable { 32 class SkSmallAllocator : SkNoncopyable {
33 public: 33 public:
34 SkSmallAllocator() 34 SkSmallAllocator()
35 : fStorageUsed(0) 35 : fStorageUsed(0)
36 , fNumObjects(0) 36 , fNumObjects(0)
37 {} 37 {}
38 38
39 ~SkSmallAllocator() { 39 ~SkSmallAllocator() {
40 // Destruct in reverse order, in case an earlier object points to a 40 // Destruct in reverse order, in case an earlier object points to a
41 // later object. 41 // later object.
42 while (fNumObjects > 0) { 42 while (fNumObjects > 0) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 140
141 // Number of bytes used so far. 141 // Number of bytes used so far.
142 size_t fStorageUsed; 142 size_t fStorageUsed;
143 // Pad the storage size to be 4-byte aligned. 143 // Pad the storage size to be 4-byte aligned.
144 uint32_t fStorage[SkAlign4(kTotalBytes) >> 2]; 144 uint32_t fStorage[SkAlign4(kTotalBytes) >> 2];
145 uint32_t fNumObjects; 145 uint32_t fNumObjects;
146 Rec fRecs[kMaxObjects]; 146 Rec fRecs[kMaxObjects];
147 }; 147 };
148 148
149 #endif // SkSmallAllocator_DEFINED 149 #endif // SkSmallAllocator_DEFINED
OLDNEW
« no previous file with comments | « src/core/SkMatrixClipStateMgr.h ('k') | src/core/SkTLList.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698