| 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 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 SkScalar* stops = stopsArray; | 534 SkScalar* stops = stopsArray; |
| 535 SkShader::TileMode tm; | 535 SkShader::TileMode tm; |
| 536 int colorCount = RandomGradientParams(random, colors, &stops, &tm); | 536 int colorCount = RandomGradientParams(random, colors, &stops, &tm); |
| 537 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointRadial(center1
, radius1, | 537 SkAutoTUnref<SkShader> shader(SkGradientShader::CreateTwoPointRadial(center1
, radius1, |
| 538 center2
, radius2, | 538 center2
, radius2, |
| 539 colors,
stops, colorCount, | 539 colors,
stops, colorCount, |
| 540 tm)); | 540 tm)); |
| 541 SkPaint paint; | 541 SkPaint paint; |
| 542 GrFragmentProcessor* fp; | 542 GrFragmentProcessor* fp; |
| 543 GrColor paintColor; | 543 GrColor paintColor; |
| 544 SkAssertResult(shader->asFragmentProcessor(context, paint, NULL, &paintColor
, &fp)); | 544 SkAssertResult(shader->asFragmentProcessor(context, paint, |
| 545 GrProcessorUnitTest::TestMatrix(r
andom), NULL, |
| 546 &paintColor, &fp)); |
| 545 return fp; | 547 return fp; |
| 546 } | 548 } |
| 547 | 549 |
| 548 ///////////////////////////////////////////////////////////////////// | 550 ///////////////////////////////////////////////////////////////////// |
| 549 | 551 |
| 550 GrGLRadial2Gradient::GrGLRadial2Gradient(const GrProcessor& processor) | 552 GrGLRadial2Gradient::GrGLRadial2Gradient(const GrProcessor& processor) |
| 551 : fVSVaryingName(NULL) | 553 : fVSVaryingName(NULL) |
| 552 , fFSVaryingName(NULL) | 554 , fFSVaryingName(NULL) |
| 553 , fCachedCenter(SK_ScalarMax) | 555 , fCachedCenter(SK_ScalarMax) |
| 554 , fCachedRadius(-SK_ScalarMax) | 556 , fCachedRadius(-SK_ScalarMax) |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 void GrGLRadial2Gradient::GenKey(const GrProcessor& processor, | 671 void GrGLRadial2Gradient::GenKey(const GrProcessor& processor, |
| 670 const GrGLCaps&, GrProcessorKeyBuilder* b) { | 672 const GrGLCaps&, GrProcessorKeyBuilder* b) { |
| 671 uint32_t* key = b->add32n(2); | 673 uint32_t* key = b->add32n(2); |
| 672 key[0] = GenBaseGradientKey(processor); | 674 key[0] = GenBaseGradientKey(processor); |
| 673 key[1] = processor.cast<GrRadial2Gradient>().isDegenerate(); | 675 key[1] = processor.cast<GrRadial2Gradient>().isDegenerate(); |
| 674 } | 676 } |
| 675 | 677 |
| 676 ///////////////////////////////////////////////////////////////////// | 678 ///////////////////////////////////////////////////////////////////// |
| 677 | 679 |
| 678 bool SkTwoPointRadialGradient::asFragmentProcessor(GrContext* context, const SkP
aint& paint, | 680 bool SkTwoPointRadialGradient::asFragmentProcessor(GrContext* context, const SkP
aint& paint, |
| 681 const SkMatrix&, |
| 679 const SkMatrix* localMatrix,
GrColor* paintColor, | 682 const SkMatrix* localMatrix,
GrColor* paintColor, |
| 680 GrFragmentProcessor** fp) co
nst { | 683 GrFragmentProcessor** fp) co
nst { |
| 681 SkASSERT(context); | 684 SkASSERT(context); |
| 682 | 685 |
| 683 // invert the localM, translate to center1 (fPtsToUni), rotate so center2 is
on x axis. | 686 // invert the localM, translate to center1 (fPtsToUni), rotate so center2 is
on x axis. |
| 684 SkMatrix matrix; | 687 SkMatrix matrix; |
| 685 if (!this->getLocalMatrix().invert(&matrix)) { | 688 if (!this->getLocalMatrix().invert(&matrix)) { |
| 686 return false; | 689 return false; |
| 687 } | 690 } |
| 688 if (localMatrix) { | 691 if (localMatrix) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 704 } | 707 } |
| 705 | 708 |
| 706 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); | 709 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); |
| 707 *fp = GrRadial2Gradient::Create(context, *this, matrix, fTileMode); | 710 *fp = GrRadial2Gradient::Create(context, *this, matrix, fTileMode); |
| 708 | 711 |
| 709 return true; | 712 return true; |
| 710 } | 713 } |
| 711 | 714 |
| 712 #else | 715 #else |
| 713 | 716 |
| 714 bool SkTwoPointRadialGradient::asFragmentProcessor(GrContext*, const SkPaint&, c
onst SkMatrix*, | 717 bool SkTwoPointRadialGradient::asFragmentProcessor(GrContext*, const SkPaint&, c
onst SkMatrix&, |
| 718 const SkMatrix*, |
| 715 GrColor*, GrFragmentProcessor
**) const { | 719 GrColor*, GrFragmentProcessor
**) const { |
| 716 SkDEBUGFAIL("Should not call in GPU-less build"); | 720 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 717 return false; | 721 return false; |
| 718 } | 722 } |
| 719 | 723 |
| 720 #endif | 724 #endif |
| OLD | NEW |