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

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

Issue 23566022: move GrMalloc, GrFree, Gr_bzero to their sk equivalents (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 2 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/GrGpu.cpp ('k') | src/gpu/GrPlotMgr.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 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 #include "GrMemoryPool.h" 8 #include "GrMemoryPool.h"
9 9
10 #ifdef SK_DEBUG 10 #ifdef SK_DEBUG
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 block->fFreeSize += (block->fCurrPtr - block->fPrevPtr); 97 block->fFreeSize += (block->fCurrPtr - block->fPrevPtr);
98 block->fCurrPtr = block->fPrevPtr; 98 block->fCurrPtr = block->fPrevPtr;
99 } 99 }
100 } 100 }
101 SkDEBUGCODE(--fAllocationCnt); 101 SkDEBUGCODE(--fAllocationCnt);
102 VALIDATE; 102 VALIDATE;
103 } 103 }
104 104
105 GrMemoryPool::BlockHeader* GrMemoryPool::CreateBlock(size_t size) { 105 GrMemoryPool::BlockHeader* GrMemoryPool::CreateBlock(size_t size) {
106 BlockHeader* block = 106 BlockHeader* block =
107 reinterpret_cast<BlockHeader*>(GrMalloc(size + kHeaderSize)); 107 reinterpret_cast<BlockHeader*>(sk_malloc_throw(size + kHeaderSize));
108 // we assume malloc gives us aligned memory 108 // we assume malloc gives us aligned memory
109 SkASSERT(!(reinterpret_cast<intptr_t>(block) % kAlignment)); 109 SkASSERT(!(reinterpret_cast<intptr_t>(block) % kAlignment));
110 block->fLiveCount = 0; 110 block->fLiveCount = 0;
111 block->fFreeSize = size; 111 block->fFreeSize = size;
112 block->fCurrPtr = reinterpret_cast<intptr_t>(block) + kHeaderSize; 112 block->fCurrPtr = reinterpret_cast<intptr_t>(block) + kHeaderSize;
113 block->fPrevPtr = 0; // gcc warns on assigning NULL to an intptr_t. 113 block->fPrevPtr = 0; // gcc warns on assigning NULL to an intptr_t.
114 return block; 114 return block;
115 } 115 }
116 116
117 void GrMemoryPool::DeleteBlock(BlockHeader* block) { 117 void GrMemoryPool::DeleteBlock(BlockHeader* block) {
118 GrFree(block); 118 sk_free(block);
119 } 119 }
120 120
121 void GrMemoryPool::validate() { 121 void GrMemoryPool::validate() {
122 #ifdef SK_DEBUG 122 #ifdef SK_DEBUG
123 BlockHeader* block = fHead; 123 BlockHeader* block = fHead;
124 BlockHeader* prev = NULL; 124 BlockHeader* prev = NULL;
125 SkASSERT(block); 125 SkASSERT(block);
126 int allocCount = 0; 126 int allocCount = 0;
127 do { 127 do {
128 allocCount += block->fLiveCount; 128 allocCount += block->fLiveCount;
(...skipping 23 matching lines...) Expand all
152 SkASSERT(userStart == block->fCurrPtr); 152 SkASSERT(userStart == block->fCurrPtr);
153 } else { 153 } else {
154 SkASSERT(block == *reinterpret_cast<BlockHeader**>(userStart)); 154 SkASSERT(block == *reinterpret_cast<BlockHeader**>(userStart));
155 } 155 }
156 prev = block; 156 prev = block;
157 } while ((block = block->fNext)); 157 } while ((block = block->fNext));
158 SkASSERT(allocCount == fAllocationCnt); 158 SkASSERT(allocCount == fAllocationCnt);
159 SkASSERT(prev == fTail); 159 SkASSERT(prev == fTail);
160 #endif 160 #endif
161 } 161 }
OLDNEW
« no previous file with comments | « src/gpu/GrGpu.cpp ('k') | src/gpu/GrPlotMgr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698