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 19 matching lines...) Expand all Loading... |
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; |
35 } | 35 } |
36 return factory.glEffectKey(drawEffect, caps); | 36 return factory.glEffectKey(drawEffect, caps); |
37 } | 37 } |
38 } | 38 } |
39 void GrGLProgramDesc::Build(const GrDrawState& drawState, | 39 void GrGLProgramDesc::Build(const GrDrawState& drawState, |
40 bool isPoints, | 40 GrGpu::DrawType drawType, |
41 GrDrawState::BlendOptFlags blendOpts, | 41 GrDrawState::BlendOptFlags blendOpts, |
42 GrBlendCoeff srcCoeff, | 42 GrBlendCoeff srcCoeff, |
43 GrBlendCoeff dstCoeff, | 43 GrBlendCoeff dstCoeff, |
44 const GrGpuGL* gpu, | 44 const GrGpuGL* gpu, |
45 const GrDeviceCoordTexture* dstCopy, | 45 const GrDeviceCoordTexture* dstCopy, |
46 SkTArray<const GrEffectStage*, true>* colorStages, | 46 SkTArray<const GrEffectStage*, true>* colorStages, |
47 SkTArray<const GrEffectStage*, true>* coverageStages
, | 47 SkTArray<const GrEffectStage*, true>* coverageStages
, |
48 GrGLProgramDesc* desc) { | 48 GrGLProgramDesc* desc) { |
49 colorStages->reset(); | 49 colorStages->reset(); |
50 coverageStages->reset(); | 50 coverageStages->reset(); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 } | 106 } |
107 // write the key length | 107 // write the key length |
108 *desc->atOffset<uint32_t, kLengthOffset>() = SkToU32(newKeyLength); | 108 *desc->atOffset<uint32_t, kLengthOffset>() = SkToU32(newKeyLength); |
109 | 109 |
110 KeyHeader* header = desc->header(); | 110 KeyHeader* header = desc->header(); |
111 EffectKey* effectKeys = desc->effectKeys(); | 111 EffectKey* effectKeys = desc->effectKeys(); |
112 | 112 |
113 int currEffectKey = 0; | 113 int currEffectKey = 0; |
114 bool readsDst = false; | 114 bool readsDst = false; |
115 bool readFragPosition = false; | 115 bool readFragPosition = false; |
116 bool hasVertexCode = false; | 116 // We use vertexshader-less shader programs only when drawing paths. |
| 117 bool hasVertexCode = !(GrGpu::kDrawPath_DrawType == drawType || |
| 118 GrGpu::kDrawPaths_DrawType == drawType); |
| 119 |
117 if (!skipColor) { | 120 if (!skipColor) { |
118 for (int s = firstEffectiveColorStage; s < drawState.numColorStages(); +
+s) { | 121 for (int s = firstEffectiveColorStage; s < drawState.numColorStages(); +
+s) { |
119 effectKeys[currEffectKey++] = | 122 effectKeys[currEffectKey++] = |
120 get_key_and_update_stats(drawState.getColorStage(s), gpu->glCaps
(), | 123 get_key_and_update_stats(drawState.getColorStage(s), gpu->glCaps
(), |
121 requiresLocalCoordAttrib, &readsDst, &r
eadFragPosition, | 124 requiresLocalCoordAttrib, &readsDst, &r
eadFragPosition, |
122 &hasVertexCode); | 125 &hasVertexCode); |
123 } | 126 } |
124 } | 127 } |
125 if (!skipCoverage) { | 128 if (!skipCoverage) { |
126 for (int s = firstEffectiveCoverageStage; s < drawState.numCoverageStage
s(); ++s) { | 129 for (int s = firstEffectiveCoverageStage; s < drawState.numCoverageStage
s(); ++s) { |
127 effectKeys[currEffectKey++] = | 130 effectKeys[currEffectKey++] = |
128 get_key_and_update_stats(drawState.getCoverageStage(s), gpu->glC
aps(), | 131 get_key_and_update_stats(drawState.getCoverageStage(s), gpu->glC
aps(), |
129 requiresLocalCoordAttrib, &readsDst, &r
eadFragPosition, | 132 requiresLocalCoordAttrib, &readsDst, &r
eadFragPosition, |
130 &hasVertexCode); | 133 &hasVertexCode); |
131 } | 134 } |
132 } | 135 } |
133 | 136 |
134 header->fHasVertexCode = hasVertexCode || requiresLocalCoordAttrib; | 137 header->fHasVertexCode = hasVertexCode || requiresLocalCoordAttrib; |
135 header->fEmitsPointSize = isPoints; | 138 header->fEmitsPointSize = GrGpu::kDrawPoints_DrawType == drawType; |
136 | 139 |
137 // Currently the experimental GS will only work with triangle prims (and it
doesn't do anything | 140 // Currently the experimental GS will only work with triangle prims (and it
doesn't do anything |
138 // other than pass through values from the VS to the FS anyway). | 141 // other than pass through values from the VS to the FS anyway). |
139 #if GR_GL_EXPERIMENTAL_GS | 142 #if GR_GL_EXPERIMENTAL_GS |
140 #if 0 | 143 #if 0 |
141 header->fExperimentalGS = gpu->caps().geometryShaderSupport(); | 144 header->fExperimentalGS = gpu->caps().geometryShaderSupport(); |
142 #else | 145 #else |
143 header->fExperimentalGS = false; | 146 header->fExperimentalGS = false; |
144 #endif | 147 #endif |
145 #endif | 148 #endif |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 | 276 |
274 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { | 277 GrGLProgramDesc& GrGLProgramDesc::operator= (const GrGLProgramDesc& other) { |
275 fInitialized = other.fInitialized; | 278 fInitialized = other.fInitialized; |
276 if (fInitialized) { | 279 if (fInitialized) { |
277 size_t keyLength = other.keyLength(); | 280 size_t keyLength = other.keyLength(); |
278 fKey.reset(keyLength); | 281 fKey.reset(keyLength); |
279 memcpy(fKey.get(), other.fKey.get(), keyLength); | 282 memcpy(fKey.get(), other.fKey.get(), keyLength); |
280 } | 283 } |
281 return *this; | 284 return *this; |
282 } | 285 } |
OLD | NEW |