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 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 fIndicesPerInstance = di.fIndicesPerInstance; | 34 fIndicesPerInstance = di.fIndicesPerInstance; |
35 | 35 |
36 if (di.fDevBounds) { | 36 if (di.fDevBounds) { |
37 SkASSERT(di.fDevBounds == &di.fDevBoundsStorage); | 37 SkASSERT(di.fDevBounds == &di.fDevBoundsStorage); |
38 fDevBoundsStorage = di.fDevBoundsStorage; | 38 fDevBoundsStorage = di.fDevBoundsStorage; |
39 fDevBounds = &fDevBoundsStorage; | 39 fDevBounds = &fDevBoundsStorage; |
40 } else { | 40 } else { |
41 fDevBounds = NULL; | 41 fDevBounds = NULL; |
42 } | 42 } |
43 | 43 |
44 fDstCopy = di.fDstCopy; | |
45 | |
46 this->setVertexBuffer(di.vertexBuffer()); | 44 this->setVertexBuffer(di.vertexBuffer()); |
47 this->setIndexBuffer(di.indexBuffer()); | 45 this->setIndexBuffer(di.indexBuffer()); |
48 | 46 |
49 return *this; | 47 return *this; |
50 } | 48 } |
51 | 49 |
52 #ifdef SK_DEBUG | 50 #ifdef SK_DEBUG |
53 bool GrDrawTarget::DrawInfo::isInstanced() const { | 51 bool GrDrawTarget::DrawInfo::isInstanced() const { |
54 if (fInstanceCount > 0) { | 52 if (fInstanceCount > 0) { |
55 SkASSERT(0 == fIndexCount % fIndicesPerInstance); | 53 SkASSERT(0 == fIndexCount % fIndicesPerInstance); |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 info.fVertexCount = vertexCount; | 459 info.fVertexCount = vertexCount; |
462 info.fIndexCount = indexCount; | 460 info.fIndexCount = indexCount; |
463 | 461 |
464 info.fInstanceCount = 0; | 462 info.fInstanceCount = 0; |
465 info.fVerticesPerInstance = 0; | 463 info.fVerticesPerInstance = 0; |
466 info.fIndicesPerInstance = 0; | 464 info.fIndicesPerInstance = 0; |
467 | 465 |
468 if (devBounds) { | 466 if (devBounds) { |
469 info.setDevBounds(*devBounds); | 467 info.setDevBounds(*devBounds); |
470 } | 468 } |
| 469 |
471 // TODO: We should continue with incorrect blending. | 470 // TODO: We should continue with incorrect blending. |
472 if (!this->setupDstReadIfNecessary(ds, &info)) { | 471 GrDeviceCoordTexture dstCopy; |
| 472 if (!this->setupDstReadIfNecessary(ds, &dstCopy, devBounds)) { |
473 return; | 473 return; |
474 } | 474 } |
475 | |
476 this->setDrawBuffers(&info); | 475 this->setDrawBuffers(&info); |
477 | 476 |
478 this->onDraw(*ds, info, scissorState); | 477 this->onDraw(*ds, info, scissorState, dstCopy.texture() ? &dstCopy : NUL
L); |
479 } | 478 } |
480 } | 479 } |
481 | 480 |
482 void GrDrawTarget::drawNonIndexed(GrDrawState* ds, | 481 void GrDrawTarget::drawNonIndexed(GrDrawState* ds, |
483 GrPrimitiveType type, | 482 GrPrimitiveType type, |
484 int startVertex, | 483 int startVertex, |
485 int vertexCount, | 484 int vertexCount, |
486 const SkRect* devBounds) { | 485 const SkRect* devBounds) { |
487 SkASSERT(ds); | 486 SkASSERT(ds); |
488 if (vertexCount > 0 && this->checkDraw(*ds, type, startVertex, -1, vertexCou
nt, -1)) { | 487 if (vertexCount > 0 && this->checkDraw(*ds, type, startVertex, -1, vertexCou
nt, -1)) { |
(...skipping 15 matching lines...) Expand all Loading... |
504 | 503 |
505 info.fInstanceCount = 0; | 504 info.fInstanceCount = 0; |
506 info.fVerticesPerInstance = 0; | 505 info.fVerticesPerInstance = 0; |
507 info.fIndicesPerInstance = 0; | 506 info.fIndicesPerInstance = 0; |
508 | 507 |
509 if (devBounds) { | 508 if (devBounds) { |
510 info.setDevBounds(*devBounds); | 509 info.setDevBounds(*devBounds); |
511 } | 510 } |
512 | 511 |
513 // TODO: We should continue with incorrect blending. | 512 // TODO: We should continue with incorrect blending. |
514 if (!this->setupDstReadIfNecessary(ds, &info)) { | 513 GrDeviceCoordTexture dstCopy; |
| 514 if (!this->setupDstReadIfNecessary(ds, &dstCopy, devBounds)) { |
515 return; | 515 return; |
516 } | 516 } |
517 | 517 |
518 this->setDrawBuffers(&info); | 518 this->setDrawBuffers(&info); |
519 | 519 |
520 this->onDraw(*ds, info, scissorState); | 520 this->onDraw(*ds, info, scissorState, dstCopy.texture() ? &dstCopy : NUL
L); |
521 } | 521 } |
522 } | 522 } |
523 | 523 |
524 static const GrStencilSettings& winding_path_stencil_settings() { | 524 static const GrStencilSettings& winding_path_stencil_settings() { |
525 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, | 525 GR_STATIC_CONST_SAME_STENCIL_STRUCT(gSettings, |
526 kIncClamp_StencilOp, | 526 kIncClamp_StencilOp, |
527 kIncClamp_StencilOp, | 527 kIncClamp_StencilOp, |
528 kAlwaysIfInClip_StencilFunc, | 528 kAlwaysIfInClip_StencilFunc, |
529 0xFFFF, 0xFFFF, 0xFFFF); | 529 0xFFFF, 0xFFFF, 0xFFFF); |
530 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); | 530 return *GR_CONST_STENCIL_SETTINGS_PTR_FROM_STRUCT_PTR(&gSettings); |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 info.fPrimitiveType = type; | 752 info.fPrimitiveType = type; |
753 info.fStartIndex = 0; | 753 info.fStartIndex = 0; |
754 info.fStartVertex = 0; | 754 info.fStartVertex = 0; |
755 info.fIndicesPerInstance = indicesPerInstance; | 755 info.fIndicesPerInstance = indicesPerInstance; |
756 info.fVerticesPerInstance = verticesPerInstance; | 756 info.fVerticesPerInstance = verticesPerInstance; |
757 | 757 |
758 // Set the same bounds for all the draws. | 758 // Set the same bounds for all the draws. |
759 if (devBounds) { | 759 if (devBounds) { |
760 info.setDevBounds(*devBounds); | 760 info.setDevBounds(*devBounds); |
761 } | 761 } |
| 762 |
762 // TODO: We should continue with incorrect blending. | 763 // TODO: We should continue with incorrect blending. |
763 if (!this->setupDstReadIfNecessary(ds, &info)) { | 764 GrDeviceCoordTexture dstCopy; |
| 765 if (!this->setupDstReadIfNecessary(ds, &dstCopy, devBounds)) { |
764 return; | 766 return; |
765 } | 767 } |
766 | 768 |
767 while (instanceCount) { | 769 while (instanceCount) { |
768 info.fInstanceCount = SkTMin(instanceCount, maxInstancesPerDraw); | 770 info.fInstanceCount = SkTMin(instanceCount, maxInstancesPerDraw); |
769 info.fVertexCount = info.fInstanceCount * verticesPerInstance; | 771 info.fVertexCount = info.fInstanceCount * verticesPerInstance; |
770 info.fIndexCount = info.fInstanceCount * indicesPerInstance; | 772 info.fIndexCount = info.fInstanceCount * indicesPerInstance; |
771 | 773 |
772 this->setDrawBuffers(&info); | 774 this->setDrawBuffers(&info); |
773 | 775 |
774 if (this->checkDraw(*ds, | 776 if (this->checkDraw(*ds, |
775 type, | 777 type, |
776 info.fStartVertex, | 778 info.fStartVertex, |
777 info.fStartIndex, | 779 info.fStartIndex, |
778 info.fVertexCount, | 780 info.fVertexCount, |
779 info.fIndexCount)) { | 781 info.fIndexCount)) { |
780 this->onDraw(*ds, info, scissorState); | 782 this->onDraw(*ds, info, scissorState, dstCopy.texture() ? &dstCopy :
NULL); |
781 } | 783 } |
782 info.fStartVertex += info.fVertexCount; | 784 info.fStartVertex += info.fVertexCount; |
783 instanceCount -= info.fInstanceCount; | 785 instanceCount -= info.fInstanceCount; |
784 } | 786 } |
785 } | 787 } |
786 | 788 |
787 //////////////////////////////////////////////////////////////////////////////// | 789 //////////////////////////////////////////////////////////////////////////////// |
788 | 790 |
789 GrDrawTarget::AutoReleaseGeometry::AutoReleaseGeometry( | 791 GrDrawTarget::AutoReleaseGeometry::AutoReleaseGeometry( |
790 GrDrawTarget* target, | 792 GrDrawTarget* target, |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 GrDrawState::AutoRestoreStencil* ars, | 1153 GrDrawState::AutoRestoreStencil* ars, |
1152 GrDrawState* ds, | 1154 GrDrawState* ds, |
1153 GrClipMaskManager::ScissorState* scissorState) { | 1155 GrClipMaskManager::ScissorState* scissorState) { |
1154 return fClipMaskManager.setupClipping(ds, | 1156 return fClipMaskManager.setupClipping(ds, |
1155 are, | 1157 are, |
1156 ars, | 1158 ars, |
1157 scissorState, | 1159 scissorState, |
1158 this->getClip(), | 1160 this->getClip(), |
1159 devBounds); | 1161 devBounds); |
1160 } | 1162 } |
OLD | NEW |