| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include "GrAAConvexPathRenderer.h" | 9 #include "GrAAConvexPathRenderer.h" |
| 10 | 10 |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 | 524 |
| 525 class GLEffect : public GrGLVertexEffect { | 525 class GLEffect : public GrGLVertexEffect { |
| 526 public: | 526 public: |
| 527 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&) | 527 GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&) |
| 528 : INHERITED (factory) {} | 528 : INHERITED (factory) {} |
| 529 | 529 |
| 530 virtual void emitCode(GrGLFullShaderBuilder* builder, | 530 virtual void emitCode(GrGLFullShaderBuilder* builder, |
| 531 const GrDrawEffect& drawEffect, | 531 const GrDrawEffect& drawEffect, |
| 532 EffectKey key, | 532 EffectKey key, |
| 533 const char* outputColor, | 533 const char* outputColor, |
| 534 const char* inputColor, | 534 const GrGLSLExpr4& inputColor, |
| 535 const TransformedCoordsArray&, | 535 const TransformedCoordsArray&, |
| 536 const TextureSamplerArray& samplers) SK_OVERRIDE { | 536 const TextureSamplerArray& samplers) SK_OVERRIDE { |
| 537 const char *vsName, *fsName; | 537 const char *vsName, *fsName; |
| 538 const SkString* attrName = | 538 const SkString* attrName = |
| 539 builder->getEffectAttributeName(drawEffect.getVertexAttribIndice
s()[0]); | 539 builder->getEffectAttributeName(drawEffect.getVertexAttribIndice
s()[0]); |
| 540 builder->fsCodeAppendf("\t\tfloat edgeAlpha;\n"); | 540 builder->fsCodeAppendf("\t\tfloat edgeAlpha;\n"); |
| 541 | 541 |
| 542 SkAssertResult(builder->enableFeature( | 542 SkAssertResult(builder->enableFeature( |
| 543 GrGLShaderBuilder::kStandardDeriva
tives_GLSLFeature)); | 543 GrGLShaderBuilder::kStandardDeriva
tives_GLSLFeature)); |
| 544 builder->addVarying(kVec4f_GrSLType, "QuadEdge", &vsName, &fsName); | 544 builder->addVarying(kVec4f_GrSLType, "QuadEdge", &vsName, &fsName); |
| 545 | 545 |
| 546 // keep the derivative instructions outside the conditional | 546 // keep the derivative instructions outside the conditional |
| 547 builder->fsCodeAppendf("\t\tvec2 duvdx = dFdx(%s.xy);\n", fsName); | 547 builder->fsCodeAppendf("\t\tvec2 duvdx = dFdx(%s.xy);\n", fsName); |
| 548 builder->fsCodeAppendf("\t\tvec2 duvdy = dFdy(%s.xy);\n", fsName); | 548 builder->fsCodeAppendf("\t\tvec2 duvdy = dFdy(%s.xy);\n", fsName); |
| 549 builder->fsCodeAppendf("\t\tif (%s.z > 0.0 && %s.w > 0.0) {\n", fsNa
me, fsName); | 549 builder->fsCodeAppendf("\t\tif (%s.z > 0.0 && %s.w > 0.0) {\n", fsNa
me, fsName); |
| 550 // today we know z and w are in device space. We could use derivativ
es | 550 // today we know z and w are in device space. We could use derivativ
es |
| 551 builder->fsCodeAppendf("\t\t\tedgeAlpha = min(min(%s.z, %s.w) + 0.5,
1.0);\n", fsName, | 551 builder->fsCodeAppendf("\t\t\tedgeAlpha = min(min(%s.z, %s.w) + 0.5,
1.0);\n", fsName, |
| 552 fsName); | 552 fsName); |
| 553 builder->fsCodeAppendf ("\t\t} else {\n"); | 553 builder->fsCodeAppendf ("\t\t} else {\n"); |
| 554 builder->fsCodeAppendf("\t\t\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvd
x.y,\n" | 554 builder->fsCodeAppendf("\t\t\tvec2 gF = vec2(2.0*%s.x*duvdx.x - duvd
x.y,\n" |
| 555 "\t\t\t 2.0*%s.x*duvdy.x - duvd
y.y);\n", | 555 "\t\t\t 2.0*%s.x*duvdy.x - duvd
y.y);\n", |
| 556 fsName, fsName); | 556 fsName, fsName); |
| 557 builder->fsCodeAppendf("\t\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fs
Name, fsName, | 557 builder->fsCodeAppendf("\t\t\tedgeAlpha = (%s.x*%s.x - %s.y);\n", fs
Name, fsName, |
| 558 fsName); | 558 fsName); |
| 559 builder->fsCodeAppendf("\t\t\tedgeAlpha = " | 559 builder->fsCodeAppendf("\t\t\tedgeAlpha = " |
| 560 "clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0
);\n\t\t}\n"); | 560 "clamp(0.5 - edgeAlpha / length(gF), 0.0, 1.0
);\n\t\t}\n"); |
| 561 | 561 |
| 562 | 562 |
| 563 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, | 563 builder->fsCodeAppendf("\t%s = %s;\n", outputColor, |
| 564 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeA
lpha")).c_str()); | 564 (inputColor * GrGLSLExpr1("edgeAlpha")).c_str
()); |
| 565 | 565 |
| 566 builder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str()); | 566 builder->vsCodeAppendf("\t%s = %s;\n", vsName, attrName->c_str()); |
| 567 } | 567 } |
| 568 | 568 |
| 569 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG
LCaps&) { | 569 static inline EffectKey GenKey(const GrDrawEffect& drawEffect, const GrG
LCaps&) { |
| 570 return 0x0; | 570 return 0x0; |
| 571 } | 571 } |
| 572 | 572 |
| 573 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_
OVERRIDE {} | 573 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_
OVERRIDE {} |
| 574 | 574 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 705 vOffset, // start vertex | 705 vOffset, // start vertex |
| 706 0, // start index | 706 0, // start index |
| 707 draw.fVertexCnt, | 707 draw.fVertexCnt, |
| 708 draw.fIndexCnt, | 708 draw.fIndexCnt, |
| 709 &devBounds); | 709 &devBounds); |
| 710 vOffset += draw.fVertexCnt; | 710 vOffset += draw.fVertexCnt; |
| 711 } | 711 } |
| 712 | 712 |
| 713 return true; | 713 return true; |
| 714 } | 714 } |
| OLD | NEW |