| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "GrGLProgramDesc.h" | 8 #include "GrGLProgramDesc.h" |
| 9 #include "GrBackendEffectFactory.h" | 9 #include "GrBackendEffectFactory.h" |
| 10 #include "GrDrawEffect.h" | 10 #include "GrDrawEffect.h" |
| 11 #include "GrEffect.h" | 11 #include "GrEffect.h" |
| 12 #include "GrGLShaderBuilder.h" | 12 #include "GrGLShaderBuilder.h" |
| 13 #include "GrGpuGL.h" | 13 #include "GrGpuGL.h" |
| 14 | 14 |
| 15 #include "SkChecksum.h" | 15 #include "SkChecksum.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 inline GrGLEffect::EffectKey get_key_and_update_stats(const GrEffectStage& stage
, | 18 inline GrGLEffect::EffectKey get_key_and_update_stats(const GrEffectStage& stage
, |
| 19 const GrGLCaps& caps, | 19 const GrGLCaps& caps, |
| 20 bool useExplicitLocalCoord
s, | 20 bool useExplicitLocalCoord
s, |
| 21 bool* setTrueIfReadsDst, | 21 bool* setTrueIfReadsDst, |
| 22 bool* setTrueIfReadsPos, | 22 bool* setTrueIfReadsPos, |
| 23 bool* setTrueIfHasVertexCo
de) { | 23 bool* setTrueIfHasVertexCo
de) { |
| 24 const GrEffectRef& effect = *stage.getEffect(); | 24 const GrEffect* effect = stage.getEffect(); |
| 25 const GrBackendEffectFactory& factory = effect->getFactory(); | 25 const GrBackendEffectFactory& factory = effect->getFactory(); |
| 26 GrDrawEffect drawEffect(stage, useExplicitLocalCoords); | 26 GrDrawEffect drawEffect(stage, useExplicitLocalCoords); |
| 27 if (effect->willReadDstColor()) { | 27 if (effect->willReadDstColor()) { |
| 28 *setTrueIfReadsDst = true; | 28 *setTrueIfReadsDst = true; |
| 29 } | 29 } |
| 30 if (effect->willReadFragmentPosition()) { | 30 if (effect->willReadFragmentPosition()) { |
| 31 *setTrueIfReadsPos = true; | 31 *setTrueIfReadsPos = true; |
| 32 } | 32 } |
| 33 if (effect->hasVertexCode()) { | 33 if (effect->hasVertexCode()) { |
| 34 *setTrueIfHasVertexCode = true; | 34 *setTrueIfHasVertexCode = true; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 55 bool skipCoverage = SkToBool(blendOpts & GrDrawState::kEmitTransBlack_BlendO
ptFlag); | 55 bool skipCoverage = SkToBool(blendOpts & GrDrawState::kEmitTransBlack_BlendO
ptFlag); |
| 56 | 56 |
| 57 bool skipColor = SkToBool(blendOpts & (GrDrawState::kEmitTransBlack_BlendOpt
Flag | | 57 bool skipColor = SkToBool(blendOpts & (GrDrawState::kEmitTransBlack_BlendOpt
Flag | |
| 58 GrDrawState::kEmitCoverage_BlendOptFl
ag)); | 58 GrDrawState::kEmitCoverage_BlendOptFl
ag)); |
| 59 int firstEffectiveColorStage = 0; | 59 int firstEffectiveColorStage = 0; |
| 60 bool inputColorIsUsed = true; | 60 bool inputColorIsUsed = true; |
| 61 if (!skipColor) { | 61 if (!skipColor) { |
| 62 firstEffectiveColorStage = drawState.numColorStages(); | 62 firstEffectiveColorStage = drawState.numColorStages(); |
| 63 while (firstEffectiveColorStage > 0 && inputColorIsUsed) { | 63 while (firstEffectiveColorStage > 0 && inputColorIsUsed) { |
| 64 --firstEffectiveColorStage; | 64 --firstEffectiveColorStage; |
| 65 const GrEffect* effect = drawState.getColorStage(firstEffectiveColor
Stage).getEffect()->get(); | 65 const GrEffect* effect = drawState.getColorStage(firstEffectiveColor
Stage).getEffect(); |
| 66 inputColorIsUsed = effect->willUseInputColor(); | 66 inputColorIsUsed = effect->willUseInputColor(); |
| 67 } | 67 } |
| 68 } | 68 } |
| 69 | 69 |
| 70 int firstEffectiveCoverageStage = 0; | 70 int firstEffectiveCoverageStage = 0; |
| 71 bool inputCoverageIsUsed = true; | 71 bool inputCoverageIsUsed = true; |
| 72 if (!skipCoverage) { | 72 if (!skipCoverage) { |
| 73 firstEffectiveCoverageStage = drawState.numCoverageStages(); | 73 firstEffectiveCoverageStage = drawState.numCoverageStages(); |
| 74 while (firstEffectiveCoverageStage > 0 && inputCoverageIsUsed) { | 74 while (firstEffectiveCoverageStage > 0 && inputCoverageIsUsed) { |
| 75 --firstEffectiveCoverageStage; | 75 --firstEffectiveCoverageStage; |
| 76 const GrEffect* effect = drawState.getCoverageStage(firstEffectiveCo
verageStage).getEffect()->get(); | 76 const GrEffect* effect = drawState.getCoverageStage(firstEffectiveCo
verageStage).getEffect(); |
| 77 inputCoverageIsUsed = effect->willUseInputColor(); | 77 inputCoverageIsUsed = effect->willUseInputColor(); |
| 78 } | 78 } |
| 79 } | 79 } |
| 80 | 80 |
| 81 // The descriptor is used as a cache key. Thus when a field of the | 81 // The descriptor is used as a cache key. Thus when a field of the |
| 82 // descriptor will not affect program generation (because of the attribute | 82 // descriptor will not affect program generation (because of the attribute |
| 83 // bindings in use or other descriptor field settings) it should be set | 83 // bindings in use or other descriptor field settings) it should be set |
| 84 // to a canonical value to avoid duplicate programs with different keys. | 84 // to a canonical value to avoid duplicate programs with different keys. |
| 85 | 85 |
| 86 bool requiresColorAttrib = !skipColor && drawState.hasColorVertexAttribute()
; | 86 bool requiresColorAttrib = !skipColor && drawState.hasColorVertexAttribute()
; |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 276 |
| 277 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { | 277 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { |
| 278 fInitialized = other.fInitialized; | 278 fInitialized = other.fInitialized; |
| 279 if (fInitialized) { | 279 if (fInitialized) { |
| 280 size_t keyLength = other.keyLength(); | 280 size_t keyLength = other.keyLength(); |
| 281 fKey.reset(keyLength); | 281 fKey.reset(keyLength); |
| 282 memcpy(fKey.get(), other.fKey.get(), keyLength); | 282 memcpy(fKey.get(), other.fKey.get(), keyLength); |
| 283 } | 283 } |
| 284 return *this; | 284 return *this; |
| 285 } | 285 } |
| OLD | NEW |