Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(406)

Side by Side Diff: src/gpu/effects/GrDashingEffect.cpp

Issue 361253002: Fix int to float bug in shader on gpu Dotted Line cl (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698