OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "GrDashingEffect.h" | 8 #include "GrDashingEffect.h" |
9 | 9 |
10 #include "../GrAARectRenderer.h" | 10 #include "../GrAARectRenderer.h" |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 builder->vsCodeAppendf("\t%s = %s;\n", vsCoordName, attr0Name->c_str()); | 519 builder->vsCodeAppendf("\t%s = %s;\n", vsCoordName, attr0Name->c_str()); |
520 | 520 |
521 // transforms all points so that we can compare them to our test circle | 521 // transforms all points so that we can compare them to our test circle |
522 builder->fsCodeAppendf("\t\tfloat xShifted = %s.x - floor(%s.x / %s.z) * %s.
z;\n", | 522 builder->fsCodeAppendf("\t\tfloat xShifted = %s.x - floor(%s.x / %s.z) * %s.
z;\n", |
523 fsCoordName, fsCoordName, paramName, paramName); | 523 fsCoordName, fsCoordName, paramName, paramName); |
524 builder->fsCodeAppendf("\t\tvec2 fragPosShifted = vec2(xShifted, %s.y);\n",
fsCoordName); | 524 builder->fsCodeAppendf("\t\tvec2 fragPosShifted = vec2(xShifted, %s.y);\n",
fsCoordName); |
525 builder->fsCodeAppendf("\t\tvec2 center = vec2(%s.y, 0.0);\n", paramName); | 525 builder->fsCodeAppendf("\t\tvec2 center = vec2(%s.y, 0.0);\n", paramName); |
526 builder->fsCodeAppend("\t\tfloat dist = length(center - fragPosShifted);\n")
; | 526 builder->fsCodeAppend("\t\tfloat dist = length(center - fragPosShifted);\n")
; |
527 if (GrEffectEdgeTypeIsAA(dce.getEdgeType())) { | 527 if (GrEffectEdgeTypeIsAA(dce.getEdgeType())) { |
528 builder->fsCodeAppendf("\t\tfloat diff = dist - %s.x;\n", paramName); | 528 builder->fsCodeAppendf("\t\tfloat diff = dist - %s.x;\n", paramName); |
529 builder->fsCodeAppend("\t\tdiff = 1 - diff;\n"); | 529 builder->fsCodeAppend("\t\tdiff = 1.0 - diff;\n"); |
530 builder->fsCodeAppend("\t\tfloat alpha = clamp(diff, 0.0, 1.0);\n"); | 530 builder->fsCodeAppend("\t\tfloat alpha = clamp(diff, 0.0, 1.0);\n"); |
531 } else { | 531 } else { |
532 builder->fsCodeAppendf("\t\tfloat alpha = 1.0;\n"); | 532 builder->fsCodeAppendf("\t\tfloat alpha = 1.0;\n"); |
533 builder->fsCodeAppendf("\t\talpha *= dist < %s.x + 0.5 ? 1.0 : 0.0;\n",
paramName); | 533 builder->fsCodeAppendf("\t\talpha *= dist < %s.x + 0.5 ? 1.0 : 0.0;\n",
paramName); |
534 } | 534 } |
535 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor, | 535 builder->fsCodeAppendf("\t\t%s = %s;\n", outputColor, |
536 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_st
r()); | 536 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_st
r()); |
537 } | 537 } |
538 | 538 |
539 void GLDashingCircleEffect::setData(const GrGLUniformManager& uman, const GrDraw
Effect& drawEffect) { | 539 void GLDashingCircleEffect::setData(const GrGLUniformManager& uman, const GrDraw
Effect& drawEffect) { |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 switch (cap) { | 845 switch (cap) { |
846 case GrDashingEffect::kRound_DashCap: | 846 case GrDashingEffect::kRound_DashCap: |
847 return DashingCircleEffect::Create(edgeType, info, SkScalarHalf(stro
keWidth)); | 847 return DashingCircleEffect::Create(edgeType, info, SkScalarHalf(stro
keWidth)); |
848 case GrDashingEffect::kNonRound_DashCap: | 848 case GrDashingEffect::kNonRound_DashCap: |
849 return DashingLineEffect::Create(edgeType, info, strokeWidth); | 849 return DashingLineEffect::Create(edgeType, info, strokeWidth); |
850 default: | 850 default: |
851 SkFAIL("Unexpected dashed cap."); | 851 SkFAIL("Unexpected dashed cap."); |
852 } | 852 } |
853 return NULL; | 853 return NULL; |
854 } | 854 } |
OLD | NEW |