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/GrGLProcessor.h" | 10 #include "gl/GrGLProcessor.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 const GrBatchTracker&); | 25 const GrBatchTracker&); |
26 | 26 |
27 virtual void emitCode(const EmitArgs&) SK_OVERRIDE; | 27 virtual void emitCode(const EmitArgs&) SK_OVERRIDE; |
28 | 28 |
29 static inline void GenKey(const GrGeometryProcessor&, | 29 static inline void GenKey(const GrGeometryProcessor&, |
30 const GrBatchTracker&, | 30 const GrBatchTracker&, |
31 const GrGLCaps&, | 31 const GrGLCaps&, |
32 GrProcessorKeyBuilder*); | 32 GrProcessorKeyBuilder*); |
33 | 33 |
34 virtual void setData(const GrGLProgramDataManager& pdman, | 34 virtual void setData(const GrGLProgramDataManager& pdman, |
35 const GrPrimitiveProcessor&, | 35 const GrPrimitiveProcessor& primProc, |
36 const GrBatchTracker& bt) SK_OVERRIDE { | 36 const GrBatchTracker& bt) SK_OVERRIDE { |
| 37 this->setUniformViewMatrix(pdman, primProc.viewMatrix()); |
| 38 |
37 const ConicBatchTracker& local = bt.cast<ConicBatchTracker>(); | 39 const ConicBatchTracker& local = bt.cast<ConicBatchTracker>(); |
38 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { | 40 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { |
39 GrGLfloat c[4]; | 41 GrGLfloat c[4]; |
40 GrColorToRGBAFloat(local.fColor, c); | 42 GrColorToRGBAFloat(local.fColor, c); |
41 pdman.set4fv(fColorUniform, 1, c); | 43 pdman.set4fv(fColorUniform, 1, c); |
42 fColor = local.fColor; | 44 fColor = local.fColor; |
43 } | 45 } |
44 if (0xff != local.fCoverageScale && fCoverageScale != local.fCoverageSca
le) { | 46 if (0xff != local.fCoverageScale && fCoverageScale != local.fCoverageSca
le) { |
45 pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(local.fCov
erageScale)); | 47 pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(local.fCov
erageScale)); |
46 fCoverageScale = local.fCoverageScale; | 48 fCoverageScale = local.fCoverageScale; |
(...skipping 28 matching lines...) Expand all Loading... |
75 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->fName); | 77 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inConicCoeffs()->fName); |
76 | 78 |
77 // Setup pass through color | 79 // Setup pass through color |
78 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, | 80 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, |
79 &fColorUniform); | 81 &fColorUniform); |
80 | 82 |
81 // setup coord outputs | 83 // setup coord outputs |
82 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPositio
n()->fName); | 84 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPositio
n()->fName); |
83 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()
->fName); | 85 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()
->fName); |
84 | 86 |
| 87 // setup uniform viewMatrix |
| 88 this->addUniformViewMatrix(pb); |
| 89 |
85 // setup position varying | 90 // setup position varying |
86 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), vs
Builder->uViewM(), | 91 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), th
is->uViewM(), |
87 gp.inPosition()->fName); | 92 gp.inPosition()->fName); |
88 | 93 |
89 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 94 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
90 fsBuilder->codeAppend("float edgeAlpha;"); | 95 fsBuilder->codeAppend("float edgeAlpha;"); |
91 | 96 |
92 switch (fEdgeType) { | 97 switch (fEdgeType) { |
93 case kHairlineAA_GrProcessorEdgeType: { | 98 case kHairlineAA_GrProcessorEdgeType: { |
94 SkAssertResult(fsBuilder->enableFeature( | 99 SkAssertResult(fsBuilder->enableFeature( |
95 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 100 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); |
96 fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", v.fsIn()); | 101 fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", v.fsIn()); |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 const GrBatchTracker&); | 259 const GrBatchTracker&); |
255 | 260 |
256 virtual void emitCode(const EmitArgs&) SK_OVERRIDE; | 261 virtual void emitCode(const EmitArgs&) SK_OVERRIDE; |
257 | 262 |
258 static inline void GenKey(const GrGeometryProcessor&, | 263 static inline void GenKey(const GrGeometryProcessor&, |
259 const GrBatchTracker&, | 264 const GrBatchTracker&, |
260 const GrGLCaps&, | 265 const GrGLCaps&, |
261 GrProcessorKeyBuilder*); | 266 GrProcessorKeyBuilder*); |
262 | 267 |
263 virtual void setData(const GrGLProgramDataManager& pdman, | 268 virtual void setData(const GrGLProgramDataManager& pdman, |
264 const GrPrimitiveProcessor&, | 269 const GrPrimitiveProcessor& primProc, |
265 const GrBatchTracker& bt) SK_OVERRIDE { | 270 const GrBatchTracker& bt) SK_OVERRIDE { |
| 271 this->setUniformViewMatrix(pdman, primProc.viewMatrix()); |
| 272 |
266 const QuadBatchTracker& local = bt.cast<QuadBatchTracker>(); | 273 const QuadBatchTracker& local = bt.cast<QuadBatchTracker>(); |
267 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { | 274 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { |
268 GrGLfloat c[4]; | 275 GrGLfloat c[4]; |
269 GrColorToRGBAFloat(local.fColor, c); | 276 GrColorToRGBAFloat(local.fColor, c); |
270 pdman.set4fv(fColorUniform, 1, c); | 277 pdman.set4fv(fColorUniform, 1, c); |
271 fColor = local.fColor; | 278 fColor = local.fColor; |
272 } | 279 } |
273 if (0xff != local.fCoverageScale && local.fCoverageScale != fCoverageSca
le) { | 280 if (0xff != local.fCoverageScale && local.fCoverageScale != fCoverageSca
le) { |
274 pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(local.fCov
erageScale)); | 281 pdman.set1f(fCoverageScaleUniform, GrNormalizeByteToFloat(local.fCov
erageScale)); |
275 fCoverageScale = local.fCoverageScale; | 282 fCoverageScale = local.fCoverageScale; |
(...skipping 28 matching lines...) Expand all Loading... |
304 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName); | 311 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inHairQuadEdge()->fName); |
305 | 312 |
306 // Setup pass through color | 313 // Setup pass through color |
307 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, | 314 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, |
308 &fColorUniform); | 315 &fColorUniform); |
309 | 316 |
310 // setup coord outputs | 317 // setup coord outputs |
311 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPositio
n()->fName); | 318 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPositio
n()->fName); |
312 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()
->fName); | 319 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()
->fName); |
313 | 320 |
| 321 // setup uniform viewMatrix |
| 322 this->addUniformViewMatrix(pb); |
| 323 |
314 // setup position varying | 324 // setup position varying |
315 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), vs
Builder->uViewM(), | 325 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), th
is->uViewM(), |
316 gp.inPosition()->fName); | 326 gp.inPosition()->fName); |
317 | 327 |
318 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 328 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
319 fsBuilder->codeAppendf("float edgeAlpha;"); | 329 fsBuilder->codeAppendf("float edgeAlpha;"); |
320 | 330 |
321 switch (fEdgeType) { | 331 switch (fEdgeType) { |
322 case kHairlineAA_GrProcessorEdgeType: { | 332 case kHairlineAA_GrProcessorEdgeType: { |
323 SkAssertResult(fsBuilder->enableFeature( | 333 SkAssertResult(fsBuilder->enableFeature( |
324 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); | 334 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature)
); |
325 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); | 335 fsBuilder->codeAppendf("vec2 duvdx = dFdx(%s.xy);", v.fsIn()); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 const GrBatchTracker&); | 479 const GrBatchTracker&); |
470 | 480 |
471 virtual void emitCode(const EmitArgs&) SK_OVERRIDE; | 481 virtual void emitCode(const EmitArgs&) SK_OVERRIDE; |
472 | 482 |
473 static inline void GenKey(const GrGeometryProcessor&, | 483 static inline void GenKey(const GrGeometryProcessor&, |
474 const GrBatchTracker&, | 484 const GrBatchTracker&, |
475 const GrGLCaps&, | 485 const GrGLCaps&, |
476 GrProcessorKeyBuilder*); | 486 GrProcessorKeyBuilder*); |
477 | 487 |
478 virtual void setData(const GrGLProgramDataManager& pdman, | 488 virtual void setData(const GrGLProgramDataManager& pdman, |
479 const GrPrimitiveProcessor&, | 489 const GrPrimitiveProcessor& primProc, |
480 const GrBatchTracker& bt) SK_OVERRIDE { | 490 const GrBatchTracker& bt) SK_OVERRIDE { |
| 491 this->setUniformViewMatrix(pdman, primProc.viewMatrix()); |
| 492 |
481 const CubicBatchTracker& local = bt.cast<CubicBatchTracker>(); | 493 const CubicBatchTracker& local = bt.cast<CubicBatchTracker>(); |
482 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { | 494 if (kUniform_GrGPInput == local.fInputColorType && local.fColor != fColo
r) { |
483 GrGLfloat c[4]; | 495 GrGLfloat c[4]; |
484 GrColorToRGBAFloat(local.fColor, c); | 496 GrColorToRGBAFloat(local.fColor, c); |
485 pdman.set4fv(fColorUniform, 1, c); | 497 pdman.set4fv(fColorUniform, 1, c); |
486 fColor = local.fColor; | 498 fColor = local.fColor; |
487 } | 499 } |
488 } | 500 } |
489 | 501 |
490 private: | 502 private: |
(...skipping 21 matching lines...) Expand all Loading... |
512 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName); | 524 vsBuilder->codeAppendf("%s = %s;", v.vsOut(), gp.inCubicCoeffs()->fName); |
513 | 525 |
514 // Setup pass through color | 526 // Setup pass through color |
515 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, | 527 this->setupColorPassThrough(args.fPB, local.fInputColorType, args.fOutputCol
or, NULL, |
516 &fColorUniform); | 528 &fColorUniform); |
517 | 529 |
518 // setup coord outputs | 530 // setup coord outputs |
519 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPositio
n()->fName); | 531 vsBuilder->codeAppendf("%s = %s;", vsBuilder->positionCoords(), gp.inPositio
n()->fName); |
520 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()
->fName); | 532 vsBuilder->codeAppendf("%s = %s;", vsBuilder->localCoords(), gp.inPosition()
->fName); |
521 | 533 |
| 534 // setup uniform viewMatrix |
| 535 this->addUniformViewMatrix(args.fPB); |
| 536 |
522 // setup position varying | 537 // setup position varying |
523 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), vs
Builder->uViewM(), | 538 vsBuilder->codeAppendf("%s = %s * vec3(%s, 1);", vsBuilder->glPosition(), th
is->uViewM(), |
524 gp.inPosition()->fName); | 539 gp.inPosition()->fName); |
525 | 540 |
526 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); | 541 GrGLGPFragmentBuilder* fsBuilder = args.fPB->getFragmentShaderBuilder(); |
527 | 542 |
528 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision
); | 543 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, kHigh_GrSLPrecision
); |
529 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); | 544 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); |
530 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); | 545 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, kHigh_GrSLPrecision); |
531 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, kHigh_GrSLPrecision); | 546 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, kHigh_GrSLPrecision); |
532 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, kHigh_GrSLPrecision); | 547 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, kHigh_GrSLPrecision); |
533 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, kHigh_GrSLPrecision); | 548 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, kHigh_GrSLPrecision); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 GrGeometryProcessor* gp; | 693 GrGeometryProcessor* gp; |
679 do { | 694 do { |
680 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( | 695 GrPrimitiveEdgeType edgeType = static_cast<GrPrimitiveEdgeType>( |
681 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); | 696 random->nextULessThan(kGrPro
cessorEdgeTypeCnt)); |
682 gp = GrCubicEffect::Create(GrRandomColor(random), | 697 gp = GrCubicEffect::Create(GrRandomColor(random), |
683 GrProcessorUnitTest::TestMatrix(random), edge
Type, caps); | 698 GrProcessorUnitTest::TestMatrix(random), edge
Type, caps); |
684 } while (NULL == gp); | 699 } while (NULL == gp); |
685 return gp; | 700 return gp; |
686 } | 701 } |
687 | 702 |
OLD | NEW |