OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2010 Google Inc. | 2 * Copyright 2010 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 | 8 |
9 #include "GrBufferAllocPool.h" | 9 #include "GrBufferAllocPool.h" |
10 #include "GrBuffer.h" | 10 #include "GrBuffer.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 VALIDATE(); | 71 VALIDATE(); |
72 this->deleteBlocks(); | 72 this->deleteBlocks(); |
73 sk_free(fCpuData); | 73 sk_free(fCpuData); |
74 fGpu->unref(); | 74 fGpu->unref(); |
75 } | 75 } |
76 | 76 |
77 void GrBufferAllocPool::reset() { | 77 void GrBufferAllocPool::reset() { |
78 VALIDATE(); | 78 VALIDATE(); |
79 fBytesInUse = 0; | 79 fBytesInUse = 0; |
80 this->deleteBlocks(); | 80 this->deleteBlocks(); |
81 | 81 this->resetCpuData(0); // delete all the cpu-side memory |
82 // we may have created a large cpu mirror of a large VB. Reset the size to m
atch our minimum. | |
83 this->resetCpuData(fMinBlockSize); | |
84 | |
85 VALIDATE(); | 82 VALIDATE(); |
86 } | 83 } |
87 | 84 |
88 void GrBufferAllocPool::unmap() { | 85 void GrBufferAllocPool::unmap() { |
89 VALIDATE(); | 86 VALIDATE(); |
90 | 87 |
91 if (fBufferPtr) { | 88 if (fBufferPtr) { |
92 BufferBlock& block = fBlocks.back(); | 89 BufferBlock& block = fBlocks.back(); |
93 if (block.fBuffer->isMapped()) { | 90 if (block.fBuffer->isMapped()) { |
94 UNMAP_BUFFER(block); | 91 UNMAP_BUFFER(block); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 size_t offset = 0; // assign to suppress warning | 362 size_t offset = 0; // assign to suppress warning |
366 void* ptr = INHERITED::makeSpace(indexCount * sizeof(uint16_t), | 363 void* ptr = INHERITED::makeSpace(indexCount * sizeof(uint16_t), |
367 sizeof(uint16_t), | 364 sizeof(uint16_t), |
368 buffer, | 365 buffer, |
369 &offset); | 366 &offset); |
370 | 367 |
371 SkASSERT(0 == offset % sizeof(uint16_t)); | 368 SkASSERT(0 == offset % sizeof(uint16_t)); |
372 *startIndex = static_cast<int>(offset / sizeof(uint16_t)); | 369 *startIndex = static_cast<int>(offset / sizeof(uint16_t)); |
373 return ptr; | 370 return ptr; |
374 } | 371 } |
OLD | NEW |