| 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 "GrGpu.h" | 10 #include "GrGpu.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 indices[6 * i + 5] = 4 * i + 3; | 296 indices[6 * i + 5] = 4 * i + 3; |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 | 299 |
| 300 const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const { | 300 const GrIndexBuffer* GrGpu::getQuadIndexBuffer() const { |
| 301 if (NULL == fQuadIndexBuffer) { | 301 if (NULL == fQuadIndexBuffer) { |
| 302 static const int SIZE = sizeof(uint16_t) * 6 * MAX_QUADS; | 302 static const int SIZE = sizeof(uint16_t) * 6 * MAX_QUADS; |
| 303 GrGpu* me = const_cast<GrGpu*>(this); | 303 GrGpu* me = const_cast<GrGpu*>(this); |
| 304 fQuadIndexBuffer = me->createIndexBuffer(SIZE, false); | 304 fQuadIndexBuffer = me->createIndexBuffer(SIZE, false); |
| 305 if (NULL != fQuadIndexBuffer) { | 305 if (NULL != fQuadIndexBuffer) { |
| 306 uint16_t* indices = (uint16_t*)fQuadIndexBuffer->lock(); | 306 uint16_t* indices = (uint16_t*)fQuadIndexBuffer->map(); |
| 307 if (NULL != indices) { | 307 if (NULL != indices) { |
| 308 fill_indices(indices, MAX_QUADS); | 308 fill_indices(indices, MAX_QUADS); |
| 309 fQuadIndexBuffer->unlock(); | 309 fQuadIndexBuffer->unmap(); |
| 310 } else { | 310 } else { |
| 311 indices = (uint16_t*)sk_malloc_throw(SIZE); | 311 indices = (uint16_t*)sk_malloc_throw(SIZE); |
| 312 fill_indices(indices, MAX_QUADS); | 312 fill_indices(indices, MAX_QUADS); |
| 313 if (!fQuadIndexBuffer->updateData(indices, SIZE)) { | 313 if (!fQuadIndexBuffer->updateData(indices, SIZE)) { |
| 314 fQuadIndexBuffer->unref(); | 314 fQuadIndexBuffer->unref(); |
| 315 fQuadIndexBuffer = NULL; | 315 fQuadIndexBuffer = NULL; |
| 316 SkFAIL("Can't get indices into buffer!"); | 316 SkFAIL("Can't get indices into buffer!"); |
| 317 } | 317 } |
| 318 sk_free(indices); | 318 sk_free(indices); |
| 319 } | 319 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 GrDrawState::AutoRestoreEffects are; | 415 GrDrawState::AutoRestoreEffects are; |
| 416 if (!this->setupClipAndFlushState(kDrawPaths_DrawType, dstCopy, &are, NULL))
{ | 416 if (!this->setupClipAndFlushState(kDrawPaths_DrawType, dstCopy, &are, NULL))
{ |
| 417 return; | 417 return; |
| 418 } | 418 } |
| 419 | 419 |
| 420 this->onGpuDrawPaths(pathCount, paths, transforms, fill, style); | 420 this->onGpuDrawPaths(pathCount, paths, transforms, fill, style); |
| 421 } | 421 } |
| 422 | 422 |
| 423 void GrGpu::finalizeReservedVertices() { | 423 void GrGpu::finalizeReservedVertices() { |
| 424 SkASSERT(NULL != fVertexPool); | 424 SkASSERT(NULL != fVertexPool); |
| 425 fVertexPool->unlock(); | 425 fVertexPool->unmap(); |
| 426 } | 426 } |
| 427 | 427 |
| 428 void GrGpu::finalizeReservedIndices() { | 428 void GrGpu::finalizeReservedIndices() { |
| 429 SkASSERT(NULL != fIndexPool); | 429 SkASSERT(NULL != fIndexPool); |
| 430 fIndexPool->unlock(); | 430 fIndexPool->unmap(); |
| 431 } | 431 } |
| 432 | 432 |
| 433 void GrGpu::prepareVertexPool() { | 433 void GrGpu::prepareVertexPool() { |
| 434 if (NULL == fVertexPool) { | 434 if (NULL == fVertexPool) { |
| 435 SkASSERT(0 == fVertexPoolUseCnt); | 435 SkASSERT(0 == fVertexPoolUseCnt); |
| 436 fVertexPool = SkNEW_ARGS(GrVertexBufferAllocPool, (this, true, | 436 fVertexPool = SkNEW_ARGS(GrVertexBufferAllocPool, (this, true, |
| 437 VERTEX_POOL_VB_SIZE, | 437 VERTEX_POOL_VB_SIZE, |
| 438 VERTEX_POOL_VB_COUNT)); | 438 VERTEX_POOL_VB_COUNT)); |
| 439 fVertexPool->releaseGpuRef(); | 439 fVertexPool->releaseGpuRef(); |
| 440 } else if (!fVertexPoolUseCnt) { | 440 } else if (!fVertexPoolUseCnt) { |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 550 } | 550 } |
| 551 | 551 |
| 552 void GrGpu::releaseIndexArray() { | 552 void GrGpu::releaseIndexArray() { |
| 553 // if index source was array, we stowed data in the pool | 553 // if index source was array, we stowed data in the pool |
| 554 const GeometrySrcState& geoSrc = this->getGeomSrc(); | 554 const GeometrySrcState& geoSrc = this->getGeomSrc(); |
| 555 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); | 555 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); |
| 556 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); | 556 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); |
| 557 fIndexPool->putBack(bytes); | 557 fIndexPool->putBack(bytes); |
| 558 --fIndexPoolUseCnt; | 558 --fIndexPoolUseCnt; |
| 559 } | 559 } |
| OLD | NEW |