| 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 str->append(") radius2: "); | 336 str->append(") radius2: "); |
| 337 str->appendScalar(fRadius2); | 337 str->appendScalar(fRadius2); |
| 338 str->append(" "); | 338 str->append(" "); |
| 339 | 339 |
| 340 this->INHERITED::toString(str); | 340 this->INHERITED::toString(str); |
| 341 | 341 |
| 342 str->append(")"); | 342 str->append(")"); |
| 343 } | 343 } |
| 344 #endif | 344 #endif |
| 345 | 345 |
| 346 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 347 SkTwoPointRadialGradient::SkTwoPointRadialGradient(SkReadBuffer& buffer) |
| 348 : INHERITED(buffer), |
| 349 fCenter1(buffer.readPoint()), |
| 350 fCenter2(buffer.readPoint()), |
| 351 fRadius1(buffer.readScalar()), |
| 352 fRadius2(buffer.readScalar()) { |
| 353 init(); |
| 354 }; |
| 355 #endif |
| 356 |
| 346 SkFlattenable* SkTwoPointRadialGradient::CreateProc(SkReadBuffer& buffer) { | 357 SkFlattenable* SkTwoPointRadialGradient::CreateProc(SkReadBuffer& buffer) { |
| 347 DescriptorScope desc; | 358 DescriptorScope desc; |
| 348 if (!desc.unflatten(buffer)) { | 359 if (!desc.unflatten(buffer)) { |
| 349 return NULL; | 360 return NULL; |
| 350 } | 361 } |
| 351 const SkPoint c1 = buffer.readPoint(); | 362 const SkPoint c1 = buffer.readPoint(); |
| 352 const SkPoint c2 = buffer.readPoint(); | 363 const SkPoint c2 = buffer.readPoint(); |
| 353 const SkScalar r1 = buffer.readScalar(); | 364 const SkScalar r1 = buffer.readScalar(); |
| 354 const SkScalar r2 = buffer.readScalar(); | 365 const SkScalar r2 = buffer.readScalar(); |
| 355 return SkGradientShader::CreateTwoPointRadial(c1, r1, c2, r2, desc.fColors,
desc.fPos, | 366 return SkGradientShader::CreateTwoPointRadial(c1, r1, c2, r2, desc.fColors,
desc.fPos, |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 key[0] = GenBaseGradientKey(processor); | 679 key[0] = GenBaseGradientKey(processor); |
| 669 key[1] = processor.cast<GrRadial2Gradient>().isDegenerate(); | 680 key[1] = processor.cast<GrRadial2Gradient>().isDegenerate(); |
| 670 } | 681 } |
| 671 | 682 |
| 672 ///////////////////////////////////////////////////////////////////// | 683 ///////////////////////////////////////////////////////////////////// |
| 673 | 684 |
| 674 bool SkTwoPointRadialGradient::asFragmentProcessor(GrContext* context, const SkP
aint& paint, | 685 bool SkTwoPointRadialGradient::asFragmentProcessor(GrContext* context, const SkP
aint& paint, |
| 675 const SkMatrix* localMatrix,
GrColor* paintColor, | 686 const SkMatrix* localMatrix,
GrColor* paintColor, |
| 676 GrFragmentProcessor** fp) co
nst { | 687 GrFragmentProcessor** fp) co
nst { |
| 677 SkASSERT(context); | 688 SkASSERT(context); |
| 678 | 689 |
| 679 // invert the localM, translate to center1 (fPtsToUni), rotate so center2 is
on x axis. | 690 // invert the localM, translate to center1 (fPtsToUni), rotate so center2 is
on x axis. |
| 680 SkMatrix matrix; | 691 SkMatrix matrix; |
| 681 if (!this->getLocalMatrix().invert(&matrix)) { | 692 if (!this->getLocalMatrix().invert(&matrix)) { |
| 682 return false; | 693 return false; |
| 683 } | 694 } |
| 684 if (localMatrix) { | 695 if (localMatrix) { |
| 685 SkMatrix inv; | 696 SkMatrix inv; |
| 686 if (!localMatrix->invert(&inv)) { | 697 if (!localMatrix->invert(&inv)) { |
| 687 return false; | 698 return false; |
| 688 } | 699 } |
| 689 matrix.postConcat(inv); | 700 matrix.postConcat(inv); |
| 690 } | 701 } |
| 691 matrix.postConcat(fPtsToUnit); | 702 matrix.postConcat(fPtsToUnit); |
| 692 | 703 |
| 693 SkScalar diffLen = fDiff.length(); | 704 SkScalar diffLen = fDiff.length(); |
| 694 if (0 != diffLen) { | 705 if (0 != diffLen) { |
| 695 SkScalar invDiffLen = SkScalarInvert(diffLen); | 706 SkScalar invDiffLen = SkScalarInvert(diffLen); |
| 696 SkMatrix rot; | 707 SkMatrix rot; |
| 697 rot.setSinCos(-SkScalarMul(invDiffLen, fDiff.fY), | 708 rot.setSinCos(-SkScalarMul(invDiffLen, fDiff.fY), |
| 698 SkScalarMul(invDiffLen, fDiff.fX)); | 709 SkScalarMul(invDiffLen, fDiff.fX)); |
| 699 matrix.postConcat(rot); | 710 matrix.postConcat(rot); |
| 700 } | 711 } |
| 701 | 712 |
| 702 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); | 713 *paintColor = SkColor2GrColorJustAlpha(paint.getColor()); |
| 703 *fp = GrRadial2Gradient::Create(context, *this, matrix, fTileMode); | 714 *fp = GrRadial2Gradient::Create(context, *this, matrix, fTileMode); |
| 704 | 715 |
| 705 return true; | 716 return true; |
| 706 } | 717 } |
| 707 | 718 |
| 708 #else | 719 #else |
| 709 | 720 |
| 710 bool SkTwoPointRadialGradient::asFragmentProcessor(GrContext*, const SkPaint&, c
onst SkMatrix*, | 721 bool SkTwoPointRadialGradient::asFragmentProcessor(GrContext*, const SkPaint&, c
onst SkMatrix*, |
| 711 GrColor*, GrFragmentProcessor
**) const { | 722 GrColor*, GrFragmentProcessor
**) const { |
| 712 SkDEBUGFAIL("Should not call in GPU-less build"); | 723 SkDEBUGFAIL("Should not call in GPU-less build"); |
| 713 return false; | 724 return false; |
| 714 } | 725 } |
| 715 | 726 |
| 716 #endif | 727 #endif |
| OLD | NEW |