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

Side by Side Diff: src/gpu/GrMemoryPool.h

Issue 742253002: remove GrAllocPool (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to use SkVarAlloc Created 6 years 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 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 GrMemoryPool_DEFINED 8 #ifndef GrMemoryPool_DEFINED
9 #define GrMemoryPool_DEFINED 9 #define GrMemoryPool_DEFINED
10 10
(...skipping 20 matching lines...) Expand all
31 /** 31 /**
32 * Allocates memory. The memory must be freed with release(). 32 * Allocates memory. The memory must be freed with release().
33 */ 33 */
34 void* allocate(size_t size); 34 void* allocate(size_t size);
35 35
36 /** 36 /**
37 * p must have been returned by allocate() 37 * p must have been returned by allocate()
38 */ 38 */
39 void release(void* p); 39 void release(void* p);
40 40
41 void releaseAll();
42
41 /** 43 /**
42 * Returns true if there are no unreleased allocations. 44 * Returns true if there are no unreleased allocations.
43 */ 45 */
44 bool isEmpty() const { return fTail == fHead && !fHead->fLiveCount; } 46 bool isEmpty() const { return fTail == fHead && !fHead->fLiveCount; }
45 47
46 private: 48 private:
47 struct BlockHeader; 49 struct BlockHeader;
48 50
49 static BlockHeader* CreateBlock(size_t size); 51 static BlockHeader* CreateBlock(size_t size);
50 52
(...skipping 19 matching lines...) Expand all
70 }; 72 };
71 size_t fPreallocSize; 73 size_t fPreallocSize;
72 size_t fMinAllocSize; 74 size_t fMinAllocSize;
73 BlockHeader* fHead; 75 BlockHeader* fHead;
74 BlockHeader* fTail; 76 BlockHeader* fTail;
75 #ifdef SK_DEBUG 77 #ifdef SK_DEBUG
76 int fAllocationCnt; 78 int fAllocationCnt;
77 #endif 79 #endif
78 }; 80 };
79 81
82 template <typename T> class GrTMemoryPool {
83 public:
84 GrTMemoryPool(size_t count)
85 : fPool(count * sizeof(T), count * sizeof(T)) {}
86
87 T* allocate() { return (T*)fPool.allocate(sizeof(T)); }
88 void releaseAll() { fPool.releaseAll(); }
89
90 private:
91 GrMemoryPool fPool;
92 };
93
80 #endif 94 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAllocPool.cpp ('k') | src/gpu/GrMemoryPool.cpp » ('j') | src/gpu/GrTextStrike.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698