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 22 matching lines...) Expand all Loading... |
33 , fResetBits(kAll_GrBackendState) | 33 , fResetBits(kAll_GrBackendState) |
34 , fVertexPool(NULL) | 34 , fVertexPool(NULL) |
35 , fIndexPool(NULL) | 35 , fIndexPool(NULL) |
36 , fVertexPoolUseCnt(0) | 36 , fVertexPoolUseCnt(0) |
37 , fIndexPoolUseCnt(0) | 37 , fIndexPoolUseCnt(0) |
38 , fQuadIndexBuffer(NULL) { | 38 , fQuadIndexBuffer(NULL) { |
39 | 39 |
40 fClipMaskManager.setGpu(this); | 40 fClipMaskManager.setGpu(this); |
41 | 41 |
42 fGeomPoolStateStack.push_back(); | 42 fGeomPoolStateStack.push_back(); |
43 #if GR_DEBUG | 43 #if SK_DEBUG |
44 GeometryPoolState& poolState = fGeomPoolStateStack.back(); | 44 GeometryPoolState& poolState = fGeomPoolStateStack.back(); |
45 poolState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; | 45 poolState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; |
46 poolState.fPoolStartVertex = DEBUG_INVAL_START_IDX; | 46 poolState.fPoolStartVertex = DEBUG_INVAL_START_IDX; |
47 poolState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER; | 47 poolState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER; |
48 poolState.fPoolStartIndex = DEBUG_INVAL_START_IDX; | 48 poolState.fPoolStartIndex = DEBUG_INVAL_START_IDX; |
49 #endif | 49 #endif |
50 | 50 |
51 for (int i = 0; i < kGrPixelConfigCnt; ++i) { | 51 for (int i = 0; i < kGrPixelConfigCnt; ++i) { |
52 fConfigRenderSupport[i] = false; | 52 fConfigRenderSupport[i] = false; |
53 }; | 53 }; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 | 98 |
99 void GrGpu::removeResource(GrResource* resource) { | 99 void GrGpu::removeResource(GrResource* resource) { |
100 SkASSERT(NULL != resource); | 100 SkASSERT(NULL != resource); |
101 SkASSERT(this == resource->getGpu()); | 101 SkASSERT(this == resource->getGpu()); |
102 | 102 |
103 fResourceList.remove(resource); | 103 fResourceList.remove(resource); |
104 } | 104 } |
105 | 105 |
106 | 106 |
107 void GrGpu::unimpl(const char msg[]) { | 107 void GrGpu::unimpl(const char msg[]) { |
108 #if GR_DEBUG | 108 #if SK_DEBUG |
109 GrPrintf("--- GrGpu unimplemented(\"%s\")\n", msg); | 109 GrPrintf("--- GrGpu unimplemented(\"%s\")\n", msg); |
110 #endif | 110 #endif |
111 } | 111 } |
112 | 112 |
113 //////////////////////////////////////////////////////////////////////////////// | 113 //////////////////////////////////////////////////////////////////////////////// |
114 | 114 |
115 GrTexture* GrGpu::createTexture(const GrTextureDesc& desc, | 115 GrTexture* GrGpu::createTexture(const GrTextureDesc& desc, |
116 const void* srcData, size_t rowBytes) { | 116 const void* srcData, size_t rowBytes) { |
117 if (kUnknown_GrPixelConfig == desc.fConfig) { | 117 if (kUnknown_GrPixelConfig == desc.fConfig) { |
118 return NULL; | 118 return NULL; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 const GeometrySrcState& geoSrc = this->getGeomSrc(); | 312 const GeometrySrcState& geoSrc = this->getGeomSrc(); |
313 if (kArray_GeometrySrcType == geoSrc.fVertexSrc || | 313 if (kArray_GeometrySrcType == geoSrc.fVertexSrc || |
314 kReserved_GeometrySrcType == geoSrc.fVertexSrc) { | 314 kReserved_GeometrySrcType == geoSrc.fVertexSrc) { |
315 this->finalizeReservedVertices(); | 315 this->finalizeReservedVertices(); |
316 } | 316 } |
317 if (kArray_GeometrySrcType == geoSrc.fIndexSrc || | 317 if (kArray_GeometrySrcType == geoSrc.fIndexSrc || |
318 kReserved_GeometrySrcType == geoSrc.fIndexSrc) { | 318 kReserved_GeometrySrcType == geoSrc.fIndexSrc) { |
319 this->finalizeReservedIndices(); | 319 this->finalizeReservedIndices(); |
320 } | 320 } |
321 GeometryPoolState& newState = fGeomPoolStateStack.push_back(); | 321 GeometryPoolState& newState = fGeomPoolStateStack.push_back(); |
322 #if GR_DEBUG | 322 #if SK_DEBUG |
323 newState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; | 323 newState.fPoolVertexBuffer = (GrVertexBuffer*)DEBUG_INVAL_BUFFER; |
324 newState.fPoolStartVertex = DEBUG_INVAL_START_IDX; | 324 newState.fPoolStartVertex = DEBUG_INVAL_START_IDX; |
325 newState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER; | 325 newState.fPoolIndexBuffer = (GrIndexBuffer*)DEBUG_INVAL_BUFFER; |
326 newState.fPoolStartIndex = DEBUG_INVAL_START_IDX; | 326 newState.fPoolStartIndex = DEBUG_INVAL_START_IDX; |
327 #else | 327 #else |
328 (void) newState; // silence compiler warning | 328 (void) newState; // silence compiler warning |
329 #endif | 329 #endif |
330 } | 330 } |
331 | 331 |
332 void GrGpu::geometrySourceWillPop(const GeometrySrcState& restoredState) { | 332 void GrGpu::geometrySourceWillPop(const GeometrySrcState& restoredState) { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 const GeometrySrcState& geoSrc = this->getGeomSrc(); | 448 const GeometrySrcState& geoSrc = this->getGeomSrc(); |
449 SkASSERT(kReserved_GeometrySrcType == geoSrc.fIndexSrc); | 449 SkASSERT(kReserved_GeometrySrcType == geoSrc.fIndexSrc); |
450 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); | 450 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); |
451 fIndexPool->putBack(bytes); | 451 fIndexPool->putBack(bytes); |
452 --fIndexPoolUseCnt; | 452 --fIndexPoolUseCnt; |
453 } | 453 } |
454 | 454 |
455 void GrGpu::onSetVertexSourceToArray(const void* vertexArray, int vertexCount) { | 455 void GrGpu::onSetVertexSourceToArray(const void* vertexArray, int vertexCount) { |
456 this->prepareVertexPool(); | 456 this->prepareVertexPool(); |
457 GeometryPoolState& geomPoolState = fGeomPoolStateStack.back(); | 457 GeometryPoolState& geomPoolState = fGeomPoolStateStack.back(); |
458 #if GR_DEBUG | 458 #if SK_DEBUG |
459 bool success = | 459 bool success = |
460 #endif | 460 #endif |
461 fVertexPool->appendVertices(this->getVertexSize(), | 461 fVertexPool->appendVertices(this->getVertexSize(), |
462 vertexCount, | 462 vertexCount, |
463 vertexArray, | 463 vertexArray, |
464 &geomPoolState.fPoolVertexBuffer, | 464 &geomPoolState.fPoolVertexBuffer, |
465 &geomPoolState.fPoolStartVertex); | 465 &geomPoolState.fPoolStartVertex); |
466 ++fVertexPoolUseCnt; | 466 ++fVertexPoolUseCnt; |
467 GR_DEBUGASSERT(success); | 467 GR_DEBUGASSERT(success); |
468 } | 468 } |
469 | 469 |
470 void GrGpu::onSetIndexSourceToArray(const void* indexArray, int indexCount) { | 470 void GrGpu::onSetIndexSourceToArray(const void* indexArray, int indexCount) { |
471 this->prepareIndexPool(); | 471 this->prepareIndexPool(); |
472 GeometryPoolState& geomPoolState = fGeomPoolStateStack.back(); | 472 GeometryPoolState& geomPoolState = fGeomPoolStateStack.back(); |
473 #if GR_DEBUG | 473 #if SK_DEBUG |
474 bool success = | 474 bool success = |
475 #endif | 475 #endif |
476 fIndexPool->appendIndices(indexCount, | 476 fIndexPool->appendIndices(indexCount, |
477 indexArray, | 477 indexArray, |
478 &geomPoolState.fPoolIndexBuffer, | 478 &geomPoolState.fPoolIndexBuffer, |
479 &geomPoolState.fPoolStartIndex); | 479 &geomPoolState.fPoolStartIndex); |
480 ++fIndexPoolUseCnt; | 480 ++fIndexPoolUseCnt; |
481 GR_DEBUGASSERT(success); | 481 GR_DEBUGASSERT(success); |
482 } | 482 } |
483 | 483 |
484 void GrGpu::releaseVertexArray() { | 484 void GrGpu::releaseVertexArray() { |
485 // if vertex source was array, we stowed data in the pool | 485 // if vertex source was array, we stowed data in the pool |
486 const GeometrySrcState& geoSrc = this->getGeomSrc(); | 486 const GeometrySrcState& geoSrc = this->getGeomSrc(); |
487 SkASSERT(kArray_GeometrySrcType == geoSrc.fVertexSrc); | 487 SkASSERT(kArray_GeometrySrcType == geoSrc.fVertexSrc); |
488 size_t bytes = geoSrc.fVertexCount * geoSrc.fVertexSize; | 488 size_t bytes = geoSrc.fVertexCount * geoSrc.fVertexSize; |
489 fVertexPool->putBack(bytes); | 489 fVertexPool->putBack(bytes); |
490 --fVertexPoolUseCnt; | 490 --fVertexPoolUseCnt; |
491 } | 491 } |
492 | 492 |
493 void GrGpu::releaseIndexArray() { | 493 void GrGpu::releaseIndexArray() { |
494 // if index source was array, we stowed data in the pool | 494 // if index source was array, we stowed data in the pool |
495 const GeometrySrcState& geoSrc = this->getGeomSrc(); | 495 const GeometrySrcState& geoSrc = this->getGeomSrc(); |
496 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); | 496 SkASSERT(kArray_GeometrySrcType == geoSrc.fIndexSrc); |
497 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); | 497 size_t bytes = geoSrc.fIndexCount * sizeof(uint16_t); |
498 fIndexPool->putBack(bytes); | 498 fIndexPool->putBack(bytes); |
499 --fIndexPoolUseCnt; | 499 --fIndexPoolUseCnt; |
500 } | 500 } |
OLD | NEW |