commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 Google Inc. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license that can be |
| 5 | * found in the LICENSE file. |
| 6 | */ |
| 7 | |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 8 | #include "gl/builders/GrGLProgramBuilder.h" |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 9 | #include "GrGLProgramEffects.h" |
| 10 | #include "GrDrawEffect.h" |
| 11 | #include "gl/GrGLEffect.h" |
kkinnunen | ec56e45 | 2014-08-25 22:21:16 -0700 | [diff] [blame] | 12 | #include "gl/GrGLPathRendering.h" |
| 13 | #include "gl/builders/GrGLProgramBuilder.h" |
commit-bot@chromium.org | 261dc56 | 2013-10-04 15:42:56 +0000 | [diff] [blame] | 14 | #include "gl/GrGLVertexEffect.h" |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 15 | #include "gl/GrGpuGL.h" |
| 16 | |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 17 | typedef GrGLProgramEffects::TransformedCoords TransformedCoords; |
| 18 | typedef GrGLProgramEffects::TransformedCoordsArray TransformedCoordsArray; |
| 19 | typedef GrGLProgramEffects::TextureSampler TextureSampler; |
| 20 | typedef GrGLProgramEffects::TextureSamplerArray TextureSamplerArray; |
| 21 | |
| 22 | /** |
| 23 | * We specialize the vertex code for each of these matrix types. |
| 24 | */ |
| 25 | enum MatrixType { |
egdaniel | 4c6443e | 2014-06-24 13:43:12 -0700 | [diff] [blame] | 26 | kNoPersp_MatrixType = 0, |
| 27 | kGeneral_MatrixType = 1, |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | /** |
| 31 | * The key for an individual coord transform is made up of a matrix type and a bit that |
| 32 | * indicates the source of the input coords. |
| 33 | */ |
| 34 | enum { |
egdaniel | 4c6443e | 2014-06-24 13:43:12 -0700 | [diff] [blame] | 35 | kMatrixTypeKeyBits = 1, |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 36 | kMatrixTypeKeyMask = (1 << kMatrixTypeKeyBits) - 1, |
| 37 | kPositionCoords_Flag = (1 << kMatrixTypeKeyBits), |
| 38 | kTransformKeyBits = kMatrixTypeKeyBits + 1, |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | namespace { |
| 42 | |
| 43 | /** |
| 44 | * Do we need to either map r,g,b->a or a->r. configComponentMask indicates which channels are |
| 45 | * present in the texture's config. swizzleComponentMask indicates the channels present in the |
| 46 | * shader swizzle. |
| 47 | */ |
| 48 | inline bool swizzle_requires_alpha_remapping(const GrGLCaps& caps, |
| 49 | uint32_t configComponentMask, |
| 50 | uint32_t swizzleComponentMask) { |
| 51 | if (caps.textureSwizzleSupport()) { |
| 52 | // Any remapping is handled using texture swizzling not shader modifications. |
| 53 | return false; |
| 54 | } |
| 55 | // check if the texture is alpha-only |
| 56 | if (kA_GrColorComponentFlag == configComponentMask) { |
| 57 | if (caps.textureRedSupport() && (kA_GrColorComponentFlag & swizzleComponentMask)) { |
| 58 | // we must map the swizzle 'a's to 'r'. |
| 59 | return true; |
| 60 | } |
| 61 | if (kRGB_GrColorComponentFlags & swizzleComponentMask) { |
| 62 | // The 'r', 'g', and/or 'b's must be mapped to 'a' according to our semantics that |
| 63 | // alpha-only textures smear alpha across all four channels when read. |
| 64 | return true; |
| 65 | } |
| 66 | } |
| 67 | return false; |
| 68 | } |
| 69 | |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 70 | /** |
| 71 | * Retrieves the matrix type from transformKey for the transform at transformIdx. |
| 72 | */ |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 73 | MatrixType get_matrix_type(uint32_t transformKey, int transformIdx) { |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 74 | return static_cast<MatrixType>( |
| 75 | (transformKey >> (kTransformKeyBits * transformIdx)) & kMatrixTypeKeyMask); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 76 | } |
| 77 | |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 78 | /** |
| 79 | * Retrieves the source coords from transformKey for the transform at transformIdx. It may not be |
| 80 | * the same coordinate set as the original GrCoordTransform if the position and local coords are |
| 81 | * identical for this program. |
| 82 | */ |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 83 | GrCoordSet get_source_coords(uint32_t transformKey, int transformIdx) { |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 84 | return (transformKey >> (kTransformKeyBits * transformIdx)) & kPositionCoords_Flag ? |
| 85 | kPosition_GrCoordSet : |
| 86 | kLocal_GrCoordSet; |
| 87 | } |
| 88 | |
| 89 | /** |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 90 | * Retrieves the final matrix that a transform needs to apply to its source coords. |
| 91 | */ |
| 92 | SkMatrix get_transform_matrix(const GrDrawEffect& drawEffect, int transformIdx) { |
bsalomon | f99f884 | 2014-07-07 11:54:23 -0700 | [diff] [blame] | 93 | const GrCoordTransform& coordTransform = drawEffect.effect()->coordTransform(transformIdx); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 94 | SkMatrix combined; |
bsalomon | 0673676 | 2014-08-04 10:56:39 -0700 | [diff] [blame] | 95 | |
| 96 | if (kLocal_GrCoordSet == coordTransform.sourceCoords()) { |
| 97 | // If we have explicit local coords then we shouldn't need a coord change. |
| 98 | SkASSERT(!drawEffect.programHasExplicitLocalCoords() || |
| 99 | drawEffect.getCoordChangeMatrix().isIdentity()); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 100 | combined.setConcat(coordTransform.getMatrix(), drawEffect.getCoordChangeMatrix()); |
| 101 | } else { |
| 102 | combined = coordTransform.getMatrix(); |
| 103 | } |
| 104 | if (coordTransform.reverseY()) { |
| 105 | // combined.postScale(1,-1); |
| 106 | // combined.postTranslate(0,1); |
| 107 | combined.set(SkMatrix::kMSkewY, |
| 108 | combined[SkMatrix::kMPersp0] - combined[SkMatrix::kMSkewY]); |
| 109 | combined.set(SkMatrix::kMScaleY, |
| 110 | combined[SkMatrix::kMPersp1] - combined[SkMatrix::kMScaleY]); |
| 111 | combined.set(SkMatrix::kMTransY, |
| 112 | combined[SkMatrix::kMPersp2] - combined[SkMatrix::kMTransY]); |
| 113 | } |
| 114 | return combined; |
| 115 | } |
| 116 | |
| 117 | } |
| 118 | |
| 119 | //////////////////////////////////////////////////////////////////////////////// |
| 120 | |
bsalomon | 929f29a | 2014-07-17 07:55:11 -0700 | [diff] [blame] | 121 | bool GrGLProgramEffects::GenEffectMetaKey(const GrDrawEffect& drawEffect, const GrGLCaps& caps, |
| 122 | GrEffectKeyBuilder* b) { |
| 123 | |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 124 | uint32_t textureKey = GrGLProgramEffects::GenTextureKey(drawEffect, caps); |
| 125 | uint32_t transformKey = GrGLProgramEffects::GenTransformKey(drawEffect); |
| 126 | uint32_t attribKey = GrGLProgramEffects::GenAttribKey(drawEffect); |
bsalomon | 929f29a | 2014-07-17 07:55:11 -0700 | [diff] [blame] | 127 | uint32_t classID = drawEffect.effect()->getFactory().effectClassID(); |
| 128 | |
| 129 | // Currently we allow 16 bits for each of the above portions of the meta-key. Fail if they |
| 130 | // don't fit. |
| 131 | static const uint32_t kMetaKeyInvalidMask = ~((uint32_t) SK_MaxU16); |
| 132 | if ((textureKey | transformKey | attribKey | classID) & kMetaKeyInvalidMask) { |
| 133 | return false; |
| 134 | } |
| 135 | |
| 136 | uint32_t* key = b->add32n(2); |
| 137 | key[0] = (textureKey << 16 | transformKey); |
| 138 | key[1] = (classID << 16 | attribKey); |
| 139 | return true; |
| 140 | } |
| 141 | |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 142 | uint32_t GrGLProgramEffects::GenAttribKey(const GrDrawEffect& drawEffect) { |
| 143 | uint32_t key = 0; |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 144 | int numAttributes = drawEffect.getVertexAttribIndexCount(); |
| 145 | SkASSERT(numAttributes <= 2); |
| 146 | const int* attributeIndices = drawEffect.getVertexAttribIndices(); |
| 147 | for (int a = 0; a < numAttributes; ++a) { |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 148 | uint32_t value = attributeIndices[a] << 3 * a; |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 149 | SkASSERT(0 == (value & key)); // keys for each attribute ought not to overlap |
| 150 | key |= value; |
| 151 | } |
| 152 | return key; |
| 153 | } |
| 154 | |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 155 | uint32_t GrGLProgramEffects::GenTransformKey(const GrDrawEffect& drawEffect) { |
| 156 | uint32_t totalKey = 0; |
bsalomon | f99f884 | 2014-07-07 11:54:23 -0700 | [diff] [blame] | 157 | int numTransforms = drawEffect.effect()->numTransforms(); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 158 | for (int t = 0; t < numTransforms; ++t) { |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 159 | uint32_t key = 0; |
bsalomon | f99f884 | 2014-07-07 11:54:23 -0700 | [diff] [blame] | 160 | const GrCoordTransform& coordTransform = drawEffect.effect()->coordTransform(t); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 161 | SkMatrix::TypeMask type0 = coordTransform.getMatrix().getType(); |
| 162 | SkMatrix::TypeMask type1; |
| 163 | if (kLocal_GrCoordSet == coordTransform.sourceCoords()) { |
| 164 | type1 = drawEffect.getCoordChangeMatrix().getType(); |
| 165 | } else { |
| 166 | if (drawEffect.programHasExplicitLocalCoords()) { |
| 167 | // We only make the key indicate that device coords are referenced when the local coords |
| 168 | // are not actually determined by positions. Otherwise the local coords var and position |
| 169 | // var are identical. |
| 170 | key |= kPositionCoords_Flag; |
| 171 | } |
| 172 | type1 = SkMatrix::kIdentity_Mask; |
| 173 | } |
| 174 | |
| 175 | int combinedTypes = type0 | type1; |
| 176 | |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 177 | if (SkMatrix::kPerspective_Mask & combinedTypes) { |
| 178 | key |= kGeneral_MatrixType; |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 179 | } else { |
egdaniel | 4c6443e | 2014-06-24 13:43:12 -0700 | [diff] [blame] | 180 | key |= kNoPersp_MatrixType; |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 181 | } |
| 182 | key <<= kTransformKeyBits * t; |
| 183 | SkASSERT(0 == (totalKey & key)); // keys for each transform ought not to overlap |
| 184 | totalKey |= key; |
| 185 | } |
| 186 | return totalKey; |
| 187 | } |
| 188 | |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 189 | uint32_t GrGLProgramEffects::GenTextureKey(const GrDrawEffect& drawEffect, const GrGLCaps& caps) { |
| 190 | uint32_t key = 0; |
bsalomon | f99f884 | 2014-07-07 11:54:23 -0700 | [diff] [blame] | 191 | int numTextures = drawEffect.effect()->numTextures(); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 192 | for (int t = 0; t < numTextures; ++t) { |
bsalomon | f99f884 | 2014-07-07 11:54:23 -0700 | [diff] [blame] | 193 | const GrTextureAccess& access = drawEffect.effect()->textureAccess(t); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 194 | uint32_t configComponentMask = GrPixelConfigComponentMask(access.getTexture()->config()); |
| 195 | if (swizzle_requires_alpha_remapping(caps, configComponentMask, access.swizzleMask())) { |
| 196 | key |= 1 << t; |
| 197 | } |
| 198 | } |
| 199 | return key; |
| 200 | } |
| 201 | |
| 202 | GrGLProgramEffects::~GrGLProgramEffects() { |
| 203 | int numEffects = fGLEffects.count(); |
| 204 | for (int e = 0; e < numEffects; ++e) { |
| 205 | SkDELETE(fGLEffects[e]); |
| 206 | } |
| 207 | } |
| 208 | |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 209 | void GrGLProgramEffects::emitSamplers(GrGLProgramBuilder* builder, |
bsalomon | f99f884 | 2014-07-07 11:54:23 -0700 | [diff] [blame] | 210 | const GrEffect* effect, |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 211 | TextureSamplerArray* outSamplers) { |
| 212 | SkTArray<Sampler, true>& samplers = fSamplers.push_back(); |
| 213 | int numTextures = effect->numTextures(); |
| 214 | samplers.push_back_n(numTextures); |
| 215 | SkString name; |
| 216 | for (int t = 0; t < numTextures; ++t) { |
| 217 | name.printf("Sampler%d", t); |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 218 | samplers[t].fUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility, |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 219 | kSampler2D_GrSLType, |
| 220 | name.c_str()); |
| 221 | SkNEW_APPEND_TO_TARRAY(outSamplers, TextureSampler, |
| 222 | (samplers[t].fUniform, effect->textureAccess(t))); |
| 223 | } |
| 224 | } |
| 225 | |
kkinnunen | 7510b22 | 2014-07-30 00:04:16 -0700 | [diff] [blame] | 226 | void GrGLProgramEffects::initSamplers(const GrGLProgramDataManager& programResourceManager, int* texUnitIdx) { |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 227 | int numEffects = fGLEffects.count(); |
| 228 | SkASSERT(numEffects == fSamplers.count()); |
| 229 | for (int e = 0; e < numEffects; ++e) { |
| 230 | SkTArray<Sampler, true>& samplers = fSamplers[e]; |
| 231 | int numSamplers = samplers.count(); |
| 232 | for (int s = 0; s < numSamplers; ++s) { |
| 233 | SkASSERT(samplers[s].fUniform.isValid()); |
kkinnunen | 7510b22 | 2014-07-30 00:04:16 -0700 | [diff] [blame] | 234 | programResourceManager.setSampler(samplers[s].fUniform, *texUnitIdx); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 235 | samplers[s].fTextureUnit = (*texUnitIdx)++; |
| 236 | } |
| 237 | } |
| 238 | } |
| 239 | |
bsalomon | f99f884 | 2014-07-07 11:54:23 -0700 | [diff] [blame] | 240 | void GrGLProgramEffects::bindTextures(GrGpuGL* gpu, const GrEffect* effect, int effectIdx) { |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 241 | const SkTArray<Sampler, true>& samplers = fSamplers[effectIdx]; |
| 242 | int numSamplers = samplers.count(); |
| 243 | SkASSERT(numSamplers == effect->numTextures()); |
| 244 | for (int s = 0; s < numSamplers; ++s) { |
| 245 | SkASSERT(samplers[s].fTextureUnit >= 0); |
| 246 | const GrTextureAccess& textureAccess = effect->textureAccess(s); |
| 247 | gpu->bindTexture(samplers[s].fTextureUnit, |
| 248 | textureAccess.getParams(), |
| 249 | static_cast<GrGLTexture*>(textureAccess.getTexture())); |
| 250 | } |
| 251 | } |
| 252 | |
| 253 | //////////////////////////////////////////////////////////////////////////////// |
| 254 | |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 255 | void GrGLVertexProgramEffects::emitEffect(GrGLFullProgramBuilder* builder, |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 256 | const GrEffectStage& stage, |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 257 | const GrEffectKey& key, |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 258 | const char* outColor, |
| 259 | const char* inColor, |
| 260 | int stageIndex) { |
| 261 | GrDrawEffect drawEffect(stage, fHasExplicitLocalCoords); |
bsalomon | f99f884 | 2014-07-07 11:54:23 -0700 | [diff] [blame] | 262 | const GrEffect* effect = stage.getEffect(); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 263 | SkSTArray<2, TransformedCoords> coords(effect->numTransforms()); |
| 264 | SkSTArray<4, TextureSampler> samplers(effect->numTextures()); |
| 265 | |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 266 | GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder(); |
| 267 | GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
| 268 | vsBuilder->emitAttributes(stage); |
bsalomon | 848faf0 | 2014-07-11 10:01:02 -0700 | [diff] [blame] | 269 | this->emitTransforms(builder, drawEffect, &coords); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 270 | this->emitSamplers(builder, effect, &samplers); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 271 | |
| 272 | GrGLEffect* glEffect = effect->getFactory().createGLInstance(drawEffect); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 273 | fGLEffects.push_back(glEffect); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 274 | |
| 275 | // Enclose custom code in a block to avoid namespace conflicts |
| 276 | SkString openBrace; |
| 277 | openBrace.printf("\t{ // Stage %d: %s\n", stageIndex, glEffect->name()); |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 278 | fsBuilder->codeAppend(openBrace.c_str()); |
| 279 | vsBuilder->codeAppend(openBrace.c_str()); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 280 | |
commit-bot@chromium.org | 261dc56 | 2013-10-04 15:42:56 +0000 | [diff] [blame] | 281 | if (glEffect->isVertexEffect()) { |
| 282 | GrGLVertexEffect* vertexEffect = static_cast<GrGLVertexEffect*>(glEffect); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 283 | vertexEffect->emitCode(builder, drawEffect, key, outColor, inColor, coords, samplers); |
commit-bot@chromium.org | 261dc56 | 2013-10-04 15:42:56 +0000 | [diff] [blame] | 284 | } else { |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 285 | glEffect->emitCode(builder, drawEffect, key, outColor, inColor, coords, samplers); |
commit-bot@chromium.org | 261dc56 | 2013-10-04 15:42:56 +0000 | [diff] [blame] | 286 | } |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 287 | |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 288 | vsBuilder->codeAppend("\t}\n"); |
| 289 | fsBuilder->codeAppend("\t}\n"); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 290 | } |
| 291 | |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 292 | void GrGLVertexProgramEffects::emitTransforms(GrGLFullProgramBuilder* builder, |
bsalomon | 848faf0 | 2014-07-11 10:01:02 -0700 | [diff] [blame] | 293 | const GrDrawEffect& drawEffect, |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 294 | TransformedCoordsArray* outCoords) { |
| 295 | SkTArray<Transform, true>& transforms = fTransforms.push_back(); |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 296 | uint32_t totalKey = GenTransformKey(drawEffect); |
bsalomon | 848faf0 | 2014-07-11 10:01:02 -0700 | [diff] [blame] | 297 | int numTransforms = drawEffect.effect()->numTransforms(); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 298 | transforms.push_back_n(numTransforms); |
kkinnunen | ec56e45 | 2014-08-25 22:21:16 -0700 | [diff] [blame] | 299 | |
| 300 | SkTArray<PathTransform, true>* pathTransforms = NULL; |
| 301 | const GrGLCaps* glCaps = builder->ctxInfo().caps(); |
| 302 | if (glCaps->pathRenderingSupport() && |
| 303 | builder->gpu()->glPathRendering()->texturingMode() == |
| 304 | GrGLPathRendering::SeparableShaders_TexturingMode) { |
| 305 | pathTransforms = &fPathTransforms.push_back(); |
| 306 | pathTransforms->push_back_n(numTransforms); |
| 307 | } |
| 308 | |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 309 | for (int t = 0; t < numTransforms; t++) { |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 310 | GrSLType varyingType = kVoid_GrSLType; |
| 311 | const char* uniName; |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 312 | switch (get_matrix_type(totalKey, t)) { |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 313 | case kNoPersp_MatrixType: |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 314 | uniName = "StageMatrix"; |
| 315 | varyingType = kVec2f_GrSLType; |
| 316 | break; |
| 317 | case kGeneral_MatrixType: |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 318 | uniName = "StageMatrix"; |
| 319 | varyingType = kVec3f_GrSLType; |
| 320 | break; |
| 321 | default: |
commit-bot@chromium.org | 88cb22b | 2014-04-30 14:17:00 +0000 | [diff] [blame] | 322 | SkFAIL("Unexpected key."); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 323 | } |
| 324 | SkString suffixedUniName; |
egdaniel | 4c6443e | 2014-06-24 13:43:12 -0700 | [diff] [blame] | 325 | if (0 != t) { |
| 326 | suffixedUniName.append(uniName); |
| 327 | suffixedUniName.appendf("_%i", t); |
| 328 | uniName = suffixedUniName.c_str(); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 329 | } |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 330 | transforms[t].fHandle = builder->addUniform(GrGLProgramBuilder::kVertex_Visibility, |
egdaniel | 4c6443e | 2014-06-24 13:43:12 -0700 | [diff] [blame] | 331 | kMat33f_GrSLType, |
| 332 | uniName, |
| 333 | &uniName); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 334 | |
| 335 | const char* varyingName = "MatrixCoord"; |
| 336 | SkString suffixedVaryingName; |
| 337 | if (0 != t) { |
| 338 | suffixedVaryingName.append(varyingName); |
| 339 | suffixedVaryingName.appendf("_%i", t); |
| 340 | varyingName = suffixedVaryingName.c_str(); |
| 341 | } |
| 342 | const char* vsVaryingName; |
| 343 | const char* fsVaryingName; |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 344 | GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder(); |
kkinnunen | ec56e45 | 2014-08-25 22:21:16 -0700 | [diff] [blame] | 345 | if (pathTransforms) { |
| 346 | (*pathTransforms)[t].fHandle = |
| 347 | builder->addSeparableVarying(varyingType, varyingName, &vsVaryingName, &fsVaryingName); |
| 348 | (*pathTransforms)[t].fType = varyingType; |
| 349 | } else { |
| 350 | builder->addVarying(varyingType, varyingName, &vsVaryingName, &fsVaryingName); |
| 351 | } |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 352 | |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 353 | const GrGLShaderVar& coords = kPosition_GrCoordSet == get_source_coords(totalKey, t) ? |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 354 | vsBuilder->positionAttribute() : |
| 355 | vsBuilder->localCoordsAttribute(); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 356 | // varying = matrix * coords (logically) |
egdaniel | 4c6443e | 2014-06-24 13:43:12 -0700 | [diff] [blame] | 357 | SkASSERT(kVec2f_GrSLType == varyingType || kVec3f_GrSLType == varyingType); |
| 358 | if (kVec2f_GrSLType == varyingType) { |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 359 | vsBuilder->codeAppendf("\t%s = (%s * vec3(%s, 1)).xy;\n", |
egdaniel | 4c6443e | 2014-06-24 13:43:12 -0700 | [diff] [blame] | 360 | vsVaryingName, uniName, coords.c_str()); |
| 361 | } else { |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 362 | vsBuilder->codeAppendf("\t%s = %s * vec3(%s, 1);\n", |
egdaniel | 4c6443e | 2014-06-24 13:43:12 -0700 | [diff] [blame] | 363 | vsVaryingName, uniName, coords.c_str()); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 364 | } |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 365 | SkNEW_APPEND_TO_TARRAY(outCoords, TransformedCoords, |
| 366 | (SkString(fsVaryingName), varyingType)); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 367 | } |
| 368 | } |
| 369 | |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 370 | void GrGLVertexProgramEffects::setData(GrGpuGL* gpu, |
kkinnunen | ec56e45 | 2014-08-25 22:21:16 -0700 | [diff] [blame] | 371 | GrGpu::DrawType drawType, |
| 372 | const GrGLProgramDataManager& programDataManager, |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 373 | const GrEffectStage* effectStages[]) { |
| 374 | int numEffects = fGLEffects.count(); |
| 375 | SkASSERT(numEffects == fTransforms.count()); |
| 376 | SkASSERT(numEffects == fSamplers.count()); |
| 377 | for (int e = 0; e < numEffects; ++e) { |
| 378 | GrDrawEffect drawEffect(*effectStages[e], fHasExplicitLocalCoords); |
kkinnunen | ec56e45 | 2014-08-25 22:21:16 -0700 | [diff] [blame] | 379 | fGLEffects[e]->setData(programDataManager, drawEffect); |
| 380 | if (GrGpu::IsPathRenderingDrawType(drawType)) { |
| 381 | this->setPathTransformData(gpu, programDataManager, drawEffect, e); |
| 382 | } else { |
| 383 | this->setTransformData(gpu, programDataManager, drawEffect, e); |
| 384 | } |
| 385 | |
bsalomon | f99f884 | 2014-07-07 11:54:23 -0700 | [diff] [blame] | 386 | this->bindTextures(gpu, drawEffect.effect(), e); |
commit-bot@chromium.org | 3390b9a | 2013-10-03 15:17:58 +0000 | [diff] [blame] | 387 | } |
| 388 | } |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 389 | |
kkinnunen | ec56e45 | 2014-08-25 22:21:16 -0700 | [diff] [blame] | 390 | void GrGLVertexProgramEffects::setTransformData(GrGpuGL* gpu, |
| 391 | const GrGLProgramDataManager& pdman, |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 392 | const GrDrawEffect& drawEffect, |
| 393 | int effectIdx) { |
| 394 | SkTArray<Transform, true>& transforms = fTransforms[effectIdx]; |
| 395 | int numTransforms = transforms.count(); |
bsalomon | f99f884 | 2014-07-07 11:54:23 -0700 | [diff] [blame] | 396 | SkASSERT(numTransforms == drawEffect.effect()->numTransforms()); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 397 | for (int t = 0; t < numTransforms; ++t) { |
egdaniel | 4c6443e | 2014-06-24 13:43:12 -0700 | [diff] [blame] | 398 | SkASSERT(transforms[t].fHandle.isValid()); |
| 399 | const SkMatrix& matrix = get_transform_matrix(drawEffect, t); |
| 400 | if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) { |
kkinnunen | ec56e45 | 2014-08-25 22:21:16 -0700 | [diff] [blame] | 401 | pdman.setSkMatrix(transforms[t].fHandle, matrix); |
egdaniel | 4c6443e | 2014-06-24 13:43:12 -0700 | [diff] [blame] | 402 | transforms[t].fCurrentValue = matrix; |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 403 | } |
| 404 | } |
| 405 | } |
| 406 | |
kkinnunen | ec56e45 | 2014-08-25 22:21:16 -0700 | [diff] [blame] | 407 | void GrGLVertexProgramEffects::setPathTransformData(GrGpuGL* gpu, |
| 408 | const GrGLProgramDataManager& pdman, |
| 409 | const GrDrawEffect& drawEffect, |
| 410 | int effectIdx) { |
| 411 | SkTArray<PathTransform, true>& transforms = fPathTransforms[effectIdx]; |
| 412 | int numTransforms = transforms.count(); |
| 413 | SkASSERT(numTransforms == drawEffect.effect()->numTransforms()); |
| 414 | for (int t = 0; t < numTransforms; ++t) { |
| 415 | SkASSERT(transforms[t].fHandle.isValid()); |
| 416 | const SkMatrix& transform = get_transform_matrix(drawEffect, t); |
| 417 | if (transforms[t].fCurrentValue.cheapEqualTo(transform)) { |
| 418 | continue; |
| 419 | } |
| 420 | transforms[t].fCurrentValue = transform; |
| 421 | switch (transforms[t].fType) { |
| 422 | case kVec2f_GrSLType: |
| 423 | pdman.setProgramPathFragmentInputTransform(transforms[t].fHandle, 2, transform); |
| 424 | break; |
| 425 | case kVec3f_GrSLType: |
| 426 | pdman.setProgramPathFragmentInputTransform(transforms[t].fHandle, 3, transform); |
| 427 | break; |
| 428 | default: |
| 429 | SkFAIL("Unexpected matrix type."); |
| 430 | } |
| 431 | } |
| 432 | } |
| 433 | |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 434 | GrGLVertexProgramEffectsBuilder::GrGLVertexProgramEffectsBuilder(GrGLFullProgramBuilder* builder, |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 435 | int reserveCount) |
| 436 | : fBuilder(builder) |
| 437 | , fProgramEffects(SkNEW_ARGS(GrGLVertexProgramEffects, |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 438 | (reserveCount, |
| 439 | fBuilder->getVertexShaderBuilder()->hasExplicitLocalCoords()))) { |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 440 | } |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 441 | void GrGLVertexProgramEffectsBuilder::emitEffect(const GrEffectStage& stage, |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 442 | const GrEffectKey& key, |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 443 | const char* outColor, |
| 444 | const char* inColor, |
| 445 | int stageIndex) { |
| 446 | SkASSERT(NULL != fProgramEffects.get()); |
| 447 | fProgramEffects->emitEffect(fBuilder, stage, key, outColor, inColor, stageIndex); |
| 448 | } |
| 449 | |
| 450 | //////////////////////////////////////////////////////////////////////////////// |
| 451 | |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 452 | void GrGLPathTexGenProgramEffects::emitEffect(GrGLFragmentOnlyProgramBuilder* builder, |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 453 | const GrEffectStage& stage, |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 454 | const GrEffectKey& key, |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 455 | const char* outColor, |
| 456 | const char* inColor, |
| 457 | int stageIndex) { |
| 458 | GrDrawEffect drawEffect(stage, false); |
bsalomon | f99f884 | 2014-07-07 11:54:23 -0700 | [diff] [blame] | 459 | const GrEffect* effect = stage.getEffect(); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 460 | SkSTArray<2, TransformedCoords> coords(effect->numTransforms()); |
| 461 | SkSTArray<4, TextureSampler> samplers(effect->numTextures()); |
| 462 | |
| 463 | SkASSERT(0 == stage.getVertexAttribIndexCount()); |
bsalomon | 848faf0 | 2014-07-11 10:01:02 -0700 | [diff] [blame] | 464 | this->setupPathTexGen(builder, drawEffect, &coords); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 465 | this->emitSamplers(builder, effect, &samplers); |
| 466 | |
| 467 | GrGLEffect* glEffect = effect->getFactory().createGLInstance(drawEffect); |
| 468 | fGLEffects.push_back(glEffect); |
| 469 | |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 470 | GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 471 | // Enclose custom code in a block to avoid namespace conflicts |
| 472 | SkString openBrace; |
| 473 | openBrace.printf("\t{ // Stage %d: %s\n", stageIndex, glEffect->name()); |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 474 | fsBuilder->codeAppend(openBrace.c_str()); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 475 | |
| 476 | SkASSERT(!glEffect->isVertexEffect()); |
| 477 | glEffect->emitCode(builder, drawEffect, key, outColor, inColor, coords, samplers); |
| 478 | |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 479 | fsBuilder->codeAppend("\t}\n"); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 480 | } |
| 481 | |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 482 | void GrGLPathTexGenProgramEffects::setupPathTexGen(GrGLFragmentOnlyProgramBuilder* builder, |
bsalomon | 848faf0 | 2014-07-11 10:01:02 -0700 | [diff] [blame] | 483 | const GrDrawEffect& drawEffect, |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 484 | TransformedCoordsArray* outCoords) { |
bsalomon | 848faf0 | 2014-07-11 10:01:02 -0700 | [diff] [blame] | 485 | int numTransforms = drawEffect.effect()->numTransforms(); |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 486 | uint32_t totalKey = GenTransformKey(drawEffect); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 487 | int texCoordIndex = builder->addTexCoordSets(numTransforms); |
| 488 | SkNEW_APPEND_TO_TARRAY(&fTransforms, Transforms, (totalKey, texCoordIndex)); |
| 489 | SkString name; |
| 490 | for (int t = 0; t < numTransforms; ++t) { |
| 491 | GrSLType type = kGeneral_MatrixType == get_matrix_type(totalKey, t) ? |
| 492 | kVec3f_GrSLType : |
| 493 | kVec2f_GrSLType; |
| 494 | name.printf("%s(gl_TexCoord[%i])", GrGLSLTypeString(type), texCoordIndex++); |
| 495 | SkNEW_APPEND_TO_TARRAY(outCoords, TransformedCoords, (name, type)); |
| 496 | } |
| 497 | } |
| 498 | |
commit-bot@chromium.org | 0a6fe71 | 2014-04-23 19:26:26 +0000 | [diff] [blame] | 499 | void GrGLPathTexGenProgramEffects::setData(GrGpuGL* gpu, |
kkinnunen | ec56e45 | 2014-08-25 22:21:16 -0700 | [diff] [blame] | 500 | GrGpu::DrawType, |
| 501 | const GrGLProgramDataManager& pdman, |
| 502 | const GrEffectStage* effectStages[]) { |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 503 | int numEffects = fGLEffects.count(); |
| 504 | SkASSERT(numEffects == fTransforms.count()); |
| 505 | SkASSERT(numEffects == fSamplers.count()); |
| 506 | for (int e = 0; e < numEffects; ++e) { |
| 507 | GrDrawEffect drawEffect(*effectStages[e], false); |
kkinnunen | ec56e45 | 2014-08-25 22:21:16 -0700 | [diff] [blame] | 508 | fGLEffects[e]->setData(pdman, drawEffect); |
commit-bot@chromium.org | 0a6fe71 | 2014-04-23 19:26:26 +0000 | [diff] [blame] | 509 | this->setPathTexGenState(gpu, drawEffect, e); |
bsalomon | f99f884 | 2014-07-07 11:54:23 -0700 | [diff] [blame] | 510 | this->bindTextures(gpu, drawEffect.effect(), e); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 511 | } |
| 512 | } |
| 513 | |
commit-bot@chromium.org | 0a6fe71 | 2014-04-23 19:26:26 +0000 | [diff] [blame] | 514 | void GrGLPathTexGenProgramEffects::setPathTexGenState(GrGpuGL* gpu, |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 515 | const GrDrawEffect& drawEffect, |
| 516 | int effectIdx) { |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 517 | uint32_t totalKey = fTransforms[effectIdx].fTransformKey; |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 518 | int texCoordIndex = fTransforms[effectIdx].fTexCoordIndex; |
bsalomon | f99f884 | 2014-07-07 11:54:23 -0700 | [diff] [blame] | 519 | int numTransforms = drawEffect.effect()->numTransforms(); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 520 | for (int t = 0; t < numTransforms; ++t) { |
| 521 | switch (get_matrix_type(totalKey, t)) { |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 522 | case kNoPersp_MatrixType: { |
| 523 | const SkMatrix& transform = get_transform_matrix(drawEffect, t); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 524 | gpu->glPathRendering()->enablePathTexGen( |
| 525 | texCoordIndex++, |
| 526 | GrGLPathRendering::kST_PathTexGenComponents, |
| 527 | transform); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 528 | break; |
| 529 | } |
| 530 | case kGeneral_MatrixType: { |
| 531 | const SkMatrix& transform = get_transform_matrix(drawEffect, t); |
kkinnunen | ccdaa04 | 2014-08-20 01:36:23 -0700 | [diff] [blame] | 532 | gpu->glPathRendering()->enablePathTexGen( |
| 533 | texCoordIndex++, |
| 534 | GrGLPathRendering::kSTR_PathTexGenComponents, |
| 535 | transform); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 536 | break; |
| 537 | } |
| 538 | default: |
commit-bot@chromium.org | 88cb22b | 2014-04-30 14:17:00 +0000 | [diff] [blame] | 539 | SkFAIL("Unexpected matrixs type."); |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 540 | } |
| 541 | } |
| 542 | } |
| 543 | |
commit-bot@chromium.org | 0a6fe71 | 2014-04-23 19:26:26 +0000 | [diff] [blame] | 544 | GrGLPathTexGenProgramEffectsBuilder::GrGLPathTexGenProgramEffectsBuilder( |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 545 | GrGLFragmentOnlyProgramBuilder* builder, |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 546 | int reserveCount) |
| 547 | : fBuilder(builder) |
commit-bot@chromium.org | 0a6fe71 | 2014-04-23 19:26:26 +0000 | [diff] [blame] | 548 | , fProgramEffects(SkNEW_ARGS(GrGLPathTexGenProgramEffects, (reserveCount))) { |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 549 | } |
commit-bot@chromium.org | 0a6fe71 | 2014-04-23 19:26:26 +0000 | [diff] [blame] | 550 | void GrGLPathTexGenProgramEffectsBuilder::emitEffect(const GrEffectStage& stage, |
bsalomon | 63e99f7 | 2014-07-21 08:03:14 -0700 | [diff] [blame] | 551 | const GrEffectKey& key, |
commit-bot@chromium.org | 0a6fe71 | 2014-04-23 19:26:26 +0000 | [diff] [blame] | 552 | const char* outColor, |
| 553 | const char* inColor, |
| 554 | int stageIndex) { |
commit-bot@chromium.org | 6b30e45 | 2013-10-04 20:02:53 +0000 | [diff] [blame] | 555 | SkASSERT(NULL != fProgramEffects.get()); |
| 556 | fProgramEffects->emitEffect(fBuilder, stage, key, outColor, inColor, stageIndex); |
| 557 | } |
joshualitt | 30ba436 | 2014-08-21 20:18:45 -0700 | [diff] [blame] | 558 | |