OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrRODrawState.h" | 8 #include "GrRODrawState.h" |
9 #include "GrDrawTargetCaps.h" | 9 #include "GrDrawTargetCaps.h" |
10 | 10 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 slTypes[i] = static_cast<GrSLType>(-1); | 79 slTypes[i] = static_cast<GrSLType>(-1); |
80 } | 80 } |
81 | 81 |
82 if (this->hasGeometryProcessor()) { | 82 if (this->hasGeometryProcessor()) { |
83 const GrEffectStage& stage = *this->getGeometryProcessor(); | 83 const GrEffectStage& stage = *this->getGeometryProcessor(); |
84 const GrEffect* effect = stage.getEffect(); | 84 const GrEffect* effect = stage.getEffect(); |
85 SkASSERT(effect); | 85 SkASSERT(effect); |
86 // make sure that any attribute indices have the correct binding type, t
hat the attrib | 86 // make sure that any attribute indices have the correct binding type, t
hat the attrib |
87 // type and effect's shader lang type are compatible, and that attribute
s shared by | 87 // type and effect's shader lang type are compatible, and that attribute
s shared by |
88 // multiple effects use the same shader lang type. | 88 // multiple effects use the same shader lang type. |
89 const int* attributeIndices = stage.getVertexAttribIndices(); | 89 const GrEffect::VertexAttribArray& s = effect->getVertexAttribs(); |
90 int numAttributes = stage.getVertexAttribIndexCount(); | 90 |
91 for (int i = 0; i < numAttributes; ++i) { | 91 const int effectAttribCount = s.count(); |
92 int attribIndex = attributeIndices[i]; | 92 int effectIndex = 0; |
93 if (attribIndex >= fVACount || | 93 for (int index = 0; index < fVACount; index++) { |
94 kEffect_GrVertexAttribBinding != fVAPtr[attribIndex].fBinding) { | 94 if (kEffect_GrVertexAttribBinding != fVAPtr[index].fBinding) { |
95 return false; | 95 // we only care about effect bindings |
| 96 continue; |
96 } | 97 } |
97 | 98 SkASSERT(effectIndex < effectAttribCount); |
98 GrSLType effectSLType = effect->vertexAttribType(i); | 99 GrSLType effectSLType = s[effectIndex].getType(); |
99 GrVertexAttribType attribType = fVAPtr[attribIndex].fType; | 100 GrVertexAttribType attribType = fVAPtr[index].fType; |
100 int slVecCount = GrSLTypeVectorCount(effectSLType); | 101 int slVecCount = GrSLTypeVectorCount(effectSLType); |
101 int attribVecCount = GrVertexAttribTypeVectorCount(attribType); | 102 int attribVecCount = GrVertexAttribTypeVectorCount(attribType); |
102 if (slVecCount != attribVecCount || | 103 if (slVecCount != attribVecCount || |
103 (static_cast<GrSLType>(-1) != slTypes[attribIndex] && | 104 (static_cast<GrSLType>(-1) != slTypes[index] && slTypes[index] !
= effectSLType)) { |
104 slTypes[attribIndex] != effectSLType)) { | |
105 return false; | 105 return false; |
106 } | 106 } |
107 slTypes[attribIndex] = effectSLType; | 107 slTypes[index] = effectSLType; |
| 108 effectIndex++; |
108 } | 109 } |
| 110 // Make sure all attributes are consumed and we were able to find everyt
hing |
| 111 SkASSERT(effectAttribCount == effectIndex); |
109 } | 112 } |
110 | 113 |
111 return true; | 114 return true; |
112 } | 115 } |
113 | 116 |
114 bool GrRODrawState::hasSolidCoverage() const { | 117 bool GrRODrawState::hasSolidCoverage() const { |
115 // If we're drawing coverage directly then coverage is effectively treated a
s color. | 118 // If we're drawing coverage directly then coverage is effectively treated a
s color. |
116 if (this->isCoverageDrawing()) { | 119 if (this->isCoverageDrawing()) { |
117 return true; | 120 return true; |
118 } | 121 } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 for (int i = 0; i < fColorStages.count(); ++i) { | 193 for (int i = 0; i < fColorStages.count(); ++i) { |
191 fColorStages[i].convertToPendingExec(); | 194 fColorStages[i].convertToPendingExec(); |
192 } | 195 } |
193 if (fGeometryProcessor) { | 196 if (fGeometryProcessor) { |
194 fGeometryProcessor->convertToPendingExec(); | 197 fGeometryProcessor->convertToPendingExec(); |
195 } | 198 } |
196 for (int i = 0; i < fCoverageStages.count(); ++i) { | 199 for (int i = 0; i < fCoverageStages.count(); ++i) { |
197 fCoverageStages[i].convertToPendingExec(); | 200 fCoverageStages[i].convertToPendingExec(); |
198 } | 201 } |
199 } | 202 } |
OLD | NEW |