OLD | NEW |
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 #include "GrBufferAllocPool.h" | 10 #include "GrBufferAllocPool.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 177 |
178 SkASSERT(buffer); | 178 SkASSERT(buffer); |
179 SkASSERT(offset); | 179 SkASSERT(offset); |
180 | 180 |
181 if (fBufferPtr) { | 181 if (fBufferPtr) { |
182 BufferBlock& back = fBlocks.back(); | 182 BufferBlock& back = fBlocks.back(); |
183 size_t usedBytes = back.fBuffer->gpuMemorySize() - back.fBytesFree; | 183 size_t usedBytes = back.fBuffer->gpuMemorySize() - back.fBytesFree; |
184 size_t pad = GrSizeAlignUpPad(usedBytes, | 184 size_t pad = GrSizeAlignUpPad(usedBytes, |
185 alignment); | 185 alignment); |
186 if ((size + pad) <= back.fBytesFree) { | 186 if ((size + pad) <= back.fBytesFree) { |
| 187 memset((void*)(reinterpret_cast<intptr_t>(fBufferPtr) + usedBytes),
0, pad); |
187 usedBytes += pad; | 188 usedBytes += pad; |
188 *offset = usedBytes; | 189 *offset = usedBytes; |
189 *buffer = back.fBuffer; | 190 *buffer = back.fBuffer; |
190 back.fBytesFree -= size + pad; | 191 back.fBytesFree -= size + pad; |
191 fBytesInUse += size + pad; | 192 fBytesInUse += size + pad; |
192 VALIDATE(); | 193 VALIDATE(); |
193 return (void*)(reinterpret_cast<intptr_t>(fBufferPtr) + usedBytes); | 194 return (void*)(reinterpret_cast<intptr_t>(fBufferPtr) + usedBytes); |
194 } | 195 } |
195 } | 196 } |
196 | 197 |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 return ptr; | 469 return ptr; |
469 } | 470 } |
470 | 471 |
471 int GrIndexBufferAllocPool::preallocatedBufferIndices() const { | 472 int GrIndexBufferAllocPool::preallocatedBufferIndices() const { |
472 return static_cast<int>(INHERITED::preallocatedBufferSize() / sizeof(uint16_
t)); | 473 return static_cast<int>(INHERITED::preallocatedBufferSize() / sizeof(uint16_
t)); |
473 } | 474 } |
474 | 475 |
475 int GrIndexBufferAllocPool::currentBufferIndices() const { | 476 int GrIndexBufferAllocPool::currentBufferIndices() const { |
476 return currentBufferItems(sizeof(uint16_t)); | 477 return currentBufferItems(sizeof(uint16_t)); |
477 } | 478 } |
OLD | NEW |