Chromium Code Reviews| 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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 523 SkColor colors[kMaxRandomGradientColors]; | 523 SkColor colors[kMaxRandomGradientColors]; |
| 524 SkScalar stopsArray[kMaxRandomGradientColors]; | 524 SkScalar stopsArray[kMaxRandomGradientColors]; |
| 525 SkScalar* stops = stopsArray; | 525 SkScalar* stops = stopsArray; |
| 526 SkShader::TileMode tm; | 526 SkShader::TileMode tm; |
| 527 int colorCount = RandomGradientParams(random, colors, &stops, &tm); | 527 int colorCount = RandomGradientParams(random, colors, &stops, &tm); |
| 528 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointRadial(center1 , radius1, | 528 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointRadial(center1 , radius1, |
| 529 center2 , radius2, | 529 center2 , radius2, |
| 530 colors, stops, colorCount, | 530 colors, stops, colorCount, |
| 531 tm)); | 531 tm)); |
| 532 SkPaint paint; | 532 SkPaint paint; |
| 533 return shader->asNewEffect(context, paint, NULL); | 533 GrEffectRef* effect; |
| 534 GrColor grColor; | |
| 535 shader->asNewEffect(context, paint, &grColor, &effect, NULL); | |
| 536 return effect; | |
| 534 } | 537 } |
| 535 | 538 |
| 536 ///////////////////////////////////////////////////////////////////// | 539 ///////////////////////////////////////////////////////////////////// |
| 537 | 540 |
| 538 GrGLRadial2Gradient::GrGLRadial2Gradient(const GrBackendEffectFactory& factory, | 541 GrGLRadial2Gradient::GrGLRadial2Gradient(const GrBackendEffectFactory& factory, |
| 539 const GrDrawEffect& drawEffect) | 542 const GrDrawEffect& drawEffect) |
| 540 : INHERITED(factory) | 543 : INHERITED(factory) |
| 541 , fVSVaryingName(NULL) | 544 , fVSVaryingName(NULL) |
| 542 , fFSVaryingName(NULL) | 545 , fFSVaryingName(NULL) |
| 543 , fCachedCenter(SK_ScalarMax) | 546 , fCachedCenter(SK_ScalarMax) |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 663 | 666 |
| 664 EffectKey key = GenBaseGradientKey(drawEffect); | 667 EffectKey key = GenBaseGradientKey(drawEffect); |
| 665 if (drawEffect.castEffect<GrRadial2Gradient>().isDegenerate()) { | 668 if (drawEffect.castEffect<GrRadial2Gradient>().isDegenerate()) { |
| 666 key |= kIsDegenerate; | 669 key |= kIsDegenerate; |
| 667 } | 670 } |
| 668 return key; | 671 return key; |
| 669 } | 672 } |
| 670 | 673 |
| 671 ///////////////////////////////////////////////////////////////////// | 674 ///////////////////////////////////////////////////////////////////// |
| 672 | 675 |
| 673 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkP aint&, | 676 bool SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkPaint& pa int, |
| 674 const SkMatrix* localMatrix) const { | 677 GrColor* grColor, GrEffectRef** grEff ect, |
| 678 const SkMatrix* localMatrix) const { | |
|
jvanverth1
2014/06/05 17:36:31
grColor never gets set by this method
dandov
2014/06/06 21:50:43
Done.
| |
| 675 SkASSERT(NULL != context); | 679 SkASSERT(NULL != context); |
| 676 // invert the localM, translate to center1 (fPtsToUni), rotate so center2 is on x axis. | 680 // invert the localM, translate to center1 (fPtsToUni), rotate so center2 is on x axis. |
| 677 SkMatrix matrix; | 681 SkMatrix matrix; |
| 678 if (!this->getLocalMatrix().invert(&matrix)) { | 682 if (!this->getLocalMatrix().invert(&matrix)) { |
| 679 return NULL; | 683 return false; |
| 680 } | 684 } |
| 681 if (localMatrix) { | 685 if (localMatrix) { |
| 682 SkMatrix inv; | 686 SkMatrix inv; |
| 683 if (!localMatrix->invert(&inv)) { | 687 if (!localMatrix->invert(&inv)) { |
| 684 return NULL; | 688 return false; |
| 685 } | 689 } |
| 686 matrix.postConcat(inv); | 690 matrix.postConcat(inv); |
| 687 } | 691 } |
| 688 matrix.postConcat(fPtsToUnit); | 692 matrix.postConcat(fPtsToUnit); |
| 689 | 693 |
| 690 SkScalar diffLen = fDiff.length(); | 694 SkScalar diffLen = fDiff.length(); |
| 691 if (0 != diffLen) { | 695 if (0 != diffLen) { |
| 692 SkScalar invDiffLen = SkScalarInvert(diffLen); | 696 SkScalar invDiffLen = SkScalarInvert(diffLen); |
| 693 SkMatrix rot; | 697 SkMatrix rot; |
| 694 rot.setSinCos(-SkScalarMul(invDiffLen, fDiff.fY), | 698 rot.setSinCos(-SkScalarMul(invDiffLen, fDiff.fY), |
| 695 SkScalarMul(invDiffLen, fDiff.fX)); | 699 SkScalarMul(invDiffLen, fDiff.fX)); |
| 696 matrix.postConcat(rot); | 700 matrix.postConcat(rot); |
| 697 } | 701 } |
| 698 | 702 |
| 699 return GrRadial2Gradient::Create(context, *this, matrix, fTileMode); | 703 *grEffect = GrRadial2Gradient::Create(context, *this, matrix, fTileMode); |
| 704 return true; | |
| 700 } | 705 } |
| 701 | 706 |
| 702 #else | 707 #else |
| 703 | 708 |
| 704 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext*, const SkPaint&, | 709 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext*, const SkPaint&, |
| 705 const SkMatrix*) const { | 710 const SkMatrix*) const { |
| 706 SkDEBUGFAIL("Should not call in GPU-less build"); | 711 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 707 return NULL; | 712 return NULL; |
| 708 } | 713 } |
| 709 | 714 |
| 710 #endif | 715 #endif |
| OLD | NEW |