| 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 "GrBezierEffect.h" | 8 #include "GrBezierEffect.h" |
| 9 | 9 |
| 10 #include "gl/builders/GrGLProgramBuilder.h" | 10 #include "gl/builders/GrGLProgramBuilder.h" |
| 11 #include "gl/GrGLProcessor.h" | 11 #include "gl/GrGLProcessor.h" |
| 12 #include "gl/GrGLSL.h" | 12 #include "gl/GrGLSL.h" |
| 13 #include "gl/GrGLGeometryProcessor.h" | 13 #include "gl/GrGLGeometryProcessor.h" |
| 14 #include "GrTBackendProcessorFactory.h" | 14 #include "GrTBackendProcessorFactory.h" |
| 15 | 15 |
| 16 class GrGLConicEffect : public GrGLGeometryProcessor { | 16 class GrGLConicEffect : public GrGLGeometryProcessor { |
| 17 public: | 17 public: |
| 18 GrGLConicEffect(const GrBackendProcessorFactory&, const GrProcessor&); | 18 GrGLConicEffect(const GrBackendProcessorFactory&, const GrProcessor&); |
| 19 | 19 |
| 20 virtual void emitCode(GrGLGPBuilder* builder, | 20 virtual void emitCode(const EmitArgs&) SK_OVERRIDE; |
| 21 const GrGeometryProcessor& geometryProcessor, | |
| 22 const GrProcessorKey& key, | |
| 23 const char* outputColor, | |
| 24 const char* inputColor, | |
| 25 const TransformedCoordsArray&, | |
| 26 const TextureSamplerArray&) SK_OVERRIDE; | |
| 27 | 21 |
| 28 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); | 22 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); |
| 29 | 23 |
| 30 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE {} | 24 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE {} |
| 31 | 25 |
| 32 private: | 26 private: |
| 33 GrPrimitiveEdgeType fEdgeType; | 27 GrPrimitiveEdgeType fEdgeType; |
| 34 | 28 |
| 35 typedef GrGLGeometryProcessor INHERITED; | 29 typedef GrGLGeometryProcessor INHERITED; |
| 36 }; | 30 }; |
| 37 | 31 |
| 38 GrGLConicEffect::GrGLConicEffect(const GrBackendProcessorFactory& factory, | 32 GrGLConicEffect::GrGLConicEffect(const GrBackendProcessorFactory& factory, |
| 39 const GrProcessor& effect) | 33 const GrProcessor& effect) |
| 40 : INHERITED (factory) { | 34 : INHERITED (factory) { |
| 41 const GrConicEffect& ce = effect.cast<GrConicEffect>(); | 35 const GrConicEffect& ce = effect.cast<GrConicEffect>(); |
| 42 fEdgeType = ce.getEdgeType(); | 36 fEdgeType = ce.getEdgeType(); |
| 43 } | 37 } |
| 44 | 38 |
| 45 void GrGLConicEffect::emitCode(GrGLGPBuilder* builder, | 39 void GrGLConicEffect::emitCode(const EmitArgs& args) { |
| 46 const GrGeometryProcessor& geometryProcessor, | |
| 47 const GrProcessorKey& key, | |
| 48 const char* outputColor, | |
| 49 const char* inputColor, | |
| 50 const TransformedCoordsArray&, | |
| 51 const TextureSamplerArray& samplers) { | |
| 52 const char *vsName, *fsName; | 40 const char *vsName, *fsName; |
| 53 | 41 |
| 54 builder->addVarying(kVec4f_GrSLType, "ConicCoeffs", | 42 args.fPB->addVarying(kVec4f_GrSLType, "ConicCoeffs", &vsName, &fsName); |
| 55 &vsName, &fsName); | |
| 56 | 43 |
| 57 const GrShaderVar& inConicCoeffs = geometryProcessor.cast<GrConicEffect>().i
nConicCoeffs(); | 44 const GrShaderVar& inConicCoeffs = args.fGP.cast<GrConicEffect>().inConicCoe
ffs(); |
| 58 GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder(); | 45 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 59 vsBuilder->codeAppendf("%s = %s;", vsName, inConicCoeffs.c_str()); | 46 vsBuilder->codeAppendf("%s = %s;", vsName, inConicCoeffs.c_str()); |
| 60 | 47 |
| 61 GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 48 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
| 62 fsBuilder->codeAppend("float edgeAlpha;"); | 49 fsBuilder->codeAppend("float edgeAlpha;"); |
| 63 | 50 |
| 64 switch (fEdgeType) { | 51 switch (fEdgeType) { |
| 65 case kHairlineAA_GrProcessorEdgeType: { | 52 case kHairlineAA_GrProcessorEdgeType: { |
| 66 SkAssertResult(fsBuilder->enableFeature( | 53 SkAssertResult(fsBuilder->enableFeature( |
| 67 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 54 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); |
| 68 fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", fsName); | 55 fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", fsName); |
| 69 fsBuilder->codeAppendf("vec3 dklmdy = dFdy(%s.xyz);", fsName); | 56 fsBuilder->codeAppendf("vec3 dklmdy = dFdy(%s.xyz);", fsName); |
| 70 fsBuilder->codeAppendf("float dfdx =" | 57 fsBuilder->codeAppendf("float dfdx =" |
| 71 "2.0 * %s.x * dklmdx.x - %s.y * dklmdx.z - %s
.z * dklmdx.y;", | 58 "2.0 * %s.x * dklmdx.x - %s.y * dklmdx.z - %s
.z * dklmdx.y;", |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 case kFillBW_GrProcessorEdgeType: { | 95 case kFillBW_GrProcessorEdgeType: { |
| 109 fsBuilder->codeAppendf("edgeAlpha = %s.x * %s.x - %s.y * %s.z;", fsN
ame, fsName, | 96 fsBuilder->codeAppendf("edgeAlpha = %s.x * %s.x - %s.y * %s.z;", fsN
ame, fsName, |
| 110 fsName, fsName); | 97 fsName, fsName); |
| 111 fsBuilder->codeAppend("edgeAlpha = float(edgeAlpha < 0.0);"); | 98 fsBuilder->codeAppend("edgeAlpha = float(edgeAlpha < 0.0);"); |
| 112 break; | 99 break; |
| 113 } | 100 } |
| 114 default: | 101 default: |
| 115 SkFAIL("Shouldn't get here"); | 102 SkFAIL("Shouldn't get here"); |
| 116 } | 103 } |
| 117 | 104 |
| 118 fsBuilder->codeAppendf("%s = %s;", outputColor, | 105 fsBuilder->codeAppendf("%s = %s;", args.fOutput, |
| 119 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).
c_str()); | 106 (GrGLSLExpr4(args.fInput) * GrGLSLExpr1("edgeAlpha"))
.c_str()); |
| 120 } | 107 } |
| 121 | 108 |
| 122 void GrGLConicEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, | 109 void GrGLConicEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, |
| 123 GrProcessorKeyBuilder* b) { | 110 GrProcessorKeyBuilder* b) { |
| 124 const GrConicEffect& ce = processor.cast<GrConicEffect>(); | 111 const GrConicEffect& ce = processor.cast<GrConicEffect>(); |
| 125 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; | 112 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; |
| 126 b->add32(key); | 113 b->add32(key); |
| 127 } | 114 } |
| 128 | 115 |
| 129 ////////////////////////////////////////////////////////////////////////////// | 116 ////////////////////////////////////////////////////////////////////////////// |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 151 } |
| 165 | 152 |
| 166 ////////////////////////////////////////////////////////////////////////////// | 153 ////////////////////////////////////////////////////////////////////////////// |
| 167 // Quad | 154 // Quad |
| 168 ////////////////////////////////////////////////////////////////////////////// | 155 ////////////////////////////////////////////////////////////////////////////// |
| 169 | 156 |
| 170 class GrGLQuadEffect : public GrGLGeometryProcessor { | 157 class GrGLQuadEffect : public GrGLGeometryProcessor { |
| 171 public: | 158 public: |
| 172 GrGLQuadEffect(const GrBackendProcessorFactory&, const GrProcessor&); | 159 GrGLQuadEffect(const GrBackendProcessorFactory&, const GrProcessor&); |
| 173 | 160 |
| 174 virtual void emitCode(GrGLGPBuilder* builder, | 161 virtual void emitCode(const EmitArgs&) SK_OVERRIDE; |
| 175 const GrGeometryProcessor& geometryProcessor, | |
| 176 const GrProcessorKey& key, | |
| 177 const char* outputColor, | |
| 178 const char* inputColor, | |
| 179 const TransformedCoordsArray&, | |
| 180 const TextureSamplerArray&) SK_OVERRIDE; | |
| 181 | 162 |
| 182 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); | 163 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); |
| 183 | 164 |
| 184 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE {} | 165 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE {} |
| 185 | 166 |
| 186 private: | 167 private: |
| 187 GrPrimitiveEdgeType fEdgeType; | 168 GrPrimitiveEdgeType fEdgeType; |
| 188 | 169 |
| 189 typedef GrGLGeometryProcessor INHERITED; | 170 typedef GrGLGeometryProcessor INHERITED; |
| 190 }; | 171 }; |
| 191 | 172 |
| 192 GrGLQuadEffect::GrGLQuadEffect(const GrBackendProcessorFactory& factory, | 173 GrGLQuadEffect::GrGLQuadEffect(const GrBackendProcessorFactory& factory, |
| 193 const GrProcessor& effect) | 174 const GrProcessor& effect) |
| 194 : INHERITED (factory) { | 175 : INHERITED (factory) { |
| 195 const GrQuadEffect& ce = effect.cast<GrQuadEffect>(); | 176 const GrQuadEffect& ce = effect.cast<GrQuadEffect>(); |
| 196 fEdgeType = ce.getEdgeType(); | 177 fEdgeType = ce.getEdgeType(); |
| 197 } | 178 } |
| 198 | 179 |
| 199 void GrGLQuadEffect::emitCode(GrGLGPBuilder* builder, | 180 void GrGLQuadEffect::emitCode(const EmitArgs& args) { |
| 200 const GrGeometryProcessor& geometryProcessor, | |
| 201 const GrProcessorKey& key, | |
| 202 const char* outputColor, | |
| 203 const char* inputColor, | |
| 204 const TransformedCoordsArray&, | |
| 205 const TextureSamplerArray& samplers) { | |
| 206 const char *vsName, *fsName; | 181 const char *vsName, *fsName; |
| 207 builder->addVarying(kVec4f_GrSLType, "HairQuadEdge", &vsName, &fsName); | 182 args.fPB->addVarying(kVec4f_GrSLType, "HairQuadEdge", &vsName, &fsName); |
| 208 | 183 |
| 209 GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder(); | 184 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 210 const GrShaderVar& inHairQuadEdge = geometryProcessor.cast<GrQuadEffect>().i
nHairQuadEdge(); | 185 const GrShaderVar& inHairQuadEdge = args.fGP.cast<GrQuadEffect>().inHairQuad
Edge(); |
| 211 vsBuilder->codeAppendf("%s = %s;", vsName, inHairQuadEdge.c_str()); | 186 vsBuilder->codeAppendf("%s = %s;", vsName, inHairQuadEdge.c_str()); |
| 212 | 187 |
| 213 GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 188 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
| 214 fsBuilder->codeAppendf("float edgeAlpha;"); | 189 fsBuilder->codeAppendf("float edgeAlpha;"); |
| 215 | 190 |
| 216 switch (fEdgeType) { | 191 switch (fEdgeType) { |
| 217 case kHairlineAA_GrProcessorEdgeType: { | 192 case kHairlineAA_GrProcessorEdgeType: { |
| 218 SkAssertResult(fsBuilder->enableFeature( | 193 SkAssertResult(fsBuilder->enableFeature( |
| 219 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 194 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); |
| 220 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", fsName); | 195 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", fsName); |
| 221 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", fsName); | 196 fsBuilder->codeAppendf("vec2 duvdy = dFdy(%s.xy);", fsName); |
| 222 fsBuilder->codeAppendf("vec2 gF = vec2(2.0 * %s.x * duvdx.x - duvdx.
y," | 197 fsBuilder->codeAppendf("vec2 gF = vec2(2.0 * %s.x * duvdx.x - duvdx.
y," |
| 223 " 2.0 * %s.x * duvdy.x - duvdy.
y);", | 198 " 2.0 * %s.x * duvdy.x - duvdy.
y);", |
| (...skipping 22 matching lines...) Expand all Loading... |
| 246 } | 221 } |
| 247 case kFillBW_GrProcessorEdgeType: { | 222 case kFillBW_GrProcessorEdgeType: { |
| 248 fsBuilder->codeAppendf("edgeAlpha = (%s.x * %s.x - %s.y);", fsName,
fsName, fsName); | 223 fsBuilder->codeAppendf("edgeAlpha = (%s.x * %s.x - %s.y);", fsName,
fsName, fsName); |
| 249 fsBuilder->codeAppend("edgeAlpha = float(edgeAlpha < 0.0);"); | 224 fsBuilder->codeAppend("edgeAlpha = float(edgeAlpha < 0.0);"); |
| 250 break; | 225 break; |
| 251 } | 226 } |
| 252 default: | 227 default: |
| 253 SkFAIL("Shouldn't get here"); | 228 SkFAIL("Shouldn't get here"); |
| 254 } | 229 } |
| 255 | 230 |
| 256 fsBuilder->codeAppendf("%s = %s;", outputColor, | 231 fsBuilder->codeAppendf("%s = %s;", args.fOutput, |
| 257 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).
c_str()); | 232 (GrGLSLExpr4(args.fInput) * GrGLSLExpr1("edgeAlpha"))
.c_str()); |
| 258 } | 233 } |
| 259 | 234 |
| 260 void GrGLQuadEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, | 235 void GrGLQuadEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, |
| 261 GrProcessorKeyBuilder* b) { | 236 GrProcessorKeyBuilder* b) { |
| 262 const GrQuadEffect& ce = processor.cast<GrQuadEffect>(); | 237 const GrQuadEffect& ce = processor.cast<GrQuadEffect>(); |
| 263 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; | 238 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; |
| 264 b->add32(key); | 239 b->add32(key); |
| 265 } | 240 } |
| 266 | 241 |
| 267 ////////////////////////////////////////////////////////////////////////////// | 242 ////////////////////////////////////////////////////////////////////////////// |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 302 } | 277 } |
| 303 | 278 |
| 304 ////////////////////////////////////////////////////////////////////////////// | 279 ////////////////////////////////////////////////////////////////////////////// |
| 305 // Cubic | 280 // Cubic |
| 306 ////////////////////////////////////////////////////////////////////////////// | 281 ////////////////////////////////////////////////////////////////////////////// |
| 307 | 282 |
| 308 class GrGLCubicEffect : public GrGLGeometryProcessor { | 283 class GrGLCubicEffect : public GrGLGeometryProcessor { |
| 309 public: | 284 public: |
| 310 GrGLCubicEffect(const GrBackendProcessorFactory&, const GrProcessor&); | 285 GrGLCubicEffect(const GrBackendProcessorFactory&, const GrProcessor&); |
| 311 | 286 |
| 312 virtual void emitCode(GrGLGPBuilder* builder, | 287 virtual void emitCode(const EmitArgs&) SK_OVERRIDE; |
| 313 const GrGeometryProcessor& geometryProcessor, | |
| 314 const GrProcessorKey& key, | |
| 315 const char* outputColor, | |
| 316 const char* inputColor, | |
| 317 const TransformedCoordsArray&, | |
| 318 const TextureSamplerArray&) SK_OVERRIDE; | |
| 319 | 288 |
| 320 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); | 289 static inline void GenKey(const GrProcessor&, const GrGLCaps&, GrProcessorKe
yBuilder*); |
| 321 | 290 |
| 322 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE {} | 291 virtual void setData(const GrGLProgramDataManager&, const GrProcessor&) SK_O
VERRIDE {} |
| 323 | 292 |
| 324 private: | 293 private: |
| 325 GrPrimitiveEdgeType fEdgeType; | 294 GrPrimitiveEdgeType fEdgeType; |
| 326 | 295 |
| 327 typedef GrGLGeometryProcessor INHERITED; | 296 typedef GrGLGeometryProcessor INHERITED; |
| 328 }; | 297 }; |
| 329 | 298 |
| 330 GrGLCubicEffect::GrGLCubicEffect(const GrBackendProcessorFactory& factory, | 299 GrGLCubicEffect::GrGLCubicEffect(const GrBackendProcessorFactory& factory, |
| 331 const GrProcessor& processor) | 300 const GrProcessor& processor) |
| 332 : INHERITED (factory) { | 301 : INHERITED (factory) { |
| 333 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); | 302 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); |
| 334 fEdgeType = ce.getEdgeType(); | 303 fEdgeType = ce.getEdgeType(); |
| 335 } | 304 } |
| 336 | 305 |
| 337 void GrGLCubicEffect::emitCode(GrGLGPBuilder* builder, | 306 void GrGLCubicEffect::emitCode(const EmitArgs& args) { |
| 338 const GrGeometryProcessor& geometryProcessor, | |
| 339 const GrProcessorKey& key, | |
| 340 const char* outputColor, | |
| 341 const char* inputColor, | |
| 342 const TransformedCoordsArray&, | |
| 343 const TextureSamplerArray& samplers) { | |
| 344 const char *vsName, *fsName; | 307 const char *vsName, *fsName; |
| 345 | 308 |
| 346 builder->addVarying(kVec4f_GrSLType, "CubicCoeffs", | 309 args.fPB->addVarying(kVec4f_GrSLType, "CubicCoeffs", |
| 347 &vsName, &fsName, GrGLShaderVar::kHigh_Precision); | 310 &vsName, &fsName, GrGLShaderVar::kHigh_Precision); |
| 348 | 311 |
| 349 GrGLVertexBuilder* vsBuilder = builder->getVertexShaderBuilder(); | 312 GrGLVertexBuilder* vsBuilder = args.fPB->getVertexShaderBuilder(); |
| 350 const GrShaderVar& inCubicCoeffs = geometryProcessor.cast<GrCubicEffect>().i
nCubicCoeffs(); | 313 const GrShaderVar& inCubicCoeffs = args.fGP.cast<GrCubicEffect>().inCubicCoe
ffs(); |
| 351 vsBuilder->codeAppendf("%s = %s;", vsName, inCubicCoeffs.c_str()); | 314 vsBuilder->codeAppendf("%s = %s;", vsName, inCubicCoeffs.c_str()); |
| 352 | 315 |
| 353 GrGLGPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder(); | 316 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
| 354 | 317 |
| 355 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, GrGLShaderVar::kHig
h_Precision); | 318 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, GrGLShaderVar::kHig
h_Precision); |
| 356 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec
ision); | 319 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec
ision); |
| 357 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec
ision); | 320 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec
ision); |
| 358 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio
n); | 321 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio
n); |
| 359 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio
n); | 322 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio
n); |
| 360 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, GrGLShaderVar::kHigh_Precision); | 323 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, GrGLShaderVar::kHigh_Precision); |
| 361 GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precision)
; | 324 GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precision)
; |
| 362 GrGLShaderVar func("func", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio
n); | 325 GrGLShaderVar func("func", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio
n); |
| 363 | 326 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 case kFillBW_GrProcessorEdgeType: { | 389 case kFillBW_GrProcessorEdgeType: { |
| 427 fsBuilder->codeAppendf("%s = %s.x * %s.x * %s.x - %s.y * %s.z;", | 390 fsBuilder->codeAppendf("%s = %s.x * %s.x * %s.x - %s.y * %s.z;", |
| 428 edgeAlpha.c_str(), fsName, fsName, fsName, fs
Name, fsName); | 391 edgeAlpha.c_str(), fsName, fsName, fsName, fs
Name, fsName); |
| 429 fsBuilder->codeAppendf("%s = float(%s < 0.0);", edgeAlpha.c_str(), e
dgeAlpha.c_str()); | 392 fsBuilder->codeAppendf("%s = float(%s < 0.0);", edgeAlpha.c_str(), e
dgeAlpha.c_str()); |
| 430 break; | 393 break; |
| 431 } | 394 } |
| 432 default: | 395 default: |
| 433 SkFAIL("Shouldn't get here"); | 396 SkFAIL("Shouldn't get here"); |
| 434 } | 397 } |
| 435 | 398 |
| 436 fsBuilder->codeAppendf("%s = %s;", outputColor, | 399 fsBuilder->codeAppendf("%s = %s;", args.fOutput, |
| 437 (GrGLSLExpr4(inputColor) * GrGLSLExpr1(edgeAlpha.c_st
r())).c_str()); | 400 (GrGLSLExpr4(args.fInput) * GrGLSLExpr1(edgeAlpha.c_s
tr())).c_str()); |
| 438 } | 401 } |
| 439 | 402 |
| 440 void GrGLCubicEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, | 403 void GrGLCubicEffect::GenKey(const GrProcessor& processor, const GrGLCaps&, |
| 441 GrProcessorKeyBuilder* b) { | 404 GrProcessorKeyBuilder* b) { |
| 442 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); | 405 const GrCubicEffect& ce = processor.cast<GrCubicEffect>(); |
| 443 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; | 406 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; |
| 444 b->add32(key); | 407 b->add32(key); |
| 445 } | 408 } |
| 446 | 409 |
| 447 ////////////////////////////////////////////////////////////////////////////// | 410 ////////////////////////////////////////////////////////////////////////////// |
| (...skipping 26 matching lines...) Expand all Loading... |
| 474 GrTexture*[]) { | 437 GrTexture*[]) { |
| 475 GrGeometryProcessor* gp; | 438 GrGeometryProcessor* gp; |
| 476 do { | 439 do { |
| 477 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 440 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
| 478 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); | 441 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); |
| 479 gp = GrCubicEffect::Create(edgeType, caps); | 442 gp = GrCubicEffect::Create(edgeType, caps); |
| 480 } while (NULL == gp); | 443 } while (NULL == gp); |
| 481 return gp; | 444 return gp; |
| 482 } | 445 } |
| 483 | 446 |
| OLD | NEW |