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" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // to a canonical value to avoid duplicate programs with different keys. | 59 // to a canonical value to avoid duplicate programs with different keys. |
60 | 60 |
61 bool requiresColorAttrib = !skipColor && drawState.hasColorVertexAttribute()
; | 61 bool requiresColorAttrib = !skipColor && drawState.hasColorVertexAttribute()
; |
62 bool requiresCoverageAttrib = !skipCoverage && drawState.hasCoverageVertexAt
tribute(); | 62 bool requiresCoverageAttrib = !skipCoverage && drawState.hasCoverageVertexAt
tribute(); |
63 // we only need the local coords if we're actually going to generate effect
code | 63 // we only need the local coords if we're actually going to generate effect
code |
64 bool requiresLocalCoordAttrib = !(skipCoverage && skipColor) && | 64 bool requiresLocalCoordAttrib = !(skipCoverage && skipColor) && |
65 drawState.hasLocalCoordAttribute(); | 65 drawState.hasLocalCoordAttribute(); |
66 | 66 |
67 bool colorIsTransBlack = SkToBool(blendOpts & GrDrawState::kEmitTransBlack_B
lendOptFlag); | 67 bool colorIsTransBlack = SkToBool(blendOpts & GrDrawState::kEmitTransBlack_B
lendOptFlag); |
68 bool colorIsSolidWhite = (blendOpts & GrDrawState::kEmitCoverage_BlendOptFla
g) || | 68 bool colorIsSolidWhite = (blendOpts & GrDrawState::kEmitCoverage_BlendOptFla
g) || |
69 (!requiresColorAttrib && 0xffffffff == drawState.ge
tColor()); | 69 (!requiresColorAttrib && 0xffffffff == drawState.ge
tColor()) || |
| 70 drawState.numColorStages() > 0 && !(*drawState.getC
olorStage(0)->getEffect())->getWillUseInputColor(); |
70 | 71 |
71 int numEffects = (skipColor ? 0 : drawState.numColorStages()) + | 72 int numEffects = (skipColor ? 0 : drawState.numColorStages()) + |
72 (skipCoverage ? 0 : drawState.numCoverageStages()); | 73 (skipCoverage ? 0 : drawState.numCoverageStages()); |
73 | 74 |
74 size_t newKeyLength = KeyLength(numEffects); | 75 size_t newKeyLength = KeyLength(numEffects); |
75 bool allocChanged; | 76 bool allocChanged; |
76 desc->fKey.reset(newKeyLength, SkAutoMalloc::kAlloc_OnShrink, &allocChanged)
; | 77 desc->fKey.reset(newKeyLength, SkAutoMalloc::kAlloc_OnShrink, &allocChanged)
; |
77 if (allocChanged || !desc->fInitialized) { | 78 if (allocChanged || !desc->fInitialized) { |
78 // make sure any padding in the header is zero if we we haven't used thi
s allocation before. | 79 // make sure any padding in the header is zero if we we haven't used thi
s allocation before. |
79 memset(desc->header(), 0, kHeaderSize); | 80 memset(desc->header(), 0, kHeaderSize); |
(...skipping 16 matching lines...) Expand all Loading... |
96 } | 97 } |
97 if (!skipCoverage) { | 98 if (!skipCoverage) { |
98 for (int s = 0; s < drawState.numCoverageStages(); ++s) { | 99 for (int s = 0; s < drawState.numCoverageStages(); ++s) { |
99 effectKeys[currEffectKey++] = | 100 effectKeys[currEffectKey++] = |
100 get_key_and_update_stats(drawState.getCoverageStage(s), gpu->glC
aps(), | 101 get_key_and_update_stats(drawState.getCoverageStage(s), gpu->glC
aps(), |
101 requiresLocalCoordAttrib, &readsDst, &r
eadFragPosition); | 102 requiresLocalCoordAttrib, &readsDst, &r
eadFragPosition); |
102 } | 103 } |
103 } | 104 } |
104 | 105 |
105 header->fEmitsPointSize = isPoints; | 106 header->fEmitsPointSize = isPoints; |
106 header->fColorFilterXfermode = skipColor ? SkXfermode::kDst_Mode : drawState
.getColorFilterMode(); | |
107 | 107 |
108 // Currently the experimental GS will only work with triangle prims (and it
doesn't do anything | 108 // Currently the experimental GS will only work with triangle prims (and it
doesn't do anything |
109 // other than pass through values from the VS to the FS anyway). | 109 // other than pass through values from the VS to the FS anyway). |
110 #if GR_GL_EXPERIMENTAL_GS | 110 #if GR_GL_EXPERIMENTAL_GS |
111 #if 0 | 111 #if 0 |
112 header->fExperimentalGS = gpu->caps().geometryShaderSupport(); | 112 header->fExperimentalGS = gpu->caps().geometryShaderSupport(); |
113 #else | 113 #else |
114 header->fExperimentalGS = false; | 114 header->fExperimentalGS = false; |
115 #endif | 115 #endif |
116 #endif | 116 #endif |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 | 184 |
185 // Set these defaults and then possibly change our mind if there is coverage
. | 185 // Set these defaults and then possibly change our mind if there is coverage
. |
186 header->fDiscardIfZeroCoverage = false; | 186 header->fDiscardIfZeroCoverage = false; |
187 header->fCoverageOutput = kModulate_CoverageOutput; | 187 header->fCoverageOutput = kModulate_CoverageOutput; |
188 | 188 |
189 // If we do have coverage determine whether it matters. | 189 // If we do have coverage determine whether it matters. |
190 bool separateCoverageFromColor = false; | 190 bool separateCoverageFromColor = false; |
191 if (!drawState.isCoverageDrawing() && !skipCoverage && | 191 if (!drawState.isCoverageDrawing() && !skipCoverage && |
192 (drawState.numCoverageStages() > 0 || requiresCoverageAttrib)) { | 192 (drawState.numCoverageStages() > 0 || requiresCoverageAttrib)) { |
193 // color filter is applied between color/coverage computation | 193 // color filter is applied between color/coverage computation |
194 if (SkXfermode::kDst_Mode != header->fColorFilterXfermode) { | 194 // TODO: |
| 195 //if (SkXfermode::kDst_Mode != header->fColorFilterXfermode) { |
195 separateCoverageFromColor = true; | 196 separateCoverageFromColor = true; |
196 } | 197 //} |
197 | 198 |
198 // If we're stenciling then we want to discard samples that have zero co
verage | 199 // If we're stenciling then we want to discard samples that have zero co
verage |
199 if (drawState.getStencil().doesWrite()) { | 200 if (drawState.getStencil().doesWrite()) { |
200 header->fDiscardIfZeroCoverage = true; | 201 header->fDiscardIfZeroCoverage = true; |
201 separateCoverageFromColor = true; | 202 separateCoverageFromColor = true; |
202 } | 203 } |
203 | 204 |
204 if (gpu->caps()->dualSourceBlendingSupport() && | 205 if (gpu->caps()->dualSourceBlendingSupport() && |
205 !(blendOpts & (GrDrawState::kEmitCoverage_BlendOptFlag | | 206 !(blendOpts & (GrDrawState::kEmitCoverage_BlendOptFlag | |
206 GrDrawState::kCoverageAsAlpha_BlendOptFlag))) { | 207 GrDrawState::kCoverageAsAlpha_BlendOptFlag))) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 | 253 |
253 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { | 254 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { |
254 fInitialized = other.fInitialized; | 255 fInitialized = other.fInitialized; |
255 if (fInitialized) { | 256 if (fInitialized) { |
256 size_t keyLength = other.keyLength(); | 257 size_t keyLength = other.keyLength(); |
257 fKey.reset(keyLength); | 258 fKey.reset(keyLength); |
258 memcpy(fKey.get(), other.fKey.get(), keyLength); | 259 memcpy(fKey.get(), other.fKey.get(), keyLength); |
259 } | 260 } |
260 return *this; | 261 return *this; |
261 } | 262 } |
OLD | NEW |