Home | History | Annotate | Download | only in gradients
      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 SkColor colors[], const SkScalar pos[],
     19                               int colorCount, SkShader::TileMode mode,
     20                               SkUnitMapper* mapper);
     21 
     22     virtual BitmapType asABitmap(SkBitmap* bitmap,
     23                                  SkMatrix* matrix,
     24                                  TileMode* xy) const SK_OVERRIDE;
     25     virtual GradientType asAGradient(GradientInfo* info) const SK_OVERRIDE;
     26     virtual GrEffectRef* asNewEffect(GrContext* context, const SkPaint&) const SK_OVERRIDE;
     27 
     28     virtual void shadeSpan(int x, int y, SkPMColor* dstCParam,
     29                            int count) SK_OVERRIDE;
     30     virtual bool setContext(const SkBitmap& device,
     31                             const SkPaint& paint,
     32                             const SkMatrix& matrix) SK_OVERRIDE;
     33 
     34     SkScalar getCenterX1() const { return fDiff.length(); }
     35     SkScalar getStartRadius() const { return fStartRadius; }
     36     SkScalar getDiffRadius() const { return fDiffRadius; }
     37 
     38     SK_DEVELOPER_TO_STRING()
     39     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkTwoPointRadialGradient)
     40 
     41 protected:
     42     SkTwoPointRadialGradient(SkFlattenableReadBuffer& buffer);
     43     virtual void flatten(SkFlattenableWriteBuffer& buffer) const SK_OVERRIDE;
     44 
     45 private:
     46     typedef SkGradientShaderBase INHERITED;
     47     const SkPoint fCenter1;
     48     const SkPoint fCenter2;
     49     const SkScalar fRadius1;
     50     const SkScalar fRadius2;
     51     SkPoint fDiff;
     52     SkScalar fStartRadius, fDiffRadius, fSr2D2, fA, fOneOverTwoA;
     53 
     54     void init();
     55 };
     56 
     57 #endif
     58