1 /*
2  * Copyright 2012 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 SkRadialGradient_DEFINED
9 #define SkRadialGradient_DEFINED
10 
11 #include "SkGradientShaderPriv.h"
12 
13 class SkRadialGradient : public SkGradientShaderBase {
14 public:
15     SkRadialGradient(const SkPoint& center, SkScalar radius, const Descriptor&);
16 
17     class RadialGradientContext : public SkGradientShaderBase::GradientShaderBaseContext {
18     public:
19         RadialGradientContext(const SkRadialGradient&, const ContextRec&);
20 
21         void shadeSpan(int x, int y, SkPMColor dstC[], int count) override;
22 
23     private:
24         typedef SkGradientShaderBase::GradientShaderBaseContext INHERITED;
25     };
26 
27     GradientType asAGradient(GradientInfo* info) const override;
28 #if SK_SUPPORT_GPU
29     sk_sp<GrFragmentProcessor> asFragmentProcessor(const AsFPArgs&) const override;
30 #endif
31 
32     SK_TO_STRING_OVERRIDE()
33     SK_DECLARE_PUBLIC_FLATTENABLE_DESERIALIZATION_PROCS(SkRadialGradient)
34 
35 protected:
36     SkRadialGradient(SkReadBuffer& buffer);
37     void flatten(SkWriteBuffer& buffer) const override;
38     Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override;
39 
40 private:
41     const SkPoint fCenter;
42     const SkScalar fRadius;
43 
44     friend class SkGradientShader;
45     typedef SkGradientShaderBase INHERITED;
46 };
47 
48 #endif
49