| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkTwoPointConicalGradient_gpu_DEFINED | 8 #ifndef SkTwoPointConicalGradient_gpu_DEFINED |
| 9 #define SkTwoPointConicalGradient_gpu_DEFINED | 9 #define SkTwoPointConicalGradient_gpu_DEFINED |
| 10 | 10 |
| 11 #if SK_SUPPORT_GPU | |
| 12 | |
| 13 #include "SkGradientShaderPriv.h" | 11 #include "SkGradientShaderPriv.h" |
| 14 | 12 |
| 15 class GrEffectRef; | 13 class GrEffectRef; |
| 16 class SkTwoPointConicalGradient; | 14 class SkTwoPointConicalGradient; |
| 17 class GrGL2PtConicalGradientEffect; | |
| 18 | 15 |
| 19 class Gr2PtConicalGradientEffect : public GrGradientEffect { | 16 namespace Gr2PtConicalGradientEffect { |
| 20 public: | 17 /** |
| 18 * Creates an effect that produces a two point conical gradient based on the |
| 19 * shader passed in. |
| 20 */ |
| 21 GrEffectRef* Create(GrContext* ctx, const SkTwoPointConicalGradient& shader, |
| 22 SkShader::TileMode tm); |
| 23 }; |
| 21 | 24 |
| 22 static GrEffectRef* Create(GrContext* ctx, | 25 #endif |
| 23 const SkTwoPointConicalGradient& shader, | |
| 24 const SkMatrix& matrix, | |
| 25 SkShader::TileMode tm) { | |
| 26 AutoEffectUnref effect(SkNEW_ARGS(Gr2PtConicalGradientEffect, (ctx, shad
er, matrix, tm))); | |
| 27 return CreateEffectRef(effect); | |
| 28 } | |
| 29 | 26 |
| 30 virtual ~Gr2PtConicalGradientEffect() { } | |
| 31 | |
| 32 static const char* Name() { return "Two-Point Conical Gradient"; } | |
| 33 virtual const GrBackendEffectFactory& getFactory() const SK_OVERRIDE; | |
| 34 | |
| 35 // The radial gradient parameters can collapse to a linear (instead of quadr
atic) equation. | |
| 36 bool isDegenerate() const { return SkScalarAbs(fDiffRadius) == SkScalarAbs(f
CenterX1); } | |
| 37 SkScalar center() const { return fCenterX1; } | |
| 38 SkScalar diffRadius() const { return fDiffRadius; } | |
| 39 SkScalar radius() const { return fRadius0; } | |
| 40 | |
| 41 typedef GrGL2PtConicalGradientEffect GLEffect; | |
| 42 | |
| 43 private: | |
| 44 virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE { | |
| 45 const Gr2PtConicalGradientEffect& s = CastEffect<Gr2PtConicalGradientEff
ect>(sBase); | |
| 46 return (INHERITED::onIsEqual(sBase) && | |
| 47 this->fCenterX1 == s.fCenterX1 && | |
| 48 this->fRadius0 == s.fRadius0 && | |
| 49 this->fDiffRadius == s.fDiffRadius); | |
| 50 } | |
| 51 | |
| 52 Gr2PtConicalGradientEffect(GrContext* ctx, | |
| 53 const SkTwoPointConicalGradient& shader, | |
| 54 const SkMatrix& matrix, | |
| 55 SkShader::TileMode tm); | |
| 56 | |
| 57 GR_DECLARE_EFFECT_TEST; | |
| 58 | |
| 59 // @{ | |
| 60 // Cache of values - these can change arbitrarily, EXCEPT | |
| 61 // we shouldn't change between degenerate and non-degenerate?! | |
| 62 | |
| 63 GrCoordTransform fBTransform; | |
| 64 SkScalar fCenterX1; | |
| 65 SkScalar fRadius0; | |
| 66 SkScalar fDiffRadius; | |
| 67 | |
| 68 // @} | |
| 69 | |
| 70 typedef GrGradientEffect INHERITED; | |
| 71 }; | |
| 72 #endif | |
| 73 #endif | |
| OLD | NEW |