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

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

Issue 22850006: Replace uses of GrAssert by SkASSERT. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rebase Created 7 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 | Annotate | Revision Log
« no previous file with comments | « src/gpu/GrAARectRenderer.cpp ('k') | src/gpu/GrAllocator.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 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 10
11 #include "GrAllocPool.h" 11 #include "GrAllocPool.h"
12 12
13 #define GrAllocPool_MIN_BLOCK_SIZE ((size_t)128) 13 #define GrAllocPool_MIN_BLOCK_SIZE ((size_t)128)
14 14
15 struct GrAllocPool::Block { 15 struct GrAllocPool::Block {
16 Block* fNext; 16 Block* fNext;
17 char* fPtr; 17 char* fPtr;
18 size_t fBytesFree; 18 size_t fBytesFree;
19 size_t fBytesTotal; 19 size_t fBytesTotal;
20 20
21 static Block* Create(size_t size, Block* next) { 21 static Block* Create(size_t size, Block* next) {
22 GrAssert(size >= GrAllocPool_MIN_BLOCK_SIZE); 22 SkASSERT(size >= GrAllocPool_MIN_BLOCK_SIZE);
23 23
24 Block* block = (Block*)GrMalloc(sizeof(Block) + size); 24 Block* block = (Block*)GrMalloc(sizeof(Block) + size);
25 block->fNext = next; 25 block->fNext = next;
26 block->fPtr = (char*)block + sizeof(Block); 26 block->fPtr = (char*)block + sizeof(Block);
27 block->fBytesFree = size; 27 block->fBytesFree = size;
28 block->fBytesTotal = size; 28 block->fBytesTotal = size;
29 return block; 29 return block;
30 } 30 }
31 31
32 bool canAlloc(size_t bytes) const { 32 bool canAlloc(size_t bytes) const {
33 return bytes <= fBytesFree; 33 return bytes <= fBytesFree;
34 } 34 }
35 35
36 void* alloc(size_t bytes) { 36 void* alloc(size_t bytes) {
37 GrAssert(bytes <= fBytesFree); 37 SkASSERT(bytes <= fBytesFree);
38 fBytesFree -= bytes; 38 fBytesFree -= bytes;
39 void* ptr = fPtr; 39 void* ptr = fPtr;
40 fPtr += bytes; 40 fPtr += bytes;
41 return ptr; 41 return ptr;
42 } 42 }
43 43
44 size_t release(size_t bytes) { 44 size_t release(size_t bytes) {
45 GrAssert(bytes > 0); 45 SkASSERT(bytes > 0);
46 size_t free = GrMin(bytes, fBytesTotal - fBytesFree); 46 size_t free = GrMin(bytes, fBytesTotal - fBytesFree);
47 fBytesFree += free; 47 fBytesFree += free;
48 fPtr -= free; 48 fPtr -= free;
49 return bytes - free; 49 return bytes - free;
50 } 50 }
51 51
52 bool empty() const { return fBytesTotal == fBytesFree; } 52 bool empty() const { return fBytesTotal == fBytesFree; }
53 }; 53 };
54 54
55 /////////////////////////////////////////////////////////////////////////////// 55 ///////////////////////////////////////////////////////////////////////////////
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 105
106 #if GR_DEBUG 106 #if GR_DEBUG
107 107
108 void GrAllocPool::validate() const { 108 void GrAllocPool::validate() const {
109 Block* block = fBlock; 109 Block* block = fBlock;
110 int count = 0; 110 int count = 0;
111 while (block) { 111 while (block) {
112 count += 1; 112 count += 1;
113 block = block->fNext; 113 block = block->fNext;
114 } 114 }
115 GrAssert(fBlocksAllocated == count); 115 SkASSERT(fBlocksAllocated == count);
116 } 116 }
117 117
118 #endif 118 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrAARectRenderer.cpp ('k') | src/gpu/GrAllocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698