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

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

Issue 216503004: SK_SUPPORT_LEGACY_GRTYPES to hide duplicate types from SkTypes.h (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 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
OLDNEW
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 10 matching lines...) Expand all
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,
28 bool frequentResetHint, 28 bool frequentResetHint,
29 size_t blockSize, 29 size_t blockSize,
30 int preallocBufferCnt) : 30 int preallocBufferCnt) :
31 fBlocks(GrMax(8, 2*preallocBufferCnt)) { 31 fBlocks(SkTMax(8, 2*preallocBufferCnt)) {
32 32
33 SkASSERT(NULL != gpu); 33 SkASSERT(NULL != gpu);
34 fGpu = gpu; 34 fGpu = gpu;
35 fGpu->ref(); 35 fGpu->ref();
36 fGpuIsReffed = true; 36 fGpuIsReffed = true;
37 37
38 fBufferType = bufferType; 38 fBufferType = bufferType;
39 fFrequentResetHint = frequentResetHint; 39 fFrequentResetHint = frequentResetHint;
40 fBufferPtr = NULL; 40 fBufferPtr = NULL;
41 fMinBlockSize = GrMax(GrBufferAllocPool_MIN_BLOCK_SIZE, blockSize); 41 fMinBlockSize = SkTMax(GrBufferAllocPool_MIN_BLOCK_SIZE, blockSize);
42 42
43 fBytesInUse = 0; 43 fBytesInUse = 0;
44 44
45 fPreallocBuffersInUse = 0; 45 fPreallocBuffersInUse = 0;
46 fPreallocBufferStartIdx = 0; 46 fPreallocBufferStartIdx = 0;
47 for (int i = 0; i < preallocBufferCnt; ++i) { 47 for (int i = 0; i < preallocBufferCnt; ++i) {
48 GrGeometryBuffer* buffer = this->createBuffer(fMinBlockSize); 48 GrGeometryBuffer* buffer = this->createBuffer(fMinBlockSize);
49 if (NULL != buffer) { 49 if (NULL != buffer) {
50 *fPreallocBuffers.append() = buffer; 50 *fPreallocBuffers.append() = buffer;
51 } 51 }
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 if (!fPreallocBuffersInUse && fPreallocBuffers.count()) { 251 if (!fPreallocBuffersInUse && fPreallocBuffers.count()) {
252 fPreallocBufferStartIdx = (fPreallocBufferStartIdx + 252 fPreallocBufferStartIdx = (fPreallocBufferStartIdx +
253 preallocBuffersInUse) % 253 preallocBuffersInUse) %
254 fPreallocBuffers.count(); 254 fPreallocBuffers.count();
255 } 255 }
256 VALIDATE(); 256 VALIDATE();
257 } 257 }
258 258
259 bool GrBufferAllocPool::createBlock(size_t requestSize) { 259 bool GrBufferAllocPool::createBlock(size_t requestSize) {
260 260
261 size_t size = GrMax(requestSize, fMinBlockSize); 261 size_t size = SkTMax(requestSize, fMinBlockSize);
262 SkASSERT(size >= GrBufferAllocPool_MIN_BLOCK_SIZE); 262 SkASSERT(size >= GrBufferAllocPool_MIN_BLOCK_SIZE);
263 263
264 VALIDATE(); 264 VALIDATE();
265 265
266 BufferBlock& block = fBlocks.push_back(); 266 BufferBlock& block = fBlocks.push_back();
267 267
268 if (size == fMinBlockSize && 268 if (size == fMinBlockSize &&
269 fPreallocBuffersInUse < fPreallocBuffers.count()) { 269 fPreallocBuffersInUse < fPreallocBuffers.count()) {
270 270
271 uint32_t nextBuffer = (fPreallocBuffersInUse + 271 uint32_t nextBuffer = (fPreallocBuffersInUse +
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 479 }
480 } 480 }
481 481
482 int GrIndexBufferAllocPool::preallocatedBufferIndices() const { 482 int GrIndexBufferAllocPool::preallocatedBufferIndices() const {
483 return static_cast<int>(INHERITED::preallocatedBufferSize() / sizeof(uint16_ t)); 483 return static_cast<int>(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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698