| 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 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 583 info.fIndexCount)) { | 583 info.fIndexCount)) { |
| 584 this->onDraw(info); | 584 this->onDraw(info); |
| 585 } | 585 } |
| 586 info.fStartVertex += info.fVertexCount; | 586 info.fStartVertex += info.fVertexCount; |
| 587 instanceCount -= info.fInstanceCount; | 587 instanceCount -= info.fInstanceCount; |
| 588 } | 588 } |
| 589 } | 589 } |
| 590 | 590 |
| 591 //////////////////////////////////////////////////////////////////////////////// | 591 //////////////////////////////////////////////////////////////////////////////// |
| 592 | 592 |
| 593 namespace { |
| 594 |
| 595 // position + (optional) texture coord |
| 596 extern const GrVertexAttrib gBWRectPosUVAttribs[] = { |
| 597 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding
}, |
| 598 {kVec2f_GrVertexAttribType, sizeof(GrPoint), kLocalCoord_GrVertexAttribBindi
ng} |
| 599 }; |
| 600 |
| 601 void set_vertex_attributes(GrDrawState* drawState, bool hasUVs) { |
| 602 if (hasUVs) { |
| 603 drawState->setVertexAttribs<gBWRectPosUVAttribs>(2); |
| 604 } else { |
| 605 drawState->setVertexAttribs<gBWRectPosUVAttribs>(1); |
| 606 } |
| 607 } |
| 608 |
| 609 }; |
| 610 |
| 593 void GrDrawTarget::onDrawRect(const GrRect& rect, | 611 void GrDrawTarget::onDrawRect(const GrRect& rect, |
| 594 const SkMatrix* matrix, | 612 const SkMatrix* matrix, |
| 595 const GrRect* localRect, | 613 const GrRect* localRect, |
| 596 const SkMatrix* localMatrix) { | 614 const SkMatrix* localMatrix) { |
| 597 // position + (optional) texture coord | |
| 598 static const GrVertexAttrib kAttribs[] = { | |
| 599 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBin
ding}, | |
| 600 {kVec2f_GrVertexAttribType, sizeof(GrPoint), kLocalCoord_GrVertexAttribB
inding} | |
| 601 }; | |
| 602 int attribCount = 1; | |
| 603 | |
| 604 if (NULL != localRect) { | |
| 605 attribCount = 2; | |
| 606 } | |
| 607 | 615 |
| 608 GrDrawState::AutoViewMatrixRestore avmr; | 616 GrDrawState::AutoViewMatrixRestore avmr; |
| 609 if (NULL != matrix) { | 617 if (NULL != matrix) { |
| 610 avmr.set(this->drawState(), *matrix); | 618 avmr.set(this->drawState(), *matrix); |
| 611 } | 619 } |
| 612 | 620 |
| 613 this->drawState()->setVertexAttribs(kAttribs, attribCount); | 621 set_vertex_attributes(this->drawState(), NULL != localRect); |
| 622 |
| 614 AutoReleaseGeometry geo(this, 4, 0); | 623 AutoReleaseGeometry geo(this, 4, 0); |
| 615 if (!geo.succeeded()) { | 624 if (!geo.succeeded()) { |
| 616 GrPrintf("Failed to get space for vertices!\n"); | 625 GrPrintf("Failed to get space for vertices!\n"); |
| 617 return; | 626 return; |
| 618 } | 627 } |
| 619 | 628 |
| 620 size_t vsize = this->drawState()->getVertexSize(); | 629 size_t vsize = this->drawState()->getVertexSize(); |
| 621 geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom
, vsize); | 630 geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom
, vsize); |
| 622 if (NULL != localRect) { | 631 if (NULL != localRect) { |
| 623 GrAssert(attribCount == 2); | |
| 624 GrPoint* coords = GrTCast<GrPoint*>(GrTCast<intptr_t>(geo.vertices()) + | 632 GrPoint* coords = GrTCast<GrPoint*>(GrTCast<intptr_t>(geo.vertices()) + |
| 625 kAttribs[1].fOffset); | 633 sizeof(GrPoint)); |
| 626 coords->setRectFan(localRect->fLeft, localRect->fTop, | 634 coords->setRectFan(localRect->fLeft, localRect->fTop, |
| 627 localRect->fRight, localRect->fBottom, | 635 localRect->fRight, localRect->fBottom, |
| 628 vsize); | 636 vsize); |
| 629 if (NULL != localMatrix) { | 637 if (NULL != localMatrix) { |
| 630 localMatrix->mapPointsWithStride(coords, vsize, 4); | 638 localMatrix->mapPointsWithStride(coords, vsize, 4); |
| 631 } | 639 } |
| 632 } | 640 } |
| 633 SkTLazy<SkRect> bounds; | 641 SkTLazy<SkRect> bounds; |
| 634 if (this->getDrawState().willEffectReadDst()) { | 642 if (this->getDrawState().willEffectReadDst()) { |
| 635 bounds.init(); | 643 bounds.init(); |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 GrPrintf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]); | 943 GrPrintf("HW AA Lines Support : %s\n", gNY[fHWAALineSupport]); |
| 936 GrPrintf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSupport]
); | 944 GrPrintf("Shader Derivative Support : %s\n", gNY[fShaderDerivativeSupport]
); |
| 937 GrPrintf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]); | 945 GrPrintf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSupport]); |
| 938 GrPrintf("Dual Source Blending Support: %s\n", gNY[fDualSourceBlendingSuppor
t]); | 946 GrPrintf("Dual Source Blending Support: %s\n", gNY[fDualSourceBlendingSuppor
t]); |
| 939 GrPrintf("Buffer Lock Support : %s\n", gNY[fBufferLockSupport]); | 947 GrPrintf("Buffer Lock Support : %s\n", gNY[fBufferLockSupport]); |
| 940 GrPrintf("Path Stenciling Support : %s\n", gNY[fPathStencilingSupport]); | 948 GrPrintf("Path Stenciling Support : %s\n", gNY[fPathStencilingSupport]); |
| 941 GrPrintf("Max Texture Size : %d\n", fMaxTextureSize); | 949 GrPrintf("Max Texture Size : %d\n", fMaxTextureSize); |
| 942 GrPrintf("Max Render Target Size : %d\n", fMaxRenderTargetSize); | 950 GrPrintf("Max Render Target Size : %d\n", fMaxRenderTargetSize); |
| 943 GrPrintf("Max Sample Count : %d\n", fMaxSampleCount); | 951 GrPrintf("Max Sample Count : %d\n", fMaxSampleCount); |
| 944 } | 952 } |
| OLD | NEW |