| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 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 "SkTwoPointRadialGradient.h" | 9 #include "SkTwoPointRadialGradient.h" |
| 10 | 10 |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 fIsDegenerate = data.isDegenerate(); | 525 fIsDegenerate = data.isDegenerate(); |
| 526 } | 526 } |
| 527 | 527 |
| 528 void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder, | 528 void GrGLRadial2Gradient::emitCode(GrGLShaderBuilder* builder, |
| 529 const GrDrawEffect& drawEffect, | 529 const GrDrawEffect& drawEffect, |
| 530 EffectKey key, | 530 EffectKey key, |
| 531 const char* outputColor, | 531 const char* outputColor, |
| 532 const char* inputColor, | 532 const char* inputColor, |
| 533 const TextureSamplerArray& samplers) { | 533 const TextureSamplerArray& samplers) { |
| 534 | 534 |
| 535 this->emitYCoordUniform(builder); | 535 this->emitUniforms(builder, key); |
| 536 SkString fsCoords; | 536 SkString fsCoords; |
| 537 SkString vsCoordsVarying; | 537 SkString vsCoordsVarying; |
| 538 |
| 538 GrSLType coordsVaryingType; | 539 GrSLType coordsVaryingType; |
| 539 this->setupMatrix(builder, key, &fsCoords, &vsCoordsVarying, &coordsVaryingT
ype); | 540 this->setupMatrix(builder, key, &fsCoords, &vsCoordsVarying, &coordsVaryingT
ype); |
| 540 | 541 |
| 541 // 2 copies of uniform array, 1 for each of vertex & fragment shader, | 542 // 2 copies of uniform array, 1 for each of vertex & fragment shader, |
| 542 // to work around Xoom bug. Doesn't seem to cause performance decrease | 543 // to work around Xoom bug. Doesn't seem to cause performance decrease |
| 543 // in test apps, but need to keep an eye on it. | 544 // in test apps, but need to keep an eye on it. |
| 544 fVSParamUni = builder->addUniformArray(GrGLShaderBuilder::kVertex_Visibility
, | 545 fVSParamUni = builder->addUniformArray(GrGLShaderBuilder::kVertex_Visibility
, |
| 545 kFloat_GrSLType, "Radial2VSParams", 6
); | 546 kFloat_GrSLType, "Radial2VSParams", 6
); |
| 546 fFSParamUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibili
ty, | 547 fFSParamUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_Visibili
ty, |
| 547 kFloat_GrSLType, "Radial2FSParams", 6
); | 548 kFloat_GrSLType, "Radial2FSParams", 6
); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 ac4Name.c_str()); | 626 ac4Name.c_str()); |
| 626 | 627 |
| 627 // t is: (-b + params[5] * sqrt(b^2-4ac)) * params[1] | 628 // t is: (-b + params[5] * sqrt(b^2-4ac)) * params[1] |
| 628 t.printf("(-%s + %s * %s) * %s", bVar.c_str(), p5.c_str(), | 629 t.printf("(-%s + %s * %s) * %s", bVar.c_str(), p5.c_str(), |
| 629 rootName.c_str(), p1.c_str()); | 630 rootName.c_str(), p1.c_str()); |
| 630 } else { | 631 } else { |
| 631 // t is: -c/b | 632 // t is: -c/b |
| 632 t.printf("-%s / %s", cName.c_str(), bVar.c_str()); | 633 t.printf("-%s / %s", cName.c_str(), bVar.c_str()); |
| 633 } | 634 } |
| 634 | 635 |
| 635 this->emitColorLookup(builder, t.c_str(), outputColor, inputColor, sampl
ers[0]); | 636 this->emitColor(builder, t.c_str(), key, outputColor, inputColor, sample
rs); |
| 636 } | 637 } |
| 637 } | 638 } |
| 638 | 639 |
| 639 void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman, | 640 void GrGLRadial2Gradient::setData(const GrGLUniformManager& uman, |
| 640 const GrDrawEffect& drawEffect) { | 641 const GrDrawEffect& drawEffect) { |
| 641 INHERITED::setData(uman, drawEffect); | 642 INHERITED::setData(uman, drawEffect); |
| 642 const GrRadial2Gradient& data = drawEffect.castEffect<GrRadial2Gradient>(); | 643 const GrRadial2Gradient& data = drawEffect.castEffect<GrRadial2Gradient>(); |
| 643 SkASSERT(data.isDegenerate() == fIsDegenerate); | 644 SkASSERT(data.isDegenerate() == fIsDegenerate); |
| 644 SkScalar centerX1 = data.center(); | 645 SkScalar centerX1 = data.center(); |
| 645 SkScalar radius0 = data.radius(); | 646 SkScalar radius0 = data.radius(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 667 uman.set1fv(fFSParamUni, 0, 6, values); | 668 uman.set1fv(fFSParamUni, 0, 6, values); |
| 668 fCachedCenter = centerX1; | 669 fCachedCenter = centerX1; |
| 669 fCachedRadius = radius0; | 670 fCachedRadius = radius0; |
| 670 fCachedPosRoot = data.isPosRoot(); | 671 fCachedPosRoot = data.isPosRoot(); |
| 671 } | 672 } |
| 672 } | 673 } |
| 673 | 674 |
| 674 GrGLEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrDrawEffect& drawEffect
, | 675 GrGLEffect::EffectKey GrGLRadial2Gradient::GenKey(const GrDrawEffect& drawEffect
, |
| 675 const GrGLCaps&) { | 676 const GrGLCaps&) { |
| 676 enum { | 677 enum { |
| 677 kIsDegenerate = 1 << kMatrixKeyBitCnt, | 678 kIsDegenerate = 1 << kBaseKeyBitCnt, |
| 678 }; | 679 }; |
| 679 | 680 |
| 680 EffectKey key = GenMatrixKey(drawEffect); | 681 EffectKey key = GenBaseGradientKey(drawEffect); |
| 681 if (drawEffect.castEffect<GrRadial2Gradient>().isDegenerate()) { | 682 if (drawEffect.castEffect<GrRadial2Gradient>().isDegenerate()) { |
| 682 key |= kIsDegenerate; | 683 key |= kIsDegenerate; |
| 683 } | 684 } |
| 684 return key; | 685 return key; |
| 685 } | 686 } |
| 686 | 687 |
| 687 ///////////////////////////////////////////////////////////////////// | 688 ///////////////////////////////////////////////////////////////////// |
| 688 | 689 |
| 689 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkP
aint&) const { | 690 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkP
aint&) const { |
| 690 SkASSERT(NULL != context); | 691 SkASSERT(NULL != context); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 708 } | 709 } |
| 709 | 710 |
| 710 #else | 711 #else |
| 711 | 712 |
| 712 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext*, const SkPaint&) c
onst { | 713 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext*, const SkPaint&) c
onst { |
| 713 SkDEBUGFAIL("Should not call in GPU-less build"); | 714 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 714 return NULL; | 715 return NULL; |
| 715 } | 716 } |
| 716 | 717 |
| 717 #endif | 718 #endif |
| OLD | NEW |