| 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 const int effectAttribCount = s.count(); |
| 99 int attribIndex = attributeIndices[i]; | 99 int effectIndex = 0; |
| 100 if (attribIndex >= fVACount || | 100 for (int index = 0; index < fVACount; index++) { |
| 101 kEffect_GrVertexAttribBinding != fVAPtr[attribIndex].fBinding) { | 101 if (kEffect_GrVertexAttribBinding != fVAPtr[index].fBinding) { |
| 102 return false; | 102 // we only care about effect bindings |
| 103 continue; |
| 103 } | 104 } |
| 104 | 105 SkASSERT(effectIndex < effectAttribCount); |
| 105 GrSLType effectSLType = effect->vertexAttribType(i); | 106 GrSLType effectSLType = s[effectIndex].getType(); |
| 106 GrVertexAttribType attribType = fVAPtr[attribIndex].fType; | 107 GrVertexAttribType attribType = fVAPtr[index].fType; |
| 107 int slVecCount = GrSLTypeVectorCount(effectSLType); | 108 int slVecCount = GrSLTypeVectorCount(effectSLType); |
| 108 int attribVecCount = GrVertexAttribTypeVectorCount(attribType); | 109 int attribVecCount = GrVertexAttribTypeVectorCount(attribType); |
| 109 if (slVecCount != attribVecCount || | 110 if (slVecCount != attribVecCount || |
| 110 (static_cast<GrSLType>(-1) != slTypes[attribIndex] && | 111 (static_cast<GrSLType>(-1) != slTypes[index] && slTypes[index] !
= effectSLType)) { |
| 111 slTypes[attribIndex] != effectSLType)) { | |
| 112 return false; | 112 return false; |
| 113 } | 113 } |
| 114 slTypes[attribIndex] = effectSLType; | 114 slTypes[index] = effectSLType; |
| 115 effectIndex++; |
| 115 } | 116 } |
| 117 // Make sure all attributes are consumed and we were able to find everyt
hing |
| 118 SkASSERT(effectAttribCount == effectIndex); |
| 116 } | 119 } |
| 117 | 120 |
| 118 return true; | 121 return true; |
| 119 } | 122 } |
| 120 | 123 |
| 121 bool GrRODrawState::hasSolidCoverage() const { | 124 bool GrRODrawState::hasSolidCoverage() const { |
| 122 // If we're drawing coverage directly then coverage is effectively treated a
s color. | 125 // If we're drawing coverage directly then coverage is effectively treated a
s color. |
| 123 if (this->isCoverageDrawing()) { | 126 if (this->isCoverageDrawing()) { |
| 124 return true; | 127 return true; |
| 125 } | 128 } |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 //////////////////////////////////////////////////////////////////////////////// | 376 //////////////////////////////////////////////////////////////////////////////// |
| 374 | 377 |
| 375 bool GrRODrawState::canIgnoreColorAttribute() const { | 378 bool GrRODrawState::canIgnoreColorAttribute() const { |
| 376 if (fBlendOptFlags & kInvalid_BlendOptFlag) { | 379 if (fBlendOptFlags & kInvalid_BlendOptFlag) { |
| 377 this->getBlendOpts(); | 380 this->getBlendOpts(); |
| 378 } | 381 } |
| 379 return SkToBool(fBlendOptFlags & (GrRODrawState::kEmitTransBlack_BlendOptFla
g | | 382 return SkToBool(fBlendOptFlags & (GrRODrawState::kEmitTransBlack_BlendOptFla
g | |
| 380 GrRODrawState::kEmitCoverage_BlendOptFlag)
); | 383 GrRODrawState::kEmitCoverage_BlendOptFlag)
); |
| 381 } | 384 } |
| 382 | 385 |
| OLD | NEW |