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

Side by Side Diff: src/effects/gradients/SkGradientShader.cpp

Issue 2247113003: Speed up centered hard stop shader (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
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 "Sk4fLinearGradient.h" 8 #include "Sk4fLinearGradient.h"
9 #include "SkGradientShaderPriv.h" 9 #include "SkGradientShaderPriv.h"
10 #include "SkLinearGradient.h" 10 #include "SkLinearGradient.h"
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 fragBuilder->codeAppendf(" clamp_t = 1.0 - fract(%s);", t ); 1109 fragBuilder->codeAppendf(" clamp_t = 1.0 - fract(%s);", t );
1110 fragBuilder->codeAppendf(" }"); 1110 fragBuilder->codeAppendf(" }");
1111 fragBuilder->codeAppendf("}"); 1111 fragBuilder->codeAppendf("}");
1112 } 1112 }
1113 1113
1114 // Calculate color 1114 // Calculate color
1115 fragBuilder->codeAppendf("float relative_t = fract(2.0 * clamp_t);") ; 1115 fragBuilder->codeAppendf("float relative_t = fract(2.0 * clamp_t);") ;
1116 if (SkShader::kClamp_TileMode == ge.fTileMode) { 1116 if (SkShader::kClamp_TileMode == ge.fTileMode) {
1117 fragBuilder->codeAppendf("relative_t += step(1.0, %s);", t); 1117 fragBuilder->codeAppendf("relative_t += step(1.0, %s);", t);
1118 } 1118 }
1119 fragBuilder->codeAppendf("vec4 colorTemp = mix(%s[0], %s[1], relativ e_t);", colors, 1119
1120 colors); 1120 fragBuilder->codeAppendf("vec4 start = %s[0];", colors);
1121 fragBuilder->codeAppendf("vec4 end = %s[1];", colors);
1121 fragBuilder->codeAppendf("if (clamp_t >= 0.5) {"); 1122 fragBuilder->codeAppendf("if (clamp_t >= 0.5) {");
1122 fragBuilder->codeAppendf(" colorTemp = mix(%s[2], %s[3], relative _t);", colors, 1123 fragBuilder->codeAppendf(" start = %s[2];", colors);
1123 colors); 1124 fragBuilder->codeAppendf(" end = %s[3];", colors);
1124 fragBuilder->codeAppendf("}"); 1125 fragBuilder->codeAppendf("}");
1126 fragBuilder->codeAppendf("vec4 colorTemp = mix(start, end, relative_ t);");
1125 1127
1126 if (GrGradientEffect::kAfterInterp_PremulType == ge.getPremulType()) { 1128 if (GrGradientEffect::kAfterInterp_PremulType == ge.getPremulType()) {
1127 fragBuilder->codeAppend("colorTemp.rgb *= colorTemp.a;"); 1129 fragBuilder->codeAppend("colorTemp.rgb *= colorTemp.a;");
1128 } 1130 }
1129 fragBuilder->codeAppendf("%s = %s;", outputColor, 1131 fragBuilder->codeAppendf("%s = %s;", outputColor,
1130 (GrGLSLExpr4(inputColor) * GrGLSLExpr4("col orTemp")).c_str()); 1132 (GrGLSLExpr4(inputColor) * GrGLSLExpr4("col orTemp")).c_str());
1131 1133
1132 break; 1134 break;
1133 } 1135 }
1134 1136
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 (*stops)[i] = stop; 1427 (*stops)[i] = stop;
1426 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f; 1428 stop = i < outColors - 1 ? stop + random->nextUScalar1() * (1.f - st op) : 1.f;
1427 } 1429 }
1428 } 1430 }
1429 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount)); 1431 *tm = static_cast<SkShader::TileMode>(random->nextULessThan(SkShader::kTileM odeCount));
1430 1432
1431 return outColors; 1433 return outColors;
1432 } 1434 }
1433 1435
1434 #endif 1436 #endif
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