| 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 | 9 |
| 10 #include "GrDrawTargetCaps.h" | 10 #include "GrDrawTargetCaps.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 slTypes[i] = static_cast<GrSLType>(-1); | 86 slTypes[i] = static_cast<GrSLType>(-1); |
| 87 } | 87 } |
| 88 | 88 |
| 89 if (this->hasGeometryProcessor()) { | 89 if (this->hasGeometryProcessor()) { |
| 90 const GrEffectStage& stage = *this->getGeometryProcessor(); | 90 const GrEffectStage& stage = *this->getGeometryProcessor(); |
| 91 const GrEffect* effect = stage.getEffect(); | 91 const GrEffect* effect = stage.getEffect(); |
| 92 SkASSERT(effect); | 92 SkASSERT(effect); |
| 93 // make sure that any attribute indices have the correct binding type, t
hat the attrib | 93 // make sure that any attribute indices have the correct binding type, t
hat the attrib |
| 94 // type and effect's shader lang type are compatible, and that attribute
s shared by | 94 // type and effect's shader lang type are compatible, and that attribute
s shared by |
| 95 // multiple effects use the same shader lang type. | 95 // multiple effects use the same shader lang type. |
| 96 const int* attributeIndices = stage.getVertexAttribIndices(); | 96 const GrEffect::VertexAttribArray& s = effect->getVertexAttribs(); |
| 97 int numAttributes = stage.getVertexAttribIndexCount(); | 97 |
| 98 for (int i = 0; i < numAttributes; ++i) { | 98 int effectIndex = 0; |
| 99 int attribIndex = attributeIndices[i]; | 99 for (int index = 0; index < fVACount; index++) { |
| 100 if (attribIndex >= fVACount || | 100 if (kEffect_GrVertexAttribBinding != fVAPtr[index].fBinding) { |
| 101 kEffect_GrVertexAttribBinding != fVAPtr[attribIndex].fBinding) { | 101 // we only care about effect bindings |
| 102 return false; | 102 continue; |
| 103 } | 103 } |
| 104 | 104 SkASSERT(effectIndex < s.count()); |
| 105 GrSLType effectSLType = effect->vertexAttribType(i); | 105 GrSLType effectSLType = s[effectIndex].getType(); |
| 106 GrVertexAttribType attribType = fVAPtr[attribIndex].fType; | 106 GrVertexAttribType attribType = fVAPtr[index].fType; |
| 107 int slVecCount = GrSLTypeVectorCount(effectSLType); | 107 int slVecCount = GrSLTypeVectorCount(effectSLType); |
| 108 int attribVecCount = GrVertexAttribTypeVectorCount(attribType); | 108 int attribVecCount = GrVertexAttribTypeVectorCount(attribType); |
| 109 if (slVecCount != attribVecCount || | 109 if (slVecCount != attribVecCount || |
| 110 (static_cast<GrSLType>(-1) != slTypes[attribIndex] && | 110 (static_cast<GrSLType>(-1) != slTypes[index] && slTypes[index] !
= effectSLType)) { |
| 111 slTypes[attribIndex] != effectSLType)) { | |
| 112 return false; | 111 return false; |
| 113 } | 112 } |
| 114 slTypes[attribIndex] = effectSLType; | 113 slTypes[index] = effectSLType; |
| 114 effectIndex++; |
| 115 } | 115 } |
| 116 // Make sure all attributes are consumed and we were able to find everyt
hing |
| 117 SkASSERT(s.count() == effectIndex); |
| 116 } | 118 } |
| 117 | 119 |
| 118 return true; | 120 return true; |
| 119 } | 121 } |
| 120 | 122 |
| 121 bool GrRODrawState::hasSolidCoverage() const { | 123 bool GrRODrawState::hasSolidCoverage() const { |
| 122 // If we're drawing coverage directly then coverage is effectively treated a
s color. | 124 // If we're drawing coverage directly then coverage is effectively treated a
s color. |
| 123 if (this->isCoverageDrawing()) { | 125 if (this->isCoverageDrawing()) { |
| 124 return true; | 126 return true; |
| 125 } | 127 } |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 //////////////////////////////////////////////////////////////////////////////// | 375 //////////////////////////////////////////////////////////////////////////////// |
| 374 | 376 |
| 375 bool GrRODrawState::canIgnoreColorAttribute() const { | 377 bool GrRODrawState::canIgnoreColorAttribute() const { |
| 376 if (fBlendOptFlags & kInvalid_BlendOptFlag) { | 378 if (fBlendOptFlags & kInvalid_BlendOptFlag) { |
| 377 this->getBlendOpts(); | 379 this->getBlendOpts(); |
| 378 } | 380 } |
| 379 return SkToBool(fBlendOptFlags & (GrRODrawState::kEmitTransBlack_BlendOptFla
g | | 381 return SkToBool(fBlendOptFlags & (GrRODrawState::kEmitTransBlack_BlendOptFla
g | |
| 380 GrRODrawState::kEmitCoverage_BlendOptFlag)
); | 382 GrRODrawState::kEmitCoverage_BlendOptFlag)
); |
| 381 } | 383 } |
| 382 | 384 |
| OLD | NEW |