OLD | NEW |
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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
129 SkASSERT(prev == block->fPrev); | 129 SkASSERT(prev == block->fPrev); |
130 if (NULL != prev) { | 130 if (prev) { |
131 SkASSERT(prev->fNext == block); | 131 SkASSERT(prev->fNext == block); |
132 } | 132 } |
133 | 133 |
134 intptr_t b = reinterpret_cast<intptr_t>(block); | 134 intptr_t b = reinterpret_cast<intptr_t>(block); |
135 size_t ptrOffset = block->fCurrPtr - b; | 135 size_t ptrOffset = block->fCurrPtr - b; |
136 size_t totalSize = ptrOffset + block->fFreeSize; | 136 size_t totalSize = ptrOffset + block->fFreeSize; |
137 size_t userSize = totalSize - kHeaderSize; | 137 size_t userSize = totalSize - kHeaderSize; |
138 intptr_t userStart = b + kHeaderSize; | 138 intptr_t userStart = b + kHeaderSize; |
139 | 139 |
140 SkASSERT(!(b % kAlignment)); | 140 SkASSERT(!(b % kAlignment)); |
(...skipping 11 matching lines...) Expand all Loading... |
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 } |
OLD | NEW |