Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(301)

Side by Side Diff: src/effects/gradients/SkTwoPointRadialGradient.cpp

Issue 278963002: add localmatrix parameter to shader's asNewEffect (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/effects/gradients/SkTwoPointRadialGradient.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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); 533 return shader->asNewEffect(context, paint, NULL);
534 } 534 }
535 535
536 ///////////////////////////////////////////////////////////////////// 536 /////////////////////////////////////////////////////////////////////
537 537
538 GrGLRadial2Gradient::GrGLRadial2Gradient(const GrBackendEffectFactory& factory, 538 GrGLRadial2Gradient::GrGLRadial2Gradient(const GrBackendEffectFactory& factory,
539 const GrDrawEffect& drawEffect) 539 const GrDrawEffect& drawEffect)
540 : INHERITED(factory) 540 : INHERITED(factory)
541 , fVSVaryingName(NULL) 541 , fVSVaryingName(NULL)
542 , fFSVaryingName(NULL) 542 , fFSVaryingName(NULL)
543 , fCachedCenter(SK_ScalarMax) 543 , fCachedCenter(SK_ScalarMax)
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
663 663
664 EffectKey key = GenBaseGradientKey(drawEffect); 664 EffectKey key = GenBaseGradientKey(drawEffect);
665 if (drawEffect.castEffect<GrRadial2Gradient>().isDegenerate()) { 665 if (drawEffect.castEffect<GrRadial2Gradient>().isDegenerate()) {
666 key |= kIsDegenerate; 666 key |= kIsDegenerate;
667 } 667 }
668 return key; 668 return key;
669 } 669 }
670 670
671 ///////////////////////////////////////////////////////////////////// 671 /////////////////////////////////////////////////////////////////////
672 672
673 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkP aint&) const { 673 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext* context, const SkP aint&,
674 const SkMatrix* localMatrix) const {
674 SkASSERT(NULL != context); 675 SkASSERT(NULL != context);
675 // invert the localM, translate to center1 (fPtsToUni), rotate so center2 is on x axis. 676 // invert the localM, translate to center1 (fPtsToUni), rotate so center2 is on x axis.
676 SkMatrix matrix; 677 SkMatrix matrix;
677 if (!this->getLocalMatrix().invert(&matrix)) { 678 if (!this->getLocalMatrix().invert(&matrix)) {
678 return NULL; 679 return NULL;
679 } 680 }
681 if (localMatrix) {
682 SkMatrix inv;
683 if (!localMatrix->invert(&inv)) {
684 return NULL;
685 }
686 matrix.postConcat(inv);
687 }
680 matrix.postConcat(fPtsToUnit); 688 matrix.postConcat(fPtsToUnit);
681 689
682 SkScalar diffLen = fDiff.length(); 690 SkScalar diffLen = fDiff.length();
683 if (0 != diffLen) { 691 if (0 != diffLen) {
684 SkScalar invDiffLen = SkScalarInvert(diffLen); 692 SkScalar invDiffLen = SkScalarInvert(diffLen);
685 SkMatrix rot; 693 SkMatrix rot;
686 rot.setSinCos(-SkScalarMul(invDiffLen, fDiff.fY), 694 rot.setSinCos(-SkScalarMul(invDiffLen, fDiff.fY),
687 SkScalarMul(invDiffLen, fDiff.fX)); 695 SkScalarMul(invDiffLen, fDiff.fX));
688 matrix.postConcat(rot); 696 matrix.postConcat(rot);
689 } 697 }
690 698
691 return GrRadial2Gradient::Create(context, *this, matrix, fTileMode); 699 return GrRadial2Gradient::Create(context, *this, matrix, fTileMode);
692 } 700 }
693 701
694 #else 702 #else
695 703
696 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext*, const SkPaint&) c onst { 704 GrEffectRef* SkTwoPointRadialGradient::asNewEffect(GrContext*, const SkPaint&) c onst {
697 SkDEBUGFAIL("Should not call in GPU-less build"); 705 SkDEBUGFAIL("Should not call in GPU-less build");
698 return NULL; 706 return NULL;
699 } 707 }
700 708
701 #endif 709 #endif
OLDNEW
« no previous file with comments | « src/effects/gradients/SkTwoPointRadialGradient.h ('k') | src/gpu/SkGpuDevice.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698