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