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