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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 } | 295 } |
296 | 296 |
297 GrAssert(NULL == fBufferPtr); | 297 GrAssert(NULL == fBufferPtr); |
298 | 298 |
299 // If the buffer is CPU-backed we lock it because it is free to do so and sa
ves a copy. | 299 // If the buffer is CPU-backed we lock it because it is free to do so and sa
ves a copy. |
300 // Otherwise when buffer locking is supported: | 300 // Otherwise when buffer locking is supported: |
301 // a) If the frequently reset hint is set we only lock when the request
ed size meets a | 301 // a) If the frequently reset hint is set we only lock when the request
ed size meets a |
302 // threshold (since we don't expect it is likely that we will see more
vertex data) | 302 // threshold (since we don't expect it is likely that we will see more
vertex data) |
303 // b) If the hint is not set we lock if the buffer size is greater than
the threshold. | 303 // b) If the hint is not set we lock if the buffer size is greater than
the threshold. |
304 bool attemptLock = block.fBuffer->isCPUBacked(); | 304 bool attemptLock = block.fBuffer->isCPUBacked(); |
305 if (!attemptLock && fGpu->getCaps().bufferLockSupport()) { | 305 if (!attemptLock && fGpu->caps()->bufferLockSupport()) { |
306 if (fFrequentResetHint) { | 306 if (fFrequentResetHint) { |
307 attemptLock = requestSize > GR_GEOM_BUFFER_LOCK_THRESHOLD; | 307 attemptLock = requestSize > GR_GEOM_BUFFER_LOCK_THRESHOLD; |
308 } else { | 308 } else { |
309 attemptLock = size > GR_GEOM_BUFFER_LOCK_THRESHOLD; | 309 attemptLock = size > GR_GEOM_BUFFER_LOCK_THRESHOLD; |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
313 if (attemptLock) { | 313 if (attemptLock) { |
314 fBufferPtr = block.fBuffer->lock(); | 314 fBufferPtr = block.fBuffer->lock(); |
315 } | 315 } |
(...skipping 27 matching lines...) Expand all Loading... |
343 } | 343 } |
344 | 344 |
345 void GrBufferAllocPool::flushCpuData(GrGeometryBuffer* buffer, | 345 void GrBufferAllocPool::flushCpuData(GrGeometryBuffer* buffer, |
346 size_t flushSize) { | 346 size_t flushSize) { |
347 GrAssert(NULL != buffer); | 347 GrAssert(NULL != buffer); |
348 GrAssert(!buffer->isLocked()); | 348 GrAssert(!buffer->isLocked()); |
349 GrAssert(fCpuData.get() == fBufferPtr); | 349 GrAssert(fCpuData.get() == fBufferPtr); |
350 GrAssert(flushSize <= buffer->sizeInBytes()); | 350 GrAssert(flushSize <= buffer->sizeInBytes()); |
351 VALIDATE(true); | 351 VALIDATE(true); |
352 | 352 |
353 if (fGpu->getCaps().bufferLockSupport() && | 353 if (fGpu->caps()->bufferLockSupport() && |
354 flushSize > GR_GEOM_BUFFER_LOCK_THRESHOLD) { | 354 flushSize > GR_GEOM_BUFFER_LOCK_THRESHOLD) { |
355 void* data = buffer->lock(); | 355 void* data = buffer->lock(); |
356 if (NULL != data) { | 356 if (NULL != data) { |
357 memcpy(data, fBufferPtr, flushSize); | 357 memcpy(data, fBufferPtr, flushSize); |
358 buffer->unlock(); | 358 buffer->unlock(); |
359 return; | 359 return; |
360 } | 360 } |
361 } | 361 } |
362 buffer->updateData(fBufferPtr, flushSize); | 362 buffer->updateData(fBufferPtr, flushSize); |
363 VALIDATE(true); | 363 VALIDATE(true); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 } | 478 } |
479 } | 479 } |
480 | 480 |
481 int GrIndexBufferAllocPool::preallocatedBufferIndices() const { | 481 int GrIndexBufferAllocPool::preallocatedBufferIndices() const { |
482 return INHERITED::preallocatedBufferSize() / sizeof(uint16_t); | 482 return INHERITED::preallocatedBufferSize() / sizeof(uint16_t); |
483 } | 483 } |
484 | 484 |
485 int GrIndexBufferAllocPool::currentBufferIndices() const { | 485 int GrIndexBufferAllocPool::currentBufferIndices() const { |
486 return currentBufferItems(sizeof(uint16_t)); | 486 return currentBufferItems(sizeof(uint16_t)); |
487 } | 487 } |
OLD | NEW |