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 |
11 #include "SkTwoPointConicalGradient.h" | 11 #include "SkTwoPointConicalGradient.h" |
12 | 12 |
13 #if SK_SUPPORT_GPU | 13 #if SK_SUPPORT_GPU |
14 #include "GrTBackendEffectFactory.h" | 14 #include "GrTBackendEffectFactory.h" |
15 #include "gl/GrGLShaderBuilder.h" | 15 #include "gl/GrGLShaderBuilder.h" |
16 // For brevity | 16 // For brevity |
17 typedef GrGLUniformManager::UniformHandle UniformHandle; | 17 typedef GrGLProgramDataManager::UniformHandle UniformHandle; |
18 | 18 |
19 static const SkScalar kErrorTol = 0.00001f; | 19 static const SkScalar kErrorTol = 0.00001f; |
20 static const SkScalar kEdgeErrorTol = 5.f * kErrorTol; | 20 static const SkScalar kEdgeErrorTol = 5.f * kErrorTol; |
21 | 21 |
22 /** | 22 /** |
23 * We have three general cases for 2pt conical gradients. First we always assume
that | 23 * We have three general cases for 2pt conical gradients. First we always assume
that |
24 * the start radius <= end radius. Our first case (kInside_) is when the start c
ircle | 24 * the start radius <= end radius. Our first case (kInside_) is when the start c
ircle |
25 * is completely enclosed by the end circle. The second case (kOutside_) is the
case | 25 * is completely enclosed by the end circle. The second case (kOutside_) is the
case |
26 * when the start circle is either completely outside the end circle or the circ
les | 26 * when the start circle is either completely outside the end circle or the circ
les |
27 * overlap. The final case (kEdge_) is when the start circle is inside the end o
ne, | 27 * overlap. The final case (kEdge_) is when the start circle is inside the end o
ne, |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 GLEdge2PtConicalEffect(const GrBackendEffectFactory& factory, const GrDrawEf
fect&); | 137 GLEdge2PtConicalEffect(const GrBackendEffectFactory& factory, const GrDrawEf
fect&); |
138 virtual ~GLEdge2PtConicalEffect() { } | 138 virtual ~GLEdge2PtConicalEffect() { } |
139 | 139 |
140 virtual void emitCode(GrGLShaderBuilder*, | 140 virtual void emitCode(GrGLShaderBuilder*, |
141 const GrDrawEffect&, | 141 const GrDrawEffect&, |
142 const GrEffectKey&, | 142 const GrEffectKey&, |
143 const char* outputColor, | 143 const char* outputColor, |
144 const char* inputColor, | 144 const char* inputColor, |
145 const TransformedCoordsArray&, | 145 const TransformedCoordsArray&, |
146 const TextureSamplerArray&) SK_OVERRIDE; | 146 const TextureSamplerArray&) SK_OVERRIDE; |
147 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; | 147 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_
OVERRIDE; |
148 | 148 |
149 static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBui
lder* b); | 149 static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBui
lder* b); |
150 | 150 |
151 protected: | 151 protected: |
152 UniformHandle fParamUni; | 152 UniformHandle fParamUni; |
153 | 153 |
154 const char* fVSVaryingName; | 154 const char* fVSVaryingName; |
155 const char* fFSVaryingName; | 155 const char* fFSVaryingName; |
156 | 156 |
157 // @{ | 157 // @{ |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 cName.c_str(), bVar.c_str()); | 266 cName.c_str(), bVar.c_str()); |
267 | 267 |
268 // if r(t) > 0, then t will be the x coordinate | 268 // if r(t) > 0, then t will be the x coordinate |
269 builder->fsCodeAppendf("\tif (%s * %s + %s > 0.0) {\n", tName.c_str(), | 269 builder->fsCodeAppendf("\tif (%s * %s + %s > 0.0) {\n", tName.c_str(), |
270 p2.c_str(), p0.c_str()); | 270 p2.c_str(), p0.c_str()); |
271 builder->fsCodeAppend("\t"); | 271 builder->fsCodeAppend("\t"); |
272 this->emitColor(builder, tName.c_str(), baseKey, outputColor, inputColor, sa
mplers); | 272 this->emitColor(builder, tName.c_str(), baseKey, outputColor, inputColor, sa
mplers); |
273 builder->fsCodeAppend("\t}\n"); | 273 builder->fsCodeAppend("\t}\n"); |
274 } | 274 } |
275 | 275 |
276 void GLEdge2PtConicalEffect::setData(const GrGLUniformManager& uman, | 276 void GLEdge2PtConicalEffect::setData(const GrGLProgramDataManager& pdman, |
277 const GrDrawEffect& drawEffect) { | 277 const GrDrawEffect& drawEffect) { |
278 INHERITED::setData(uman, drawEffect); | 278 INHERITED::setData(pdman, drawEffect); |
279 const Edge2PtConicalEffect& data = drawEffect.castEffect<Edge2PtConicalEffec
t>(); | 279 const Edge2PtConicalEffect& data = drawEffect.castEffect<Edge2PtConicalEffec
t>(); |
280 SkScalar radius0 = data.radius(); | 280 SkScalar radius0 = data.radius(); |
281 SkScalar diffRadius = data.diffRadius(); | 281 SkScalar diffRadius = data.diffRadius(); |
282 | 282 |
283 if (fCachedRadius != radius0 || | 283 if (fCachedRadius != radius0 || |
284 fCachedDiffRadius != diffRadius) { | 284 fCachedDiffRadius != diffRadius) { |
285 | 285 |
286 float values[3] = { | 286 float values[3] = { |
287 SkScalarToFloat(radius0), | 287 SkScalarToFloat(radius0), |
288 SkScalarToFloat(SkScalarMul(radius0, radius0)), | 288 SkScalarToFloat(SkScalarMul(radius0, radius0)), |
289 SkScalarToFloat(diffRadius) | 289 SkScalarToFloat(diffRadius) |
290 }; | 290 }; |
291 | 291 |
292 uman.set1fv(fParamUni, 3, values); | 292 pdman.set1fv(fParamUni, 3, values); |
293 fCachedRadius = radius0; | 293 fCachedRadius = radius0; |
294 fCachedDiffRadius = diffRadius; | 294 fCachedDiffRadius = diffRadius; |
295 } | 295 } |
296 } | 296 } |
297 | 297 |
298 void GLEdge2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect, | 298 void GLEdge2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect, |
299 const GrGLCaps&, GrEffectKeyBuilder* b) { | 299 const GrGLCaps&, GrEffectKeyBuilder* b) { |
300 b->add32(GenBaseGradientKey(drawEffect)); | 300 b->add32(GenBaseGradientKey(drawEffect)); |
301 } | 301 } |
302 | 302 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 GLFocalOutside2PtConicalEffect(const GrBackendEffectFactory& factory, const
GrDrawEffect&); | 413 GLFocalOutside2PtConicalEffect(const GrBackendEffectFactory& factory, const
GrDrawEffect&); |
414 virtual ~GLFocalOutside2PtConicalEffect() { } | 414 virtual ~GLFocalOutside2PtConicalEffect() { } |
415 | 415 |
416 virtual void emitCode(GrGLShaderBuilder*, | 416 virtual void emitCode(GrGLShaderBuilder*, |
417 const GrDrawEffect&, | 417 const GrDrawEffect&, |
418 const GrEffectKey&, | 418 const GrEffectKey&, |
419 const char* outputColor, | 419 const char* outputColor, |
420 const char* inputColor, | 420 const char* inputColor, |
421 const TransformedCoordsArray&, | 421 const TransformedCoordsArray&, |
422 const TextureSamplerArray&) SK_OVERRIDE; | 422 const TextureSamplerArray&) SK_OVERRIDE; |
423 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; | 423 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_
OVERRIDE; |
424 | 424 |
425 static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBui
lder* b); | 425 static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBui
lder* b); |
426 | 426 |
427 protected: | 427 protected: |
428 UniformHandle fParamUni; | 428 UniformHandle fParamUni; |
429 | 429 |
430 const char* fVSVaryingName; | 430 const char* fVSVaryingName; |
431 const char* fFSVaryingName; | 431 const char* fFSVaryingName; |
432 | 432 |
433 bool fIsFlipped; | 433 bool fIsFlipped; |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 builder->fsCodeAppendf("\tfloat %s = %s.x * %s - sqrt(d);\n", tName.c_s
tr(), | 534 builder->fsCodeAppendf("\tfloat %s = %s.x * %s - sqrt(d);\n", tName.c_s
tr(), |
535 coords2D, p0.c_str()); | 535 coords2D, p0.c_str()); |
536 } | 536 } |
537 | 537 |
538 builder->fsCodeAppendf("\tif (%s >= 0.0 && d >= 0.0) {\n", tName.c_str()); | 538 builder->fsCodeAppendf("\tif (%s >= 0.0 && d >= 0.0) {\n", tName.c_str()); |
539 builder->fsCodeAppend("\t\t"); | 539 builder->fsCodeAppend("\t\t"); |
540 this->emitColor(builder, tName.c_str(), baseKey, outputColor, inputColor, sa
mplers); | 540 this->emitColor(builder, tName.c_str(), baseKey, outputColor, inputColor, sa
mplers); |
541 builder->fsCodeAppend("\t}\n"); | 541 builder->fsCodeAppend("\t}\n"); |
542 } | 542 } |
543 | 543 |
544 void GLFocalOutside2PtConicalEffect::setData(const GrGLUniformManager& uman, | 544 void GLFocalOutside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman
, |
545 const GrDrawEffect& drawEffect) { | 545 const GrDrawEffect& drawEffect) { |
546 INHERITED::setData(uman, drawEffect); | 546 INHERITED::setData(pdman, drawEffect); |
547 const FocalOutside2PtConicalEffect& data = drawEffect.castEffect<FocalOutsid
e2PtConicalEffect>(); | 547 const FocalOutside2PtConicalEffect& data = drawEffect.castEffect<FocalOutsid
e2PtConicalEffect>(); |
548 SkASSERT(data.isFlipped() == fIsFlipped); | 548 SkASSERT(data.isFlipped() == fIsFlipped); |
549 SkScalar focal = data.focal(); | 549 SkScalar focal = data.focal(); |
550 | 550 |
551 if (fCachedFocal != focal) { | 551 if (fCachedFocal != focal) { |
552 SkScalar oneMinus2F = 1.f - SkScalarMul(focal, focal); | 552 SkScalar oneMinus2F = 1.f - SkScalarMul(focal, focal); |
553 | 553 |
554 float values[2] = { | 554 float values[2] = { |
555 SkScalarToFloat(focal), | 555 SkScalarToFloat(focal), |
556 SkScalarToFloat(oneMinus2F), | 556 SkScalarToFloat(oneMinus2F), |
557 }; | 557 }; |
558 | 558 |
559 uman.set1fv(fParamUni, 2, values); | 559 pdman.set1fv(fParamUni, 2, values); |
560 fCachedFocal = focal; | 560 fCachedFocal = focal; |
561 } | 561 } |
562 } | 562 } |
563 | 563 |
564 void GLFocalOutside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect, | 564 void GLFocalOutside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect, |
565 const GrGLCaps&, GrEffectKeyBuilder*
b) { | 565 const GrGLCaps&, GrEffectKeyBuilder*
b) { |
566 uint32_t* key = b->add32n(2); | 566 uint32_t* key = b->add32n(2); |
567 key[0] = GenBaseGradientKey(drawEffect); | 567 key[0] = GenBaseGradientKey(drawEffect); |
568 key[1] = drawEffect.castEffect<FocalOutside2PtConicalEffect>().isFlipped(); | 568 key[1] = drawEffect.castEffect<FocalOutside2PtConicalEffect>().isFlipped(); |
569 } | 569 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 GLFocalInside2PtConicalEffect(const GrBackendEffectFactory& factory, const G
rDrawEffect&); | 618 GLFocalInside2PtConicalEffect(const GrBackendEffectFactory& factory, const G
rDrawEffect&); |
619 virtual ~GLFocalInside2PtConicalEffect() {} | 619 virtual ~GLFocalInside2PtConicalEffect() {} |
620 | 620 |
621 virtual void emitCode(GrGLShaderBuilder*, | 621 virtual void emitCode(GrGLShaderBuilder*, |
622 const GrDrawEffect&, | 622 const GrDrawEffect&, |
623 const GrEffectKey&, | 623 const GrEffectKey&, |
624 const char* outputColor, | 624 const char* outputColor, |
625 const char* inputColor, | 625 const char* inputColor, |
626 const TransformedCoordsArray&, | 626 const TransformedCoordsArray&, |
627 const TextureSamplerArray&) SK_OVERRIDE; | 627 const TextureSamplerArray&) SK_OVERRIDE; |
628 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; | 628 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_
OVERRIDE; |
629 | 629 |
630 static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBui
lder* b); | 630 static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBui
lder* b); |
631 | 631 |
632 protected: | 632 protected: |
633 UniformHandle fFocalUni; | 633 UniformHandle fFocalUni; |
634 | 634 |
635 const char* fVSVaryingName; | 635 const char* fVSVaryingName; |
636 const char* fFSVaryingName; | 636 const char* fFSVaryingName; |
637 | 637 |
638 // @{ | 638 // @{ |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 SkString coords2DString = builder->ensureFSCoords2D(coords, 0); | 716 SkString coords2DString = builder->ensureFSCoords2D(coords, 0); |
717 const char* coords2D = coords2DString.c_str(); | 717 const char* coords2D = coords2DString.c_str(); |
718 | 718 |
719 // t = p.x * focalX + length(p) | 719 // t = p.x * focalX + length(p) |
720 builder->fsCodeAppendf("\tfloat %s = %s.x * %s + length(%s);\n", tName.c_st
r(), | 720 builder->fsCodeAppendf("\tfloat %s = %s.x * %s + length(%s);\n", tName.c_st
r(), |
721 coords2D, focal.c_str(), coords2D); | 721 coords2D, focal.c_str(), coords2D); |
722 | 722 |
723 this->emitColor(builder, tName.c_str(), baseKey, outputColor, inputColor, sa
mplers); | 723 this->emitColor(builder, tName.c_str(), baseKey, outputColor, inputColor, sa
mplers); |
724 } | 724 } |
725 | 725 |
726 void GLFocalInside2PtConicalEffect::setData(const GrGLUniformManager& uman, | 726 void GLFocalInside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman, |
727 const GrDrawEffect& drawEffect) { | 727 const GrDrawEffect& drawEffect) { |
728 INHERITED::setData(uman, drawEffect); | 728 INHERITED::setData(pdman, drawEffect); |
729 const FocalInside2PtConicalEffect& data = drawEffect.castEffect<FocalInside2
PtConicalEffect>(); | 729 const FocalInside2PtConicalEffect& data = drawEffect.castEffect<FocalInside2
PtConicalEffect>(); |
730 SkScalar focal = data.focal(); | 730 SkScalar focal = data.focal(); |
731 | 731 |
732 if (fCachedFocal != focal) { | 732 if (fCachedFocal != focal) { |
733 uman.set1f(fFocalUni, SkScalarToFloat(focal)); | 733 pdman.set1f(fFocalUni, SkScalarToFloat(focal)); |
734 fCachedFocal = focal; | 734 fCachedFocal = focal; |
735 } | 735 } |
736 } | 736 } |
737 | 737 |
738 void GLFocalInside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect, | 738 void GLFocalInside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect, |
739 const GrGLCaps&, GrEffectKeyBuilder*
b) { | 739 const GrGLCaps&, GrEffectKeyBuilder*
b) { |
740 b->add32(GenBaseGradientKey(drawEffect)); | 740 b->add32(GenBaseGradientKey(drawEffect)); |
741 } | 741 } |
742 | 742 |
743 ////////////////////////////////////////////////////////////////////////////// | 743 ////////////////////////////////////////////////////////////////////////////// |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 GLCircleInside2PtConicalEffect(const GrBackendEffectFactory& factory, const
GrDrawEffect&); | 859 GLCircleInside2PtConicalEffect(const GrBackendEffectFactory& factory, const
GrDrawEffect&); |
860 virtual ~GLCircleInside2PtConicalEffect() {} | 860 virtual ~GLCircleInside2PtConicalEffect() {} |
861 | 861 |
862 virtual void emitCode(GrGLShaderBuilder*, | 862 virtual void emitCode(GrGLShaderBuilder*, |
863 const GrDrawEffect&, | 863 const GrDrawEffect&, |
864 const GrEffectKey&, | 864 const GrEffectKey&, |
865 const char* outputColor, | 865 const char* outputColor, |
866 const char* inputColor, | 866 const char* inputColor, |
867 const TransformedCoordsArray&, | 867 const TransformedCoordsArray&, |
868 const TextureSamplerArray&) SK_OVERRIDE; | 868 const TextureSamplerArray&) SK_OVERRIDE; |
869 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; | 869 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_
OVERRIDE; |
870 | 870 |
871 static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBui
lder* b); | 871 static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBui
lder* b); |
872 | 872 |
873 protected: | 873 protected: |
874 UniformHandle fCenterUni; | 874 UniformHandle fCenterUni; |
875 UniformHandle fParamUni; | 875 UniformHandle fParamUni; |
876 | 876 |
877 const char* fVSVaryingName; | 877 const char* fVSVaryingName; |
878 const char* fFSVaryingName; | 878 const char* fFSVaryingName; |
879 | 879 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 // d = dot(e, p) + B | 978 // d = dot(e, p) + B |
979 // t = d +/- sqrt(d^2 - A * dot(p, p) + C) | 979 // t = d +/- sqrt(d^2 - A * dot(p, p) + C) |
980 builder->fsCodeAppendf("\tfloat pDotp = dot(%s, %s);\n", coords2D, coords2D
); | 980 builder->fsCodeAppendf("\tfloat pDotp = dot(%s, %s);\n", coords2D, coords2D
); |
981 builder->fsCodeAppendf("\tfloat d = dot(%s, %s) + %s.y;\n", coords2D, cente
r.c_str(), params.c_str()); | 981 builder->fsCodeAppendf("\tfloat d = dot(%s, %s) + %s.y;\n", coords2D, cente
r.c_str(), params.c_str()); |
982 builder->fsCodeAppendf("\tfloat %s = d + sqrt(d * d - %s.x * pDotp + %s.z);\
n", | 982 builder->fsCodeAppendf("\tfloat %s = d + sqrt(d * d - %s.x * pDotp + %s.z);\
n", |
983 tName.c_str(), params.c_str(), params.c_str()); | 983 tName.c_str(), params.c_str(), params.c_str()); |
984 | 984 |
985 this->emitColor(builder, tName.c_str(), baseKey, outputColor, inputColor, sa
mplers); | 985 this->emitColor(builder, tName.c_str(), baseKey, outputColor, inputColor, sa
mplers); |
986 } | 986 } |
987 | 987 |
988 void GLCircleInside2PtConicalEffect::setData(const GrGLUniformManager& uman, | 988 void GLCircleInside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman
, |
989 const GrDrawEffect& drawEffect) { | 989 const GrDrawEffect& drawEffect) { |
990 INHERITED::setData(uman, drawEffect); | 990 INHERITED::setData(pdman, drawEffect); |
991 const CircleInside2PtConicalEffect& data = drawEffect.castEffect<CircleInsid
e2PtConicalEffect>(); | 991 const CircleInside2PtConicalEffect& data = drawEffect.castEffect<CircleInsid
e2PtConicalEffect>(); |
992 SkScalar centerX = data.centerX(); | 992 SkScalar centerX = data.centerX(); |
993 SkScalar centerY = data.centerY(); | 993 SkScalar centerY = data.centerY(); |
994 SkScalar A = data.A(); | 994 SkScalar A = data.A(); |
995 SkScalar B = data.B(); | 995 SkScalar B = data.B(); |
996 SkScalar C = data.C(); | 996 SkScalar C = data.C(); |
997 | 997 |
998 if (fCachedCenterX != centerX || fCachedCenterY != centerY || | 998 if (fCachedCenterX != centerX || fCachedCenterY != centerY || |
999 fCachedA != A || fCachedB != B || fCachedC != C) { | 999 fCachedA != A || fCachedB != B || fCachedC != C) { |
1000 | 1000 |
1001 uman.set2f(fCenterUni, SkScalarToFloat(centerX), SkScalarToFloat(centerY
)); | 1001 pdman.set2f(fCenterUni, SkScalarToFloat(centerX), SkScalarToFloat(center
Y)); |
1002 uman.set3f(fParamUni, SkScalarToFloat(A), SkScalarToFloat(B), SkScalarTo
Float(C)); | 1002 pdman.set3f(fParamUni, SkScalarToFloat(A), SkScalarToFloat(B), SkScalarT
oFloat(C)); |
1003 | 1003 |
1004 fCachedCenterX = centerX; | 1004 fCachedCenterX = centerX; |
1005 fCachedCenterY = centerY; | 1005 fCachedCenterY = centerY; |
1006 fCachedA = A; | 1006 fCachedA = A; |
1007 fCachedB = B; | 1007 fCachedB = B; |
1008 fCachedC = C; | 1008 fCachedC = C; |
1009 } | 1009 } |
1010 } | 1010 } |
1011 | 1011 |
1012 void GLCircleInside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect, | 1012 void GLCircleInside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1085 GLCircleOutside2PtConicalEffect(const GrBackendEffectFactory& factory, const
GrDrawEffect&); | 1085 GLCircleOutside2PtConicalEffect(const GrBackendEffectFactory& factory, const
GrDrawEffect&); |
1086 virtual ~GLCircleOutside2PtConicalEffect() {} | 1086 virtual ~GLCircleOutside2PtConicalEffect() {} |
1087 | 1087 |
1088 virtual void emitCode(GrGLShaderBuilder*, | 1088 virtual void emitCode(GrGLShaderBuilder*, |
1089 const GrDrawEffect&, | 1089 const GrDrawEffect&, |
1090 const GrEffectKey&, | 1090 const GrEffectKey&, |
1091 const char* outputColor, | 1091 const char* outputColor, |
1092 const char* inputColor, | 1092 const char* inputColor, |
1093 const TransformedCoordsArray&, | 1093 const TransformedCoordsArray&, |
1094 const TextureSamplerArray&) SK_OVERRIDE; | 1094 const TextureSamplerArray&) SK_OVERRIDE; |
1095 virtual void setData(const GrGLUniformManager&, const GrDrawEffect&) SK_OVER
RIDE; | 1095 virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_
OVERRIDE; |
1096 | 1096 |
1097 static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBui
lder* b); | 1097 static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBui
lder* b); |
1098 | 1098 |
1099 protected: | 1099 protected: |
1100 UniformHandle fCenterUni; | 1100 UniformHandle fCenterUni; |
1101 UniformHandle fParamUni; | 1101 UniformHandle fParamUni; |
1102 | 1102 |
1103 const char* fVSVaryingName; | 1103 const char* fVSVaryingName; |
1104 const char* fFSVaryingName; | 1104 const char* fFSVaryingName; |
1105 | 1105 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1227 } else { | 1227 } else { |
1228 builder->fsCodeAppendf("\tfloat %s = d - sqrt(deter);\n", tName.c_str())
; | 1228 builder->fsCodeAppendf("\tfloat %s = d - sqrt(deter);\n", tName.c_str())
; |
1229 } | 1229 } |
1230 | 1230 |
1231 builder->fsCodeAppendf("\tif (%s >= %s.w && deter >= 0.0) {\n", tName.c_str(
), params.c_str()); | 1231 builder->fsCodeAppendf("\tif (%s >= %s.w && deter >= 0.0) {\n", tName.c_str(
), params.c_str()); |
1232 builder->fsCodeAppend("\t\t"); | 1232 builder->fsCodeAppend("\t\t"); |
1233 this->emitColor(builder, tName.c_str(), baseKey, outputColor, inputColor, sa
mplers); | 1233 this->emitColor(builder, tName.c_str(), baseKey, outputColor, inputColor, sa
mplers); |
1234 builder->fsCodeAppend("\t}\n"); | 1234 builder->fsCodeAppend("\t}\n"); |
1235 } | 1235 } |
1236 | 1236 |
1237 void GLCircleOutside2PtConicalEffect::setData(const GrGLUniformManager& uman, | 1237 void GLCircleOutside2PtConicalEffect::setData(const GrGLProgramDataManager& pdma
n, |
1238 const GrDrawEffect& drawEffect) { | 1238 const GrDrawEffect& drawEffect) { |
1239 INHERITED::setData(uman, drawEffect); | 1239 INHERITED::setData(pdman, drawEffect); |
1240 const CircleOutside2PtConicalEffect& data = drawEffect.castEffect<CircleOuts
ide2PtConicalEffect>(); | 1240 const CircleOutside2PtConicalEffect& data = drawEffect.castEffect<CircleOuts
ide2PtConicalEffect>(); |
1241 SkASSERT(data.isFlipped() == fIsFlipped); | 1241 SkASSERT(data.isFlipped() == fIsFlipped); |
1242 SkScalar centerX = data.centerX(); | 1242 SkScalar centerX = data.centerX(); |
1243 SkScalar centerY = data.centerY(); | 1243 SkScalar centerY = data.centerY(); |
1244 SkScalar A = data.A(); | 1244 SkScalar A = data.A(); |
1245 SkScalar B = data.B(); | 1245 SkScalar B = data.B(); |
1246 SkScalar C = data.C(); | 1246 SkScalar C = data.C(); |
1247 SkScalar tLimit = data.tLimit(); | 1247 SkScalar tLimit = data.tLimit(); |
1248 | 1248 |
1249 if (fCachedCenterX != centerX || fCachedCenterY != centerY || | 1249 if (fCachedCenterX != centerX || fCachedCenterY != centerY || |
1250 fCachedA != A || fCachedB != B || fCachedC != C || fCachedTLimit != tLim
it) { | 1250 fCachedA != A || fCachedB != B || fCachedC != C || fCachedTLimit != tLim
it) { |
1251 | 1251 |
1252 uman.set2f(fCenterUni, SkScalarToFloat(centerX), SkScalarToFloat(centerY
)); | 1252 pdman.set2f(fCenterUni, SkScalarToFloat(centerX), SkScalarToFloat(center
Y)); |
1253 uman.set4f(fParamUni, SkScalarToFloat(A), SkScalarToFloat(B), SkScalarTo
Float(C), | 1253 pdman.set4f(fParamUni, SkScalarToFloat(A), SkScalarToFloat(B), SkScalarT
oFloat(C), |
1254 SkScalarToFloat(tLimit)); | 1254 SkScalarToFloat(tLimit)); |
1255 | 1255 |
1256 fCachedCenterX = centerX; | 1256 fCachedCenterX = centerX; |
1257 fCachedCenterY = centerY; | 1257 fCachedCenterY = centerY; |
1258 fCachedA = A; | 1258 fCachedA = A; |
1259 fCachedB = B; | 1259 fCachedB = B; |
1260 fCachedC = C; | 1260 fCachedC = C; |
1261 fCachedTLimit = tLimit; | 1261 fCachedTLimit = tLimit; |
1262 } | 1262 } |
1263 } | 1263 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1307 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf
o); | 1307 return CircleInside2PtConicalEffect::Create(ctx, shader, matrix, tm, inf
o); |
1308 } else if (type == kEdge_ConicalType) { | 1308 } else if (type == kEdge_ConicalType) { |
1309 set_matrix_edge_conical(shader, &matrix); | 1309 set_matrix_edge_conical(shader, &matrix); |
1310 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); | 1310 return Edge2PtConicalEffect::Create(ctx, shader, matrix, tm); |
1311 } else { | 1311 } else { |
1312 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in
fo); | 1312 return CircleOutside2PtConicalEffect::Create(ctx, shader, matrix, tm, in
fo); |
1313 } | 1313 } |
1314 } | 1314 } |
1315 | 1315 |
1316 #endif | 1316 #endif |
OLD | NEW |