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 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 } | 280 } |
281 fBufferPtr = NULL; | 281 fBufferPtr = NULL; |
282 } | 282 } |
283 | 283 |
284 SkASSERT(NULL == fBufferPtr); | 284 SkASSERT(NULL == fBufferPtr); |
285 | 285 |
286 // If the buffer is CPU-backed we map it because it is free to do so and sav
es a copy. | 286 // If the buffer is CPU-backed we map it because it is free to do so and sav
es a copy. |
287 // Otherwise when buffer mapping is supported we map if the buffer size is g
reater than the | 287 // Otherwise when buffer mapping is supported we map if the buffer size is g
reater than the |
288 // threshold. | 288 // threshold. |
289 bool attemptMap = block.fBuffer->isCPUBacked(); | 289 bool attemptMap = block.fBuffer->isCPUBacked(); |
290 if (!attemptMap && GrDrawTargetCaps::kNone_MapFlags != fGpu->caps()->mapBuff
erFlags()) { | 290 if (!attemptMap && GrCaps::kNone_MapFlags != fGpu->caps()->mapBufferFlags())
{ |
291 attemptMap = size > GR_GEOM_BUFFER_MAP_THRESHOLD; | 291 attemptMap = size > GR_GEOM_BUFFER_MAP_THRESHOLD; |
292 } | 292 } |
293 | 293 |
294 if (attemptMap) { | 294 if (attemptMap) { |
295 fBufferPtr = block.fBuffer->map(); | 295 fBufferPtr = block.fBuffer->map(); |
296 } | 296 } |
297 | 297 |
298 if (NULL == fBufferPtr) { | 298 if (NULL == fBufferPtr) { |
299 fBufferPtr = fCpuData.reset(size); | 299 fBufferPtr = fCpuData.reset(size); |
300 } | 300 } |
(...skipping 23 matching lines...) Expand all Loading... |
324 } | 324 } |
325 | 325 |
326 void GrBufferAllocPool::flushCpuData(const BufferBlock& block, size_t flushSize)
{ | 326 void GrBufferAllocPool::flushCpuData(const BufferBlock& block, size_t flushSize)
{ |
327 GrGeometryBuffer* buffer = block.fBuffer; | 327 GrGeometryBuffer* buffer = block.fBuffer; |
328 SkASSERT(buffer); | 328 SkASSERT(buffer); |
329 SkASSERT(!buffer->isMapped()); | 329 SkASSERT(!buffer->isMapped()); |
330 SkASSERT(fCpuData.get() == fBufferPtr); | 330 SkASSERT(fCpuData.get() == fBufferPtr); |
331 SkASSERT(flushSize <= buffer->gpuMemorySize()); | 331 SkASSERT(flushSize <= buffer->gpuMemorySize()); |
332 VALIDATE(true); | 332 VALIDATE(true); |
333 | 333 |
334 if (GrDrawTargetCaps::kNone_MapFlags != fGpu->caps()->mapBufferFlags() && | 334 if (GrCaps::kNone_MapFlags != fGpu->caps()->mapBufferFlags() && |
335 flushSize > GR_GEOM_BUFFER_MAP_THRESHOLD) { | 335 flushSize > GR_GEOM_BUFFER_MAP_THRESHOLD) { |
336 void* data = buffer->map(); | 336 void* data = buffer->map(); |
337 if (data) { | 337 if (data) { |
338 memcpy(data, fBufferPtr, flushSize); | 338 memcpy(data, fBufferPtr, flushSize); |
339 UNMAP_BUFFER(block); | 339 UNMAP_BUFFER(block); |
340 return; | 340 return; |
341 } | 341 } |
342 } | 342 } |
343 buffer->updateData(fBufferPtr, flushSize); | 343 buffer->updateData(fBufferPtr, flushSize); |
344 VALIDATE(true); | 344 VALIDATE(true); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 &geomBuffer, | 412 &geomBuffer, |
413 &offset); | 413 &offset); |
414 | 414 |
415 *buffer = (const GrIndexBuffer*) geomBuffer; | 415 *buffer = (const GrIndexBuffer*) geomBuffer; |
416 SkASSERT(0 == offset % sizeof(uint16_t)); | 416 SkASSERT(0 == offset % sizeof(uint16_t)); |
417 *startIndex = static_cast<int>(offset / sizeof(uint16_t)); | 417 *startIndex = static_cast<int>(offset / sizeof(uint16_t)); |
418 return ptr; | 418 return ptr; |
419 } | 419 } |
420 | 420 |
421 | 421 |
OLD | NEW |