OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2014 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 7 |
| 8 #ifndef SkTwoPointConicalGradient_gpu_DEFINED |
| 9 #define SkTwoPointconicalGradient_gpu_DEFINED |
| 10 |
| 11 #if SK_SUPPORT_GPU |
| 12 |
| 13 #include "SkGradientShaderPriv.h" |
| 14 |
| 15 class GrEffectRef; |
| 16 class SkTwoPointConicalGradient; |
| 17 class GrGL2PtConicalGradientEffect; |
| 18 |
| 19 class Gr2PtConicalGradientEffect : public GrGradientEffect { |
| 20 public: |
| 21 |
| 22 static GrEffectRef* Create(GrContext* ctx, |
| 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 |
| 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 |