1 2 /* 3 * Copyright 2012 Google Inc. 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9 #ifndef SkTwoPointRadialGradient_DEFINED 10 #define SkTwoPointRadialGradient_DEFINED 11 12 #include "SkGradientShaderPriv.h" 13 14 class SkTwoPointRadialGradient : public SkGradientShaderBase { 15 public: 16 SkTwoPointRadialGradient(const SkPoint& start, SkScalar startRadius, 17 const SkPoint& end, SkScalar endRadius, 18 const Descriptor&); 19 20 virtual BitmapType asABitmap(SkBitmap* bitmap, 21 SkMatrix* matrix, 22 TileMode* xy) const SK_OVERRIDE; 23 virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE; 24 virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint&) const SK_OVERRIDE; 25 26 virtual void shadeSpan(int x, int y, SkPMColor* dstCParam, 27 int count) SK_OVERRIDE; 28 virtual bool setContext(const SkBitmap& device, 29 const SkPaint& paint, 30 const SkMatrix& matrix) SK_OVERRIDE; 31 32 SkScalar getCenterX1() const { return fDiff.length(); } 33 SkScalar getStartRadius() const { return fStartRadius; } 34 SkScalar getDiffRadius() const { return fDiffRadius; } 35 36 SK_DEVELOPER_TO_STRING() 37 SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTwoPointRadialGradient) 38 39 protected: 40 SkTwoPointRadialGradient(SkFlattenableReadBuffer& buffer); 41 virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE; 42 43 private: 44 typedef SkGradientShaderBase INHERITED; 45 const SkPoint fCenter1; 46 const SkPoint fCenter2; 47 const SkScalar fRadius1; 48 const SkScalar fRadius2; 49 SkPoint fDiff; 50 SkScalar fStartRadius, fDiffRadius, fSr2D2, fA, fOneOverTwoA; 51 52 void init(); 53 }; 54 55 #endif 56