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

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

Issue 742253002: remove GrAllocPool (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: feedback inc Created 6 years, 1 month 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/gpu/GrAADistanceFieldPathRenderer.h ('k') | src/gpu/GrAllocPool.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2010 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #ifndef GrAllocPool_DEFINED
9 #define GrAllocPool_DEFINED
10
11 #include "SkTypes.h"
12
13 class GrAllocPool : SkNoncopyable {
14 public:
15 GrAllocPool(size_t blockSize = 0);
16 ~GrAllocPool();
17
18 /**
19 * Frees all blocks that have been allocated with alloc().
20 */
21 void reset();
22
23 /**
24 * Returns a block of memory bytes size big. This address must not be
25 * passed to realloc/free/delete or any other function that assumes the
26 * address was allocated by malloc or new (because it hasn't).
27 */
28 void* alloc(size_t bytes);
29
30 /**
31 * Releases the most recently allocated bytes back to allocpool.
32 */
33 void release(size_t bytes);
34
35 private:
36 struct Block;
37
38 Block* fBlock;
39 size_t fMinBlockSize;
40
41 #ifdef SK_DEBUG
42 int fBlocksAllocated;
43 void validate() const;
44 #else
45 void validate() const {}
46 #endif
47 };
48
49 template <typename T> class GrTAllocPool {
50 public:
51 GrTAllocPool(int count) : fPool(count * sizeof(T)) {}
52
53 void reset() { fPool.reset(); }
54 T* alloc() { return (T*)fPool.alloc(sizeof(T)); }
55
56 private:
57 GrAllocPool fPool;
58 };
59
60 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAADistanceFieldPathRenderer.h ('k') | src/gpu/GrAllocPool.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698