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

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

Issue 521623003: Fix to use high precision on cubics not conics. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix typo bug Created 6 years, 3 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 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 "gl/builders/GrGLProgramBuilder.h" 8 #include "gl/builders/GrGLProgramBuilder.h"
9 #include "GrBezierEffect.h" 9 #include "GrBezierEffect.h"
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 builder->addVarying(kVec4f_GrSLType, "ConicCoeffs", 54 builder->addVarying(kVec4f_GrSLType, "ConicCoeffs",
55 &vsName, &fsName); 55 &vsName, &fsName);
56 56
57 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder(); 57 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
58 const SkString* attr0Name = 58 const SkString* attr0Name =
59 vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0] ); 59 vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0] );
60 vsBuilder->codeAppendf("%s = %s;", vsName, attr0Name->c_str()); 60 vsBuilder->codeAppendf("%s = %s;", vsName, attr0Name->c_str());
61 61
62 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 62 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
63 63 fsBuilder->codeAppend("float edgeAlpha;");
64 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, GrGLShaderVar::kHig h_Precision);
65 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec ision);
66 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec ision);
67 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio n);
68 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio n);
69 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, GrGLShaderVar::kHigh_Precision);
70 GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precision) ;
71 GrGLShaderVar func("func", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio n);
72
73 fsBuilder->declAppend(edgeAlpha);
74 fsBuilder->declAppend(dklmdx);
75 fsBuilder->declAppend(dklmdy);
76 fsBuilder->declAppend(dfdx);
77 fsBuilder->declAppend(dfdy);
78 fsBuilder->declAppend(gF);
79 fsBuilder->declAppend(gFM);
80 fsBuilder->declAppend(func);
81 64
82 switch (fEdgeType) { 65 switch (fEdgeType) {
83 case kHairlineAA_GrEffectEdgeType: { 66 case kHairlineAA_GrEffectEdgeType: {
84 SkAssertResult(fsBuilder->enableFeature( 67 SkAssertResult(fsBuilder->enableFeature(
85 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) ); 68 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) );
86 fsBuilder->codeAppendf("%s = dFdx(%s.xyz);", dklmdx.c_str(), fsName) ; 69 fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", fsName);
87 fsBuilder->codeAppendf("%s = dFdy(%s.xyz);", dklmdy.c_str(), fsName) ; 70 fsBuilder->codeAppendf("vec3 dklmdy = dFdy(%s.xyz);", fsName);
88 fsBuilder->codeAppendf("%s = 2.0 * %s.x * %s.x - %s.y * %s.z - %s.z * %s.y;", 71 fsBuilder->codeAppendf("float dfdx ="
89 dfdx.c_str(), fsName, dklmdx.c_str(), fsName, dklmdx.c_str(), 72 "2.0 * %s.x * dklmdx.x - %s.y * dklmdx.z - %s .z * dklmdx.y;",
90 fsName, dklmdx.c_str()); 73 fsName, fsName, fsName);
91 fsBuilder->codeAppendf("%s = 2.0 * %s.x * %s.x - %s.y * %s.z - %s.z * %s.y;", 74 fsBuilder->codeAppendf("float dfdy ="
92 dfdy.c_str(), fsName, dklmdy.c_str(), fsName, dklmdy.c_str(), 75 "2.0 * %s.x * dklmdy.x - %s.y * dklmdy.z - %s .z * dklmdy.y;",
93 fsName, dklmdy.c_str()); 76 fsName, fsName, fsName);
94 fsBuilder->codeAppendf("%s = vec2(%s, %s);", 77 fsBuilder->codeAppend("vec2 gF = vec2(dfdx, dfdy);");
95 gF.c_str(), dfdx.c_str(), dfdy.c_str()); 78 fsBuilder->codeAppend("float gFM = sqrt(dot(gF, gF));");
96 fsBuilder->codeAppendf("%s = sqrt(dot(%s, %s));", 79 fsBuilder->codeAppendf("float func = %s.x*%s.x - %s.y*%s.z;", fsName , fsName,
97 gFM.c_str(), gF.c_str(), gF.c_str()); 80 fsName, fsName);
98 fsBuilder->codeAppendf("%s = %s.x * %s.x - %s.y * %s.z;", 81 fsBuilder->codeAppend("func = abs(func);");
99 func.c_str(), fsName, fsName, fsName, fsName) ; 82 fsBuilder->codeAppend("edgeAlpha = func / gFM;");
100 fsBuilder->codeAppendf("%s = abs(%s);", func.c_str(), func.c_str()); 83 fsBuilder->codeAppend("edgeAlpha = max(1.0 - edgeAlpha, 0.0);");
101 fsBuilder->codeAppendf("%s = %s / %s;",
102 edgeAlpha.c_str(), func.c_str(), gFM.c_str()) ;
103 fsBuilder->codeAppendf("%s = max(1.0 - %s, 0.0);",
104 edgeAlpha.c_str(), edgeAlpha.c_str());
105 // Add line below for smooth cubic ramp 84 // Add line below for smooth cubic ramp
106 // fsBuilder->codeAppendf("%s = %s * %s * (3.0 - 2.0 * %s);", 85 // fsBuilder->codeAppend("edgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*e dgeAlpha);");
107 // edgeAlpha.c_str(), edgeAlpha.c_str(), edge Alpha.c_str(),
108 // edgeAlpha.c_str());
109 break; 86 break;
110 } 87 }
111 case kFillAA_GrEffectEdgeType: { 88 case kFillAA_GrEffectEdgeType: {
112 SkAssertResult(fsBuilder->enableFeature( 89 SkAssertResult(fsBuilder->enableFeature(
113 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) ); 90 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) );
114 fsBuilder->codeAppendf("%s = dFdx(%s.xyz);", dklmdx.c_str(), fsName) ; 91 fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", fsName);
115 fsBuilder->codeAppendf("%s = dFdy(%s.xyz);", dklmdy.c_str(), fsName) ; 92 fsBuilder->codeAppendf("vec3 dklmdy = dFdy(%s.xyz);", fsName);
116 fsBuilder->codeAppendf("%s = 2.0 * %s.x * %s.x - %s.y * %s.z - %s.z * %s.y;", 93 fsBuilder->codeAppendf("float dfdx ="
117 dfdx.c_str(), fsName, dklmdx.c_str(), fsName, dklmdx.c_str(), 94 "2.0 * %s.x * dklmdx.x - %s.y * dklmdx.z - %s .z * dklmdx.y;",
118 fsName, dklmdx.c_str()); 95 fsName, fsName, fsName);
119 fsBuilder->codeAppendf("%s = 2.0 * %s.x * %s.x - %s.y * %s.z - %s.z * %s.y;", 96 fsBuilder->codeAppendf("float dfdy ="
120 dfdy.c_str(), fsName, dklmdy.c_str(), fsName, dklmdy.c_str(), 97 "2.0 * %s.x * dklmdy.x - %s.y * dklmdy.z - %s .z * dklmdy.y;",
121 fsName, dklmdy.c_str()); 98 fsName, fsName, fsName);
122 fsBuilder->codeAppendf("%s = vec2(%s, %s);", 99 fsBuilder->codeAppend("vec2 gF = vec2(dfdx, dfdy);");
123 gF.c_str(), dfdx.c_str(), dfdy.c_str()); 100 fsBuilder->codeAppend("float gFM = sqrt(dot(gF, gF));");
124 fsBuilder->codeAppendf("%s = sqrt(dot(%s, %s));", 101 fsBuilder->codeAppendf("float func = %s.x * %s.x - %s.y * %s.z;", fs Name, fsName,
125 gFM.c_str(), gF.c_str(), gF.c_str()); 102 fsName, fsName);
126 fsBuilder->codeAppendf("%s = %s.x * %s.x - %s.y * %s.z;", 103 fsBuilder->codeAppend("edgeAlpha = func / gFM;");
127 func.c_str(), fsName, fsName, fsName, fsName) ; 104 fsBuilder->codeAppend("edgeAlpha = clamp(1.0 - edgeAlpha, 0.0, 1.0); ");
128 fsBuilder->codeAppendf("%s = %s / %s;",
129 edgeAlpha.c_str(), func.c_str(), gFM.c_str()) ;
130 fsBuilder->codeAppendf("%s = clamp(1.0 - %s, 0.0, 1.0);",
131 edgeAlpha.c_str(), edgeAlpha.c_str());
132 // Add line below for smooth cubic ramp 105 // Add line below for smooth cubic ramp
133 // fsBuilder->codeAppendf("%s = %s * %s * (3.0 - 2.0 * %s);", 106 // fsBuilder->codeAppend("edgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*e dgeAlpha);");
134 // edgeAlpha.c_str(), edgeAlpha.c_str(), edge Alpha.c_str(),
135 // edgeAlpha.c_str());
136 break; 107 break;
137 } 108 }
138 case kFillBW_GrEffectEdgeType: { 109 case kFillBW_GrEffectEdgeType: {
139 fsBuilder->codeAppendf("%s = %s.x * %s.x - %s.y * %s.z;", 110 fsBuilder->codeAppendf("edgeAlpha = %s.x * %s.x - %s.y * %s.z;", fsN ame, fsName,
140 edgeAlpha.c_str(), fsName, fsName, fsName, fs Name); 111 fsName, fsName);
141 fsBuilder->codeAppendf("%s = float(%s < 0.0);", 112 fsBuilder->codeAppend("edgeAlpha = float(edgeAlpha < 0.0);");
142 edgeAlpha.c_str(), edgeAlpha.c_str());
143 break; 113 break;
144 } 114 }
145 default: 115 default:
146 SkFAIL("Shouldn't get here"); 116 SkFAIL("Shouldn't get here");
147 } 117 }
148 118
149 fsBuilder->codeAppendf("%s = %s;", outputColor, 119 fsBuilder->codeAppendf("%s = %s;", outputColor,
150 (GrGLSLExpr4(inputColor) * GrGLSLExpr1(edgeAlpha.c_st r())).c_str()); 120 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")). c_str());
151 } 121 }
152 122
153 void GrGLConicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, 123 void GrGLConicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
154 GrEffectKeyBuilder* b) { 124 GrEffectKeyBuilder* b) {
155 const GrConicEffect& ce = drawEffect.castEffect<GrConicEffect>(); 125 const GrConicEffect& ce = drawEffect.castEffect<GrConicEffect>();
156 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; 126 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
157 b->add32(key); 127 b->add32(key);
158 } 128 }
159 129
160 ////////////////////////////////////////////////////////////////////////////// 130 //////////////////////////////////////////////////////////////////////////////
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 343
374 builder->addVarying(kVec4f_GrSLType, "CubicCoeffs", 344 builder->addVarying(kVec4f_GrSLType, "CubicCoeffs",
375 &vsName, &fsName); 345 &vsName, &fsName);
376 346
377 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder(); 347 GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
378 const SkString* attr0Name = 348 const SkString* attr0Name =
379 vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0] ); 349 vsBuilder->getEffectAttributeName(drawEffect.getVertexAttribIndices()[0] );
380 vsBuilder->codeAppendf("%s = %s;", vsName, attr0Name->c_str()); 350 vsBuilder->codeAppendf("%s = %s;", vsName, attr0Name->c_str());
381 351
382 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder(); 352 GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
383 fsBuilder->codeAppend("float edgeAlpha;"); 353
354 GrGLShaderVar edgeAlpha("edgeAlpha", kFloat_GrSLType, 0, GrGLShaderVar::kHig h_Precision);
355 GrGLShaderVar dklmdx("dklmdx", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec ision);
356 GrGLShaderVar dklmdy("dklmdy", kVec3f_GrSLType, 0, GrGLShaderVar::kHigh_Prec ision);
357 GrGLShaderVar dfdx("dfdx", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio n);
358 GrGLShaderVar dfdy("dfdy", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio n);
359 GrGLShaderVar gF("gF", kVec2f_GrSLType, 0, GrGLShaderVar::kHigh_Precision);
360 GrGLShaderVar gFM("gFM", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precision) ;
361 GrGLShaderVar func("func", kFloat_GrSLType, 0, GrGLShaderVar::kHigh_Precisio n);
362
363 fsBuilder->declAppend(edgeAlpha);
364 fsBuilder->declAppend(dklmdx);
365 fsBuilder->declAppend(dklmdy);
366 fsBuilder->declAppend(dfdx);
367 fsBuilder->declAppend(dfdy);
368 fsBuilder->declAppend(gF);
369 fsBuilder->declAppend(gFM);
370 fsBuilder->declAppend(func);
384 371
385 switch (fEdgeType) { 372 switch (fEdgeType) {
386 case kHairlineAA_GrEffectEdgeType: { 373 case kHairlineAA_GrEffectEdgeType: {
387 SkAssertResult(fsBuilder->enableFeature( 374 SkAssertResult(fsBuilder->enableFeature(
388 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) ); 375 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) );
389 fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", fsName); 376 fsBuilder->codeAppendf("%s = dFdx(%s.xyz);", dklmdx.c_str(), fsName) ;
390 fsBuilder->codeAppendf("vec3 dklmdy = dFdy(%s.xyz);", fsName); 377 fsBuilder->codeAppendf("%s = dFdy(%s.xyz);", dklmdy.c_str(), fsName) ;
391 fsBuilder->codeAppendf("float dfdx =" 378 fsBuilder->codeAppendf("%s = 3.0 * %s.x * %s.x * %s.x - %s.y * %s.z - %s.z * %s.y;",
392 "3.0*%s.x*%s.x * dklmdx.x - %s.y * dklmdx.z - %s.z * dklmdx.y;", 379 dfdx.c_str(), fsName, fsName, dklmdx.c_str(), fsName,
393 fsName, fsName, fsName, fsName); 380 dklmdx.c_str(), fsName, dklmdx.c_str());
394 fsBuilder->codeAppendf("float dfdy =" 381 fsBuilder->codeAppendf("%s = 3.0 * %s.x * %s.x * %s.x - %s.y * %s.z - %s.z * %s.y;",
395 "3.0*%s.x*%s.x * dklmdy.x - %s.y * dklmdy.z - %s.z * dklmdy.y;", 382 dfdy.c_str(), fsName, fsName, dklmdy.c_str(), fsName,
396 fsName, fsName, fsName, fsName); 383 dklmdy.c_str(), fsName, dklmdy.c_str());
397 fsBuilder->codeAppend("vec2 gF = vec2(dfdx, dfdy);"); 384 fsBuilder->codeAppendf("%s = vec2(%s, %s);", gF.c_str(), dfdx.c_str( ), dfdy.c_str());
398 fsBuilder->codeAppend("float gFM = sqrt(dot(gF, gF));"); 385 fsBuilder->codeAppendf("%s = sqrt(dot(%s, %s));", gFM.c_str(), gF.c_ str(), gF.c_str());
399 fsBuilder->codeAppendf("float func = %s.x * %s.x * %s.x - %s.y * %s. z;", 386 fsBuilder->codeAppendf("%s = %s.x * %s.x * %s.x - %s.y * %s.z;",
400 fsName, fsName, fsName, fsName, fsName); 387 func.c_str(), fsName, fsName, fsName, fsName, fsName);
401 fsBuilder->codeAppend("func = abs(func);"); 388 fsBuilder->codeAppendf("%s = abs(%s);", func.c_str(), func.c_str());
402 fsBuilder->codeAppend("edgeAlpha = func / gFM;"); 389 fsBuilder->codeAppendf("%s = %s / %s;",
403 fsBuilder->codeAppend("edgeAlpha = max(1.0 - edgeAlpha, 0.0);"); 390 edgeAlpha.c_str(), func.c_str(), gFM.c_str()) ;
391 fsBuilder->codeAppendf("%s = max(1.0 - %s, 0.0);",
392 edgeAlpha.c_str(), edgeAlpha.c_str());
404 // Add line below for smooth cubic ramp 393 // Add line below for smooth cubic ramp
405 // fsBuilder->codeAppend("edgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*e dgeAlpha);"); 394 // fsBuilder->codeAppendf("%s = %s * %s * (3.0 - 2.0 * %s);",
395 // edgeAlpha.c_str(), edgeAlpha.c_str(), edge Alpha.c_str(),
396 // edgeAlpha.c_str());
406 break; 397 break;
407 } 398 }
408 case kFillAA_GrEffectEdgeType: { 399 case kFillAA_GrEffectEdgeType: {
409 SkAssertResult(fsBuilder->enableFeature( 400 SkAssertResult(fsBuilder->enableFeature(
410 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) ); 401 GrGLFragmentShaderBuilder::kStandardDerivatives_GLSLFeature) );
411 fsBuilder->codeAppendf("vec3 dklmdx = dFdx(%s.xyz);", fsName); 402 fsBuilder->codeAppendf("%s = dFdx(%s.xyz);", dklmdx.c_str(), fsName) ;
412 fsBuilder->codeAppendf("vec3 dklmdy = dFdy(%s.xyz);", fsName); 403 fsBuilder->codeAppendf("%s = dFdy(%s.xyz);", dklmdy.c_str(), fsName) ;
413 fsBuilder->codeAppendf("float dfdx =" 404 fsBuilder->codeAppendf("%s ="
414 "3.0*%s.x*%s.x * dklmdx.x - %s.y * dklmdx.z - %s.z * dklmdx.y;", 405 "3.0 * %s.x * %s.x * %s.x - %s.y * %s.z - %s. z * %s.y;",
415 fsName, fsName, fsName, fsName); 406 dfdx.c_str(), fsName, fsName, dklmdx.c_str(), fsName,
416 fsBuilder->codeAppendf("float dfdy =" 407 dklmdx.c_str(), fsName, dklmdx.c_str());
417 "3.0*%s.x*%s.x * dklmdy.x - %s.y * dklmdy.z - %s.z * dklmdy.y;", 408 fsBuilder->codeAppendf("%s = 3.0 * %s.x * %s.x * %s.x - %s.y * %s.z - %s.z * %s.y;",
418 fsName, fsName, fsName, fsName); 409 dfdy.c_str(), fsName, fsName, dklmdy.c_str(), fsName,
419 fsBuilder->codeAppend("vec2 gF = vec2(dfdx, dfdy);"); 410 dklmdy.c_str(), fsName, dklmdy.c_str());
420 fsBuilder->codeAppend("float gFM = sqrt(dot(gF, gF));"); 411 fsBuilder->codeAppendf("%s = vec2(%s, %s);", gF.c_str(), dfdx.c_str( ), dfdy.c_str());
421 fsBuilder->codeAppendf("float func = %s.x * %s.x * %s.x - %s.y * %s. z;", 412 fsBuilder->codeAppendf("%s = sqrt(dot(%s, %s));", gFM.c_str(), gF.c_ str(), gF.c_str());
422 fsName, fsName, fsName, fsName, fsName); 413 fsBuilder->codeAppendf("%s = %s.x * %s.x * %s.x - %s.y * %s.z;",
423 fsBuilder->codeAppend("edgeAlpha = func / gFM;"); 414 func.c_str(), fsName, fsName, fsName, fsName, fsName);
424 fsBuilder->codeAppend("edgeAlpha = clamp(1.0 - edgeAlpha, 0.0, 1.0); "); 415 fsBuilder->codeAppendf("%s = %s / %s;",
416 edgeAlpha.c_str(), func.c_str(), gFM.c_str()) ;
417 fsBuilder->codeAppendf("%s = clamp(1.0 - %s, 0.0, 1.0);",
418 edgeAlpha.c_str(), edgeAlpha.c_str());
425 // Add line below for smooth cubic ramp 419 // Add line below for smooth cubic ramp
426 // fsBuilder->codeAppend("edgeAlpha = edgeAlpha*edgeAlpha*(3.0-2.0*e dgeAlpha);"); 420 // fsBuilder->codeAppendf("%s = %s * %s * (3.0 - 2.0 * %s);",
421 // edgeAlpha.c_str(), edgeAlpha.c_str(), edge Alpha.c_str(),
422 // edgeAlpha.c_str());
427 break; 423 break;
428 } 424 }
429 case kFillBW_GrEffectEdgeType: { 425 case kFillBW_GrEffectEdgeType: {
430 fsBuilder->codeAppendf("edgeAlpha = %s.x * %s.x * %s.x - %s.y * %s.z ;", 426 fsBuilder->codeAppendf("%s = %s.x * %s.x * %s.x - %s.y * %s.z;",
431 fsName, fsName, fsName, fsName, fsName); 427 edgeAlpha.c_str(), fsName, fsName, fsName, fs Name, fsName);
432 fsBuilder->codeAppend("edgeAlpha = float(edgeAlpha < 0.0);"); 428 fsBuilder->codeAppendf("%s = float(%s < 0.0);", edgeAlpha.c_str(), e dgeAlpha.c_str());
433 break; 429 break;
434 } 430 }
435 default: 431 default:
436 SkFAIL("Shouldn't get here"); 432 SkFAIL("Shouldn't get here");
437 } 433 }
438 434
439 fsBuilder->codeAppendf("%s = %s;", outputColor, 435 fsBuilder->codeAppendf("%s = %s;", outputColor,
440 (GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")). c_str()); 436 (GrGLSLExpr4(inputColor) * GrGLSLExpr1(edgeAlpha.c_st r())).c_str());
441 } 437 }
442 438
443 void GrGLCubicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, 439 void GrGLCubicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
444 GrEffectKeyBuilder* b) { 440 GrEffectKeyBuilder* b) {
445 const GrCubicEffect& ce = drawEffect.castEffect<GrCubicEffect>(); 441 const GrCubicEffect& ce = drawEffect.castEffect<GrCubicEffect>();
446 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2; 442 uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
447 b->add32(key); 443 b->add32(key);
448 } 444 }
449 445
450 ////////////////////////////////////////////////////////////////////////////// 446 //////////////////////////////////////////////////////////////////////////////
(...skipping 23 matching lines...) Expand all
474 const GrDrawTargetCaps& caps, 470 const GrDrawTargetCaps& caps,
475 GrTexture*[]) { 471 GrTexture*[]) {
476 GrEffect* effect; 472 GrEffect* effect;
477 do { 473 do {
478 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>( 474 GrEffectEdgeType edgeType = static_cast<GrEffectEdgeType>(
479 random->nextULessThan(kGrEff ectEdgeTypeCnt)); 475 random->nextULessThan(kGrEff ectEdgeTypeCnt));
480 effect = GrCubicEffect::Create(edgeType, caps); 476 effect = GrCubicEffect::Create(edgeType, caps);
481 } while (NULL == effect); 477 } while (NULL == effect);
482 return effect; 478 return effect;
483 } 479 }
480
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