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" |
11 #include "GrDrawTargetCaps.h" | 11 #include "GrDrawTargetCaps.h" |
12 #include "GrGpu.h" | 12 #include "GrGpu.h" |
13 #include "GrIndexBuffer.h" | 13 #include "GrIndexBuffer.h" |
14 #include "GrTypes.h" | 14 #include "GrTypes.h" |
15 #include "GrVertexBuffer.h" | 15 #include "GrVertexBuffer.h" |
16 | 16 |
17 #if GR_DEBUG | 17 #if SK_DEBUG |
18 #define VALIDATE validate | 18 #define VALIDATE validate |
19 #else | 19 #else |
20 static void VALIDATE(bool = false) {} | 20 static void VALIDATE(bool = false) {} |
21 #endif | 21 #endif |
22 | 22 |
23 // page size | 23 // page size |
24 #define GrBufferAllocPool_MIN_BLOCK_SIZE ((size_t)1 << 12) | 24 #define GrBufferAllocPool_MIN_BLOCK_SIZE ((size_t)1 << 12) |
25 | 25 |
26 GrBufferAllocPool::GrBufferAllocPool(GrGpu* gpu, | 26 GrBufferAllocPool::GrBufferAllocPool(GrGpu* gpu, |
27 BufferType bufferType, | 27 BufferType bufferType, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 block.fBuffer->unlock(); | 110 block.fBuffer->unlock(); |
111 } else { | 111 } else { |
112 size_t flushSize = block.fBuffer->sizeInBytes() - block.fBytesFree; | 112 size_t flushSize = block.fBuffer->sizeInBytes() - block.fBytesFree; |
113 flushCpuData(fBlocks.back().fBuffer, flushSize); | 113 flushCpuData(fBlocks.back().fBuffer, flushSize); |
114 } | 114 } |
115 fBufferPtr = NULL; | 115 fBufferPtr = NULL; |
116 } | 116 } |
117 VALIDATE(); | 117 VALIDATE(); |
118 } | 118 } |
119 | 119 |
120 #if GR_DEBUG | 120 #if SK_DEBUG |
121 void GrBufferAllocPool::validate(bool unusedBlockAllowed) const { | 121 void GrBufferAllocPool::validate(bool unusedBlockAllowed) const { |
122 if (NULL != fBufferPtr) { | 122 if (NULL != fBufferPtr) { |
123 SkASSERT(!fBlocks.empty()); | 123 SkASSERT(!fBlocks.empty()); |
124 if (fBlocks.back().fBuffer->isLocked()) { | 124 if (fBlocks.back().fBuffer->isLocked()) { |
125 GrGeometryBuffer* buf = fBlocks.back().fBuffer; | 125 GrGeometryBuffer* buf = fBlocks.back().fBuffer; |
126 SkASSERT(buf->lockPtr() == fBufferPtr); | 126 SkASSERT(buf->lockPtr() == fBufferPtr); |
127 } else { | 127 } else { |
128 SkASSERT(fCpuData.get() == fBufferPtr); | 128 SkASSERT(fCpuData.get() == fBufferPtr); |
129 } | 129 } |
130 } else { | 130 } else { |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 } | 479 } |
480 } | 480 } |
481 | 481 |
482 int GrIndexBufferAllocPool::preallocatedBufferIndices() const { | 482 int GrIndexBufferAllocPool::preallocatedBufferIndices() const { |
483 return INHERITED::preallocatedBufferSize() / sizeof(uint16_t); | 483 return INHERITED::preallocatedBufferSize() / sizeof(uint16_t); |
484 } | 484 } |
485 | 485 |
486 int GrIndexBufferAllocPool::currentBufferIndices() const { | 486 int GrIndexBufferAllocPool::currentBufferIndices() const { |
487 return currentBufferItems(sizeof(uint16_t)); | 487 return currentBufferItems(sizeof(uint16_t)); |
488 } | 488 } |
OLD | NEW |