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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 // linear case: t = -c/b | 265 // linear case: t = -c/b |
266 fragBuilder->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 fragBuilder->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 fragBuilder->codeAppend("\t"); | 272 fragBuilder->codeAppend("\t"); |
273 this->emitColor(args.fBuilder, | 273 this->emitColor(args.fBuilder, |
274 fragBuilder, | 274 fragBuilder, |
| 275 args.fGLSLCaps, |
275 ge, | 276 ge, |
276 tName.c_str(), | 277 tName.c_str(), |
277 args.fOutputColor, | 278 args.fOutputColor, |
278 args.fInputColor, | 279 args.fInputColor, |
279 args.fSamplers); | 280 args.fSamplers); |
280 fragBuilder->codeAppend("\t}\n"); | 281 fragBuilder->codeAppend("\t}\n"); |
281 } | 282 } |
282 | 283 |
283 void GLEdge2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman, | 284 void GLEdge2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pdman, |
284 const GrProcessor& processor) { | 285 const GrProcessor& processor) { |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 coords2D, p0.c_str()); | 538 coords2D, p0.c_str()); |
538 } else { | 539 } else { |
539 fragBuilder->codeAppendf("\tfloat %s = %s.x * %s - sqrt(d);\n", tName.c
_str(), | 540 fragBuilder->codeAppendf("\tfloat %s = %s.x * %s - sqrt(d);\n", tName.c
_str(), |
540 coords2D, p0.c_str()); | 541 coords2D, p0.c_str()); |
541 } | 542 } |
542 | 543 |
543 fragBuilder->codeAppendf("\tif (%s >= 0.0 && d >= 0.0) {\n", tName.c_str()); | 544 fragBuilder->codeAppendf("\tif (%s >= 0.0 && d >= 0.0) {\n", tName.c_str()); |
544 fragBuilder->codeAppend("\t\t"); | 545 fragBuilder->codeAppend("\t\t"); |
545 this->emitColor(args.fBuilder, | 546 this->emitColor(args.fBuilder, |
546 fragBuilder, | 547 fragBuilder, |
| 548 args.fGLSLCaps, |
547 ge, | 549 ge, |
548 tName.c_str(), | 550 tName.c_str(), |
549 args.fOutputColor, | 551 args.fOutputColor, |
550 args.fInputColor, | 552 args.fInputColor, |
551 args.fSamplers); | 553 args.fSamplers); |
552 fragBuilder->codeAppend("\t}\n"); | 554 fragBuilder->codeAppend("\t}\n"); |
553 } | 555 } |
554 | 556 |
555 void GLFocalOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& p
dman, | 557 void GLFocalOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& p
dman, |
556 const GrProcessor& processor) { | 558 const GrProcessor& processor) { |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; | 728 GrGLSLFragmentBuilder* fragBuilder = args.fFragBuilder; |
727 SkString coords2DString = fragBuilder->ensureFSCoords2D(args.fCoords, 0); | 729 SkString coords2DString = fragBuilder->ensureFSCoords2D(args.fCoords, 0); |
728 const char* coords2D = coords2DString.c_str(); | 730 const char* coords2D = coords2DString.c_str(); |
729 | 731 |
730 // t = p.x * focalX + length(p) | 732 // t = p.x * focalX + length(p) |
731 fragBuilder->codeAppendf("\tfloat %s = %s.x * %s + length(%s);\n", tName.c_
str(), | 733 fragBuilder->codeAppendf("\tfloat %s = %s.x * %s + length(%s);\n", tName.c_
str(), |
732 coords2D, focal.c_str(), coords2D); | 734 coords2D, focal.c_str(), coords2D); |
733 | 735 |
734 this->emitColor(args.fBuilder, | 736 this->emitColor(args.fBuilder, |
735 fragBuilder, | 737 fragBuilder, |
| 738 args.fGLSLCaps, |
736 ge, | 739 ge, |
737 tName.c_str(), | 740 tName.c_str(), |
738 args.fOutputColor, | 741 args.fOutputColor, |
739 args.fInputColor, | 742 args.fInputColor, |
740 args.fSamplers); | 743 args.fSamplers); |
741 } | 744 } |
742 | 745 |
743 void GLFocalInside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pd
man, | 746 void GLFocalInside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& pd
man, |
744 const GrProcessor& processor) { | 747 const GrProcessor& processor) { |
745 INHERITED::onSetData(pdman, processor); | 748 INHERITED::onSetData(pdman, processor); |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 // d = dot(e, p) + B | 994 // d = dot(e, p) + B |
992 // t = d +/- sqrt(d^2 - A * dot(p, p) + C) | 995 // t = d +/- sqrt(d^2 - A * dot(p, p) + C) |
993 fragBuilder->codeAppendf("\tfloat pDotp = dot(%s, %s);\n", coords2D, coords
2D); | 996 fragBuilder->codeAppendf("\tfloat pDotp = dot(%s, %s);\n", coords2D, coords
2D); |
994 fragBuilder->codeAppendf("\tfloat d = dot(%s, %s) + %s.y;\n", coords2D, cen
ter.c_str(), | 997 fragBuilder->codeAppendf("\tfloat d = dot(%s, %s) + %s.y;\n", coords2D, cen
ter.c_str(), |
995 params.c_str()); | 998 params.c_str()); |
996 fragBuilder->codeAppendf("\tfloat %s = d + sqrt(d * d - %s.x * pDotp + %s.z)
;\n", | 999 fragBuilder->codeAppendf("\tfloat %s = d + sqrt(d * d - %s.x * pDotp + %s.z)
;\n", |
997 tName.c_str(), params.c_str(), params.c_str()); | 1000 tName.c_str(), params.c_str(), params.c_str()); |
998 | 1001 |
999 this->emitColor(args.fBuilder, | 1002 this->emitColor(args.fBuilder, |
1000 fragBuilder, | 1003 fragBuilder, |
| 1004 args.fGLSLCaps, |
1001 ge, | 1005 ge, |
1002 tName.c_str(), | 1006 tName.c_str(), |
1003 args.fOutputColor, | 1007 args.fOutputColor, |
1004 args.fInputColor, | 1008 args.fInputColor, |
1005 args.fSamplers); | 1009 args.fSamplers); |
1006 } | 1010 } |
1007 | 1011 |
1008 void GLCircleInside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& p
dman, | 1012 void GLCircleInside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager& p
dman, |
1009 const GrProcessor& processor) { | 1013 const GrProcessor& processor) { |
1010 INHERITED::onSetData(pdman, processor); | 1014 INHERITED::onSetData(pdman, processor); |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 if (!fIsFlipped) { | 1245 if (!fIsFlipped) { |
1242 fragBuilder->codeAppendf("\tfloat %s = d + sqrt(deter);\n", tName.c_str(
)); | 1246 fragBuilder->codeAppendf("\tfloat %s = d + sqrt(deter);\n", tName.c_str(
)); |
1243 } else { | 1247 } else { |
1244 fragBuilder->codeAppendf("\tfloat %s = d - sqrt(deter);\n", tName.c_str(
)); | 1248 fragBuilder->codeAppendf("\tfloat %s = d - sqrt(deter);\n", tName.c_str(
)); |
1245 } | 1249 } |
1246 | 1250 |
1247 fragBuilder->codeAppendf("\tif (%s >= %s.w && deter >= 0.0) {\n", tName.c_st
r(), params.c_str()); | 1251 fragBuilder->codeAppendf("\tif (%s >= %s.w && deter >= 0.0) {\n", tName.c_st
r(), params.c_str()); |
1248 fragBuilder->codeAppend("\t\t"); | 1252 fragBuilder->codeAppend("\t\t"); |
1249 this->emitColor(args.fBuilder, | 1253 this->emitColor(args.fBuilder, |
1250 fragBuilder, | 1254 fragBuilder, |
| 1255 args.fGLSLCaps, |
1251 ge, | 1256 ge, |
1252 tName.c_str(), | 1257 tName.c_str(), |
1253 args.fOutputColor, | 1258 args.fOutputColor, |
1254 args.fInputColor, | 1259 args.fInputColor, |
1255 args.fSamplers); | 1260 args.fSamplers); |
1256 fragBuilder->codeAppend("\t}\n"); | 1261 fragBuilder->codeAppend("\t}\n"); |
1257 } | 1262 } |
1258 | 1263 |
1259 void GLCircleOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager&
pdman, | 1264 void GLCircleOutside2PtConicalEffect::onSetData(const GrGLSLProgramDataManager&
pdman, |
1260 const GrProcessor& processor) { | 1265 const GrProcessor& processor) { |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf
o); | 1334 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf
o); |
1330 } else if (type == kEdge_ConicalType) { | 1335 } else if (type == kEdge_ConicalType) { |
1331 set_matrix_edge_conical(shader, &matrix); | 1336 set_matrix_edge_conical(shader, &matrix); |
1332 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); | 1337 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); |
1333 } else { | 1338 } else { |
1334 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in
fo); | 1339 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in
fo); |
1335 } | 1340 } |
1336 } | 1341 } |
1337 | 1342 |
1338 #endif | 1343 #endif |
OLD | NEW |