| 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 int popCnt = fGeoSrcStateStack.count() - 1; | 119 int popCnt = fGeoSrcStateStack.count() - 1; |
| 120 while (popCnt) { | 120 while (popCnt) { |
| 121 this->popGeometrySource(); | 121 this->popGeometrySource(); |
| 122 --popCnt; | 122 --popCnt; |
| 123 } | 123 } |
| 124 this->resetVertexSource(); | 124 this->resetVertexSource(); |
| 125 this->resetIndexSource(); | 125 this->resetIndexSource(); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void GrDrawTarget::setClip(const GrClipData* clip) { | 128 void GrDrawTarget::setClip(const GrClipData* clip) { |
| 129 clipWillBeSet(clip); | |
| 130 fClip = clip; | 129 fClip = clip; |
| 131 } | 130 } |
| 132 | 131 |
| 133 const GrClipData* GrDrawTarget::getClip() const { | 132 const GrClipData* GrDrawTarget::getClip() const { |
| 134 return fClip; | 133 return fClip; |
| 135 } | 134 } |
| 136 | 135 |
| 137 void GrDrawTarget::setDrawState(GrDrawState* drawState) { | 136 void GrDrawTarget::setDrawState(GrDrawState* drawState) { |
| 138 SkASSERT(fDrawState); | 137 SkASSERT(fDrawState); |
| 139 if (NULL == drawState) { | 138 if (NULL == drawState) { |
| (...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 info.fIndexCount)) { | 750 info.fIndexCount)) { |
| 752 this->onDraw(info, scissorState); | 751 this->onDraw(info, scissorState); |
| 753 } | 752 } |
| 754 info.fStartVertex += info.fVertexCount; | 753 info.fStartVertex += info.fVertexCount; |
| 755 instanceCount -= info.fInstanceCount; | 754 instanceCount -= info.fInstanceCount; |
| 756 } | 755 } |
| 757 } | 756 } |
| 758 | 757 |
| 759 //////////////////////////////////////////////////////////////////////////////// | 758 //////////////////////////////////////////////////////////////////////////////// |
| 760 | 759 |
| 761 namespace { | |
| 762 | |
| 763 // position + (optional) texture coord | |
| 764 extern const GrVertexAttrib gBWRectPosUVAttribs[] = { | |
| 765 {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribBinding
}, | |
| 766 {kVec2f_GrVertexAttribType, sizeof(SkPoint), kLocalCoord_GrVertexAttribBindi
ng} | |
| 767 }; | |
| 768 | |
| 769 void set_vertex_attributes(GrDrawState* drawState, bool hasUVs) { | |
| 770 if (hasUVs) { | |
| 771 drawState->setVertexAttribs<gBWRectPosUVAttribs>(2, 2 * sizeof(SkPoint))
; | |
| 772 } else { | |
| 773 drawState->setVertexAttribs<gBWRectPosUVAttribs>(1, sizeof(SkPoint)); | |
| 774 } | |
| 775 } | |
| 776 | |
| 777 }; | |
| 778 | |
| 779 void GrDrawTarget::onDrawRect(const SkRect& rect, | |
| 780 const SkRect* localRect, | |
| 781 const SkMatrix* localMatrix) { | |
| 782 | |
| 783 set_vertex_attributes(this->drawState(), SkToBool(localRect)); | |
| 784 | |
| 785 AutoReleaseGeometry geo(this, 4, 0); | |
| 786 if (!geo.succeeded()) { | |
| 787 SkDebugf("Failed to get space for vertices!\n"); | |
| 788 return; | |
| 789 } | |
| 790 | |
| 791 size_t vstride = this->drawState()->getVertexStride(); | |
| 792 geo.positions()->setRectFan(rect.fLeft, rect.fTop, rect.fRight, rect.fBottom
, vstride); | |
| 793 if (localRect) { | |
| 794 SkPoint* coords = GrTCast<SkPoint*>(GrTCast<intptr_t>(geo.vertices()) + | |
| 795 sizeof(SkPoint)); | |
| 796 coords->setRectFan(localRect->fLeft, localRect->fTop, | |
| 797 localRect->fRight, localRect->fBottom, | |
| 798 vstride); | |
| 799 if (localMatrix) { | |
| 800 localMatrix->mapPointsWithStride(coords, vstride, 4); | |
| 801 } | |
| 802 } | |
| 803 SkRect bounds; | |
| 804 this->getDrawState().getViewMatrix().mapRect(&bounds, rect); | |
| 805 | |
| 806 this->drawNonIndexed(kTriangleFan_GrPrimitiveType, 0, 4, &bounds); | |
| 807 } | |
| 808 | |
| 809 void GrDrawTarget::clipWillBeSet(const GrClipData* clipData) { | |
| 810 } | |
| 811 | |
| 812 //////////////////////////////////////////////////////////////////////////////// | |
| 813 | |
| 814 GrDrawTarget::AutoStateRestore::AutoStateRestore() { | 760 GrDrawTarget::AutoStateRestore::AutoStateRestore() { |
| 815 fDrawTarget = NULL; | 761 fDrawTarget = NULL; |
| 816 } | 762 } |
| 817 | 763 |
| 818 GrDrawTarget::AutoStateRestore::AutoStateRestore(GrDrawTarget* target, | 764 GrDrawTarget::AutoStateRestore::AutoStateRestore(GrDrawTarget* target, |
| 819 ASRInit init, | 765 ASRInit init, |
| 820 const SkMatrix* vm) { | 766 const SkMatrix* vm) { |
| 821 fDrawTarget = NULL; | 767 fDrawTarget = NULL; |
| 822 this->set(target, init, vm); | 768 this->set(target, init, vm); |
| 823 } | 769 } |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1241 bool GrClipTarget::setupClip(const SkRect* devBounds, | 1187 bool GrClipTarget::setupClip(const SkRect* devBounds, |
| 1242 GrDrawState::AutoRestoreEffects* are, | 1188 GrDrawState::AutoRestoreEffects* are, |
| 1243 GrDrawState::AutoRestoreStencil* ars, | 1189 GrDrawState::AutoRestoreStencil* ars, |
| 1244 GrClipMaskManager::ScissorState* scissorState) { | 1190 GrClipMaskManager::ScissorState* scissorState) { |
| 1245 return fClipMaskManager.setupClipping(this->getClip(), | 1191 return fClipMaskManager.setupClipping(this->getClip(), |
| 1246 devBounds, | 1192 devBounds, |
| 1247 are, | 1193 are, |
| 1248 ars, | 1194 ars, |
| 1249 scissorState); | 1195 scissorState); |
| 1250 } | 1196 } |
| OLD | NEW |