• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     sk_sp<SkShader> onMakeColorSpace(SkColorSpaceXformer* xformer) const override;
40 
41     bool adjustMatrixAndAppendStages(SkArenaAlloc* alloc,
42                                      SkMatrix* matrix,
43                                      SkRasterPipeline* tPipeline,
44                                      SkRasterPipeline* postPipeline) const final;
45 
46 private:
47     const SkPoint fCenter;
48     const SkScalar fRadius;
49 
50     friend class SkGradientShader;
51     typedef SkGradientShaderBase INHERITED;
52 };
53 
54 #endif
55