| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 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 "SkTwoPointConicalGradient_gpu.h" | 9 #include "SkTwoPointConicalGradient_gpu.h" |
| 10 | 10 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 SkString p2; // difference in radii (r1 - r0) | 235 SkString p2; // difference in radii (r1 - r0) |
| 236 | 236 |
| 237 args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(0, &p0); | 237 args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(0, &p0); |
| 238 args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(1, &p1); | 238 args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(1, &p1); |
| 239 args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(2, &p2); | 239 args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(2, &p2); |
| 240 | 240 |
| 241 // We interpolate the linear component in coords[1]. | 241 // We interpolate the linear component in coords[1]. |
| 242 SkASSERT(args.fCoords[0].getType() == args.fCoords[1].getType()); | 242 SkASSERT(args.fCoords[0].getType() == args.fCoords[1].getType()); |
| 243 const char* coords2D; | 243 const char* coords2D; |
| 244 SkString bVar; | 244 SkString bVar; |
| 245 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder()
; | 245 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 246 if (kVec3f_GrSLType == args.fCoords[0].getType()) { | 246 if (kVec3f_GrSLType == args.fCoords[0].getType()) { |
| 247 fsBuilder->codeAppendf("\tvec3 interpolants = vec3(%s.xy / %s.z, %s.x /
%s.z);\n", | 247 fragBuilder->codeAppendf("\tvec3 interpolants = vec3(%s.xy / %s.z, %s.x
/ %s.z);\n", |
| 248 args.fCoords[0].c_str(), args.fCoords[0].c_str(), | 248 args.fCoords[0].c_str(), args.fCoords[0].c_str(), |
| 249 args.fCoords[1].c_str(), args.fCoords[1].c_str())
; | 249 args.fCoords[1].c_str(), args.fCoords[1].c_str())
; |
| 250 coords2D = "interpolants.xy"; | 250 coords2D = "interpolants.xy"; |
| 251 bVar = "interpolants.z"; | 251 bVar = "interpolants.z"; |
| 252 } else { | 252 } else { |
| 253 coords2D = args.fCoords[0].c_str(); | 253 coords2D = args.fCoords[0].c_str(); |
| 254 bVar.printf("%s.x", args.fCoords[1].c_str()); | 254 bVar.printf("%s.x", args.fCoords[1].c_str()); |
| 255 } | 255 } |
| 256 | 256 |
| 257 // output will default to transparent black (we simply won't write anything | 257 // output will default to transparent black (we simply won't write anything |
| 258 // else to it if invalid, instead of discarding or returning prematurely) | 258 // else to it if invalid, instead of discarding or returning prematurely) |
| 259 fsBuilder->codeAppendf("\t%s = vec4(0.0,0.0,0.0,0.0);\n", args.fOutputColor)
; | 259 fragBuilder->codeAppendf("\t%s = vec4(0.0,0.0,0.0,0.0);\n", args.fOutputColo
r); |
| 260 | 260 |
| 261 // c = (x^2)+(y^2) - params[1] | 261 // c = (x^2)+(y^2) - params[1] |
| 262 fsBuilder->codeAppendf("\tfloat %s = dot(%s, %s) - %s;\n", | 262 fragBuilder->codeAppendf("\tfloat %s = dot(%s, %s) - %s;\n", |
| 263 cName.c_str(), coords2D, coords2D, p1.c_str()); | 263 cName.c_str(), coords2D, coords2D, p1.c_str()); |
| 264 | 264 |
| 265 // linear case: t = -c/b | 265 // linear case: t = -c/b |
| 266 fsBuilder->codeAppendf("\tfloat %s = -(%s / %s);\n", tName.c_str(), | 266 fragBuilder->codeAppendf("\tfloat %s = -(%s / %s);\n", tName.c_str(), |
| 267 cName.c_str(), bVar.c_str()); | 267 cName.c_str(), bVar.c_str()); |
| 268 | 268 |
| 269 // if r(t) > 0, then t will be the x coordinate | 269 // if r(t) > 0, then t will be the x coordinate |
| 270 fsBuilder->codeAppendf("\tif (%s * %s + %s > 0.0) {\n", tName.c_str(), | 270 fragBuilder->codeAppendf("\tif (%s * %s + %s > 0.0) {\n", tName.c_str(), |
| 271 p2.c_str(), p0.c_str()); | 271 p2.c_str(), p0.c_str()); |
| 272 fsBuilder->codeAppend("\t"); | 272 fragBuilder->codeAppend("\t"); |
| 273 this->emitColor(args.fBuilder, ge, tName.c_str(), args.fOutputColor, args.fI
nputColor, | 273 this->emitColor(args.fBuilder, |
| 274 fragBuilder, |
| 275 ge, |
| 276 tName.c_str(), |
| 277 args.fOutputColor, |
| 278 args.fInputColor, |
| 274 args.fSamplers); | 279 args.fSamplers); |
| 275 fsBuilder->codeAppend("\t}\n"); | 280 fragBuilder->codeAppend("\t}\n"); |
| 276 } | 281 } |
| 277 | 282 |
| 278 void GLEdge2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman, | 283 void GLEdge2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman, |
| 279 const GrProcessor& processor) { | 284 const GrProcessor& processor) { |
| 280 INHERITED::onSetData(pdman, processor); | 285 INHERITED::onSetData(pdman, processor); |
| 281 const Edge2PtConicalEffect& data = processor.cast<Edge2PtConicalEffect>(); | 286 const Edge2PtConicalEffect& data = processor.cast<Edge2PtConicalEffect>(); |
| 282 SkScalar radius0 = data.radius(); | 287 SkScalar radius0 = data.radius(); |
| 283 SkScalar diffRadius = data.diffRadius(); | 288 SkScalar diffRadius = data.diffRadius(); |
| 284 | 289 |
| 285 if (fCachedRadius != radius0 || | 290 if (fCachedRadius != radius0 || |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 kFloat_GrSLType, kDefault_GrSLPrecision
, | 509 kFloat_GrSLType, kDefault_GrSLPrecision
, |
| 505 "Conical2FSParams", 2); | 510 "Conical2FSParams", 2); |
| 506 SkString tName("t"); | 511 SkString tName("t"); |
| 507 SkString p0; // focalX | 512 SkString p0; // focalX |
| 508 SkString p1; // 1 - focalX * focalX | 513 SkString p1; // 1 - focalX * focalX |
| 509 | 514 |
| 510 args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(0, &p0); | 515 args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(0, &p0); |
| 511 args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(1, &p1); | 516 args.fBuilder->getUniformVariable(fParamUni).appendArrayAccess(1, &p1); |
| 512 | 517 |
| 513 // if we have a vec3 from being in perspective, convert it to a vec2 first | 518 // if we have a vec3 from being in perspective, convert it to a vec2 first |
| 514 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder()
; | 519 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 515 SkString coords2DString = fsBuilder->ensureFSCoords2D(args.fCoords, 0); | 520 SkString coords2DString = fragBuilder->ensureFSCoords2D(args.fCoords, 0); |
| 516 const char* coords2D = coords2DString.c_str(); | 521 const char* coords2D = coords2DString.c_str(); |
| 517 | 522 |
| 518 // t = p.x * focal.x +/- sqrt(p.x^2 + (1 - focal.x^2) * p.y^2) | 523 // t = p.x * focal.x +/- sqrt(p.x^2 + (1 - focal.x^2) * p.y^2) |
| 519 | 524 |
| 520 // output will default to transparent black (we simply won't write anything | 525 // output will default to transparent black (we simply won't write anything |
| 521 // else to it if invalid, instead of discarding or returning prematurely) | 526 // else to it if invalid, instead of discarding or returning prematurely) |
| 522 fsBuilder->codeAppendf("\t%s = vec4(0.0,0.0,0.0,0.0);\n", args.fOutputColor)
; | 527 fragBuilder->codeAppendf("\t%s = vec4(0.0,0.0,0.0,0.0);\n", args.fOutputColo
r); |
| 523 | 528 |
| 524 fsBuilder->codeAppendf("\tfloat xs = %s.x * %s.x;\n", coords2D, coords2D); | 529 fragBuilder->codeAppendf("\tfloat xs = %s.x * %s.x;\n", coords2D, coords2D); |
| 525 fsBuilder->codeAppendf("\tfloat ys = %s.y * %s.y;\n", coords2D, coords2D); | 530 fragBuilder->codeAppendf("\tfloat ys = %s.y * %s.y;\n", coords2D, coords2D); |
| 526 fsBuilder->codeAppendf("\tfloat d = xs + %s * ys;\n", p1.c_str()); | 531 fragBuilder->codeAppendf("\tfloat d = xs + %s * ys;\n", p1.c_str()); |
| 527 | 532 |
| 528 // Must check to see if we flipped the circle order (to make sure start radi
us < end radius) | 533 // Must check to see if we flipped the circle order (to make sure start radi
us < end radius) |
| 529 // If so we must also flip sign on sqrt | 534 // If so we must also flip sign on sqrt |
| 530 if (!fIsFlipped) { | 535 if (!fIsFlipped) { |
| 531 fsBuilder->codeAppendf("\tfloat %s = %s.x * %s + sqrt(d);\n", tName.c_s
tr(), | 536 fragBuilder->codeAppendf("\tfloat %s = %s.x * %s + sqrt(d);\n", tName.c
_str(), |
| 532 coords2D, p0.c_str()); | 537 coords2D, p0.c_str()); |
| 533 } else { | 538 } else { |
| 534 fsBuilder->codeAppendf("\tfloat %s = %s.x * %s - sqrt(d);\n", tName.c_s
tr(), | 539 fragBuilder->codeAppendf("\tfloat %s = %s.x * %s - sqrt(d);\n", tName.c
_str(), |
| 535 coords2D, p0.c_str()); | 540 coords2D, p0.c_str()); |
| 536 } | 541 } |
| 537 | 542 |
| 538 fsBuilder->codeAppendf("\tif (%s >= 0.0 && d >= 0.0) {\n", tName.c_str()); | 543 fragBuilder->codeAppendf("\tif (%s >= 0.0 && d >= 0.0) {\n", tName.c_str()); |
| 539 fsBuilder->codeAppend("\t\t"); | 544 fragBuilder->codeAppend("\t\t"); |
| 540 this->emitColor(args.fBuilder, ge, tName.c_str(), args.fOutputColor, args.fI
nputColor, | 545 this->emitColor(args.fBuilder, |
| 546 fragBuilder, |
| 547 ge, |
| 548 tName.c_str(), |
| 549 args.fOutputColor, |
| 550 args.fInputColor, |
| 541 args.fSamplers); | 551 args.fSamplers); |
| 542 fsBuilder->codeAppend("\t}\n"); | 552 fragBuilder->codeAppend("\t}\n"); |
| 543 } | 553 } |
| 544 | 554 |
| 545 void GLFocalOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& p
dman, | 555 void GLFocalOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& p
dman, |
| 546 const GrProcessor& processor) { | 556 const GrProcessor& processor) { |
| 547 INHERITED::onSetData(pdman, processor); | 557 INHERITED::onSetData(pdman, processor); |
| 548 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon
icalEffect>(); | 558 const FocalOutside2PtConicalEffect& data = processor.cast<FocalOutside2PtCon
icalEffect>(); |
| 549 SkASSERT(data.isFlipped() == fIsFlipped); | 559 SkASSERT(data.isFlipped() == fIsFlipped); |
| 550 SkScalar focal = data.focal(); | 560 SkScalar focal = data.focal(); |
| 551 | 561 |
| 552 if (fCachedFocal != focal) { | 562 if (fCachedFocal != focal) { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 fFocalUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibi
lity, | 716 fFocalUni = args.fBuilder->addUniform(GrGLSLProgramBuilder::kFragment_Visibi
lity, |
| 707 kFloat_GrSLType, kDefault_GrSLPrecisio
n, | 717 kFloat_GrSLType, kDefault_GrSLPrecisio
n, |
| 708 "Conical2FSParams"); | 718 "Conical2FSParams"); |
| 709 SkString tName("t"); | 719 SkString tName("t"); |
| 710 | 720 |
| 711 // this is the distance along x-axis from the end center to focal point in | 721 // this is the distance along x-axis from the end center to focal point in |
| 712 // transformed coordinates | 722 // transformed coordinates |
| 713 GrGLSLShaderVar focal = args.fBuilder->getUniformVariable(fFocalUni); | 723 GrGLSLShaderVar focal = args.fBuilder->getUniformVariable(fFocalUni); |
| 714 | 724 |
| 715 // if we have a vec3 from being in perspective, convert it to a vec2 first | 725 // if we have a vec3 from being in perspective, convert it to a vec2 first |
| 716 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder()
; | 726 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 717 SkString coords2DString = fsBuilder->ensureFSCoords2D(args.fCoords, 0); | 727 SkString coords2DString = fragBuilder->ensureFSCoords2D(args.fCoords, 0); |
| 718 const char* coords2D = coords2DString.c_str(); | 728 const char* coords2D = coords2DString.c_str(); |
| 719 | 729 |
| 720 // t = p.x * focalX + length(p) | 730 // t = p.x * focalX + length(p) |
| 721 fsBuilder->codeAppendf("\tfloat %s = %s.x * %s + length(%s);\n", tName.c_st
r(), | 731 fragBuilder->codeAppendf("\tfloat %s = %s.x * %s + length(%s);\n", tName.c_
str(), |
| 722 coords2D, focal.c_str(), coords2D); | 732 coords2D, focal.c_str(), coords2D); |
| 723 | 733 |
| 724 this->emitColor(args.fBuilder, ge, tName.c_str(), args.fOutputColor, args.fI
nputColor, | 734 this->emitColor(args.fBuilder, |
| 735 fragBuilder, |
| 736 ge, |
| 737 tName.c_str(), |
| 738 args.fOutputColor, |
| 739 args.fInputColor, |
| 725 args.fSamplers); | 740 args.fSamplers); |
| 726 } | 741 } |
| 727 | 742 |
| 728 void GLFocalInside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pd
man, | 743 void GLFocalInside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pd
man, |
| 729 const GrProcessor& processor) { | 744 const GrProcessor& processor) { |
| 730 INHERITED::onSetData(pdman, processor); | 745 INHERITED::onSetData(pdman, processor); |
| 731 const FocalInside2PtConicalEffect& data = processor.cast<FocalInside2PtConic
alEffect>(); | 746 const FocalInside2PtConicalEffect& data = processor.cast<FocalInside2PtConic
alEffect>(); |
| 732 SkScalar focal = data.focal(); | 747 SkScalar focal = data.focal(); |
| 733 | 748 |
| 734 if (fCachedFocal != focal) { | 749 if (fCachedFocal != focal) { |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 "Conical2FSParams"); | 971 "Conical2FSParams"); |
| 957 SkString tName("t"); | 972 SkString tName("t"); |
| 958 | 973 |
| 959 GrGLSLShaderVar center = args.fBuilder->getUniformVariable(fCenterUni); | 974 GrGLSLShaderVar center = args.fBuilder->getUniformVariable(fCenterUni); |
| 960 // params.x = A | 975 // params.x = A |
| 961 // params.y = B | 976 // params.y = B |
| 962 // params.z = C | 977 // params.z = C |
| 963 GrGLSLShaderVar params = args.fBuilder->getUniformVariable(fParamUni); | 978 GrGLSLShaderVar params = args.fBuilder->getUniformVariable(fParamUni); |
| 964 | 979 |
| 965 // if we have a vec3 from being in perspective, convert it to a vec2 first | 980 // if we have a vec3 from being in perspective, convert it to a vec2 first |
| 966 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder()
; | 981 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 967 SkString coords2DString = fsBuilder->ensureFSCoords2D(args.fCoords, 0); | 982 SkString coords2DString = fragBuilder->ensureFSCoords2D(args.fCoords, 0); |
| 968 const char* coords2D = coords2DString.c_str(); | 983 const char* coords2D = coords2DString.c_str(); |
| 969 | 984 |
| 970 // p = coords2D | 985 // p = coords2D |
| 971 // e = center end | 986 // e = center end |
| 972 // r = radius end | 987 // r = radius end |
| 973 // A = dot(e, e) - r^2 + 2 * r - 1 | 988 // A = dot(e, e) - r^2 + 2 * r - 1 |
| 974 // B = (r -1) / A | 989 // B = (r -1) / A |
| 975 // C = 1 / A | 990 // C = 1 / A |
| 976 // d = dot(e, p) + B | 991 // d = dot(e, p) + B |
| 977 // t = d +/- sqrt(d^2 - A * dot(p, p) + C) | 992 // t = d +/- sqrt(d^2 - A * dot(p, p) + C) |
| 978 fsBuilder->codeAppendf("\tfloat pDotp = dot(%s, %s);\n", coords2D, coords2D
); | 993 fragBuilder->codeAppendf("\tfloat pDotp = dot(%s, %s);\n", coords2D, coords
2D); |
| 979 fsBuilder->codeAppendf("\tfloat d = dot(%s, %s) + %s.y;\n", coords2D, cente
r.c_str(), | 994 fragBuilder->codeAppendf("\tfloat d = dot(%s, %s) + %s.y;\n", coords2D, cen
ter.c_str(), |
| 980 params.c_str()); | 995 params.c_str()); |
| 981 fsBuilder->codeAppendf("\tfloat %s = d + sqrt(d * d - %s.x * pDotp + %s.z);\
n", | 996 fragBuilder->codeAppendf("\tfloat %s = d + sqrt(d * d - %s.x * pDotp + %s.z)
;\n", |
| 982 tName.c_str(), params.c_str(), params.c_str()); | 997 tName.c_str(), params.c_str(), params.c_str()); |
| 983 | 998 |
| 984 this->emitColor(args.fBuilder, ge, tName.c_str(), args.fOutputColor, args.fI
nputColor, | 999 this->emitColor(args.fBuilder, |
| 1000 fragBuilder, |
| 1001 ge, |
| 1002 tName.c_str(), |
| 1003 args.fOutputColor, |
| 1004 args.fInputColor, |
| 985 args.fSamplers); | 1005 args.fSamplers); |
| 986 } | 1006 } |
| 987 | 1007 |
| 988 void GLCircleInside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& p
dman, | 1008 void GLCircleInside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& p
dman, |
| 989 const GrProcessor& processor) { | 1009 const GrProcessor& processor) { |
| 990 INHERITED::onSetData(pdman, processor); | 1010 INHERITED::onSetData(pdman, processor); |
| 991 const CircleInside2PtConicalEffect& data = processor.cast<CircleInside2PtCon
icalEffect>(); | 1011 const CircleInside2PtConicalEffect& data = processor.cast<CircleInside2PtCon
icalEffect>(); |
| 992 SkScalar centerX = data.centerX(); | 1012 SkScalar centerX = data.centerX(); |
| 993 SkScalar centerY = data.centerY(); | 1013 SkScalar centerY = data.centerY(); |
| 994 SkScalar A = data.A(); | 1014 SkScalar A = data.A(); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 "Conical2FSParams"); | 1206 "Conical2FSParams"); |
| 1187 SkString tName("t"); | 1207 SkString tName("t"); |
| 1188 | 1208 |
| 1189 GrGLSLShaderVar center = args.fBuilder->getUniformVariable(fCenterUni); | 1209 GrGLSLShaderVar center = args.fBuilder->getUniformVariable(fCenterUni); |
| 1190 // params.x = A | 1210 // params.x = A |
| 1191 // params.y = B | 1211 // params.y = B |
| 1192 // params.z = C | 1212 // params.z = C |
| 1193 GrGLSLShaderVar params = args.fBuilder->getUniformVariable(fParamUni); | 1213 GrGLSLShaderVar params = args.fBuilder->getUniformVariable(fParamUni); |
| 1194 | 1214 |
| 1195 // if we have a vec3 from being in perspective, convert it to a vec2 first | 1215 // if we have a vec3 from being in perspective, convert it to a vec2 first |
| 1196 GrGLSLFragmentBuilder* fsBuilder = args.fBuilder->getFragmentShaderBuilder()
; | 1216 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
| 1197 SkString coords2DString = fsBuilder->ensureFSCoords2D(args.fCoords, 0); | 1217 SkString coords2DString = fragBuilder->ensureFSCoords2D(args.fCoords, 0); |
| 1198 const char* coords2D = coords2DString.c_str(); | 1218 const char* coords2D = coords2DString.c_str(); |
| 1199 | 1219 |
| 1200 // output will default to transparent black (we simply won't write anything | 1220 // output will default to transparent black (we simply won't write anything |
| 1201 // else to it if invalid, instead of discarding or returning prematurely) | 1221 // else to it if invalid, instead of discarding or returning prematurely) |
| 1202 fsBuilder->codeAppendf("\t%s = vec4(0.0,0.0,0.0,0.0);\n", args.fOutputColor)
; | 1222 fragBuilder->codeAppendf("\t%s = vec4(0.0,0.0,0.0,0.0);\n", args.fOutputColo
r); |
| 1203 | 1223 |
| 1204 // p = coords2D | 1224 // p = coords2D |
| 1205 // e = center end | 1225 // e = center end |
| 1206 // r = radius end | 1226 // r = radius end |
| 1207 // A = dot(e, e) - r^2 + 2 * r - 1 | 1227 // A = dot(e, e) - r^2 + 2 * r - 1 |
| 1208 // B = (r -1) / A | 1228 // B = (r -1) / A |
| 1209 // C = 1 / A | 1229 // C = 1 / A |
| 1210 // d = dot(e, p) + B | 1230 // d = dot(e, p) + B |
| 1211 // t = d +/- sqrt(d^2 - A * dot(p, p) + C) | 1231 // t = d +/- sqrt(d^2 - A * dot(p, p) + C) |
| 1212 | 1232 |
| 1213 fsBuilder->codeAppendf("\tfloat pDotp = dot(%s, %s);\n", coords2D, coords2D
); | 1233 fragBuilder->codeAppendf("\tfloat pDotp = dot(%s, %s);\n", coords2D, coords
2D); |
| 1214 fsBuilder->codeAppendf("\tfloat d = dot(%s, %s) + %s.y;\n", coords2D, cente
r.c_str(), | 1234 fragBuilder->codeAppendf("\tfloat d = dot(%s, %s) + %s.y;\n", coords2D, cen
ter.c_str(), |
| 1215 params.c_str()); | 1235 params.c_str()); |
| 1216 fsBuilder->codeAppendf("\tfloat deter = d * d - %s.x * pDotp + %s.z;\n", par
ams.c_str(), | 1236 fragBuilder->codeAppendf("\tfloat deter = d * d - %s.x * pDotp + %s.z;\n", p
arams.c_str(), |
| 1217 params.c_str()); | 1237 params.c_str()); |
| 1218 | 1238 |
| 1219 // Must check to see if we flipped the circle order (to make sure start radi
us < end radius) | 1239 // Must check to see if we flipped the circle order (to make sure start radi
us < end radius) |
| 1220 // If so we must also flip sign on sqrt | 1240 // If so we must also flip sign on sqrt |
| 1221 if (!fIsFlipped) { | 1241 if (!fIsFlipped) { |
| 1222 fsBuilder->codeAppendf("\tfloat %s = d + sqrt(deter);\n", tName.c_str())
; | 1242 fragBuilder->codeAppendf("\tfloat %s = d + sqrt(deter);\n", tName.c_str(
)); |
| 1223 } else { | 1243 } else { |
| 1224 fsBuilder->codeAppendf("\tfloat %s = d - sqrt(deter);\n", tName.c_str())
; | 1244 fragBuilder->codeAppendf("\tfloat %s = d - sqrt(deter);\n", tName.c_str(
)); |
| 1225 } | 1245 } |
| 1226 | 1246 |
| 1227 fsBuilder->codeAppendf("\tif (%s >= %s.w && deter >= 0.0) {\n", tName.c_str(
), params.c_str()); | 1247 fragBuilder->codeAppendf("\tif (%s >= %s.w && deter >= 0.0) {\n", tName.c_st
r(), params.c_str()); |
| 1228 fsBuilder->codeAppend("\t\t"); | 1248 fragBuilder->codeAppend("\t\t"); |
| 1229 this->emitColor(args.fBuilder, ge, tName.c_str(), args.fOutputColor, args.fI
nputColor, | 1249 this->emitColor(args.fBuilder, |
| 1250 fragBuilder, |
| 1251 ge, |
| 1252 tName.c_str(), |
| 1253 args.fOutputColor, |
| 1254 args.fInputColor, |
| 1230 args.fSamplers); | 1255 args.fSamplers); |
| 1231 fsBuilder->codeAppend("\t}\n"); | 1256 fragBuilder->codeAppend("\t}\n"); |
| 1232 } | 1257 } |
| 1233 | 1258 |
| 1234 void GLCircleOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager&
pdman, | 1259 void GLCircleOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager&
pdman, |
| 1235 const GrProcessor& processor) { | 1260 const GrProcessor& processor) { |
| 1236 INHERITED::onSetData(pdman, processor); | 1261 INHERITED::onSetData(pdman, processor); |
| 1237 const CircleOutside2PtConicalEffect& data = processor.cast<CircleOutside2PtC
onicalEffect>(); | 1262 const CircleOutside2PtConicalEffect& data = processor.cast<CircleOutside2PtC
onicalEffect>(); |
| 1238 SkASSERT(data.isFlipped() == fIsFlipped); | 1263 SkASSERT(data.isFlipped() == fIsFlipped); |
| 1239 SkScalar centerX = data.centerX(); | 1264 SkScalar centerX = data.centerX(); |
| 1240 SkScalar centerY = data.centerY(); | 1265 SkScalar centerY = data.centerY(); |
| 1241 SkScalar A = data.A(); | 1266 SkScalar A = data.A(); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1304 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf
o); | 1329 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf
o); |
| 1305 } else if (type == kEdge_ConicalType) { | 1330 } else if (type == kEdge_ConicalType) { |
| 1306 set_matrix_edge_conical(shader, &matrix); | 1331 set_matrix_edge_conical(shader, &matrix); |
| 1307 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); | 1332 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); |
| 1308 } else { | 1333 } else { |
| 1309 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in
fo); | 1334 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in
fo); |
| 1310 } | 1335 } |
| 1311 } | 1336 } |
| 1312 | 1337 |
| 1313 #endif | 1338 #endif |
| OLD | NEW |