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 SkLinearGradient_DEFINED
9 #define SkLinearGradient_DEFINED
10 
11 #include "SkGradientShaderPriv.h"
12 
13 class SkLinearGradient : public SkGradientShaderBase {
14 public:
15     SkLinearGradient(const SkPoint pts[2], const Descriptor&);
16 
17     GradientType asAGradient(GradientInfo* info) const override;
18 #if SK_SUPPORT_GPU
19     std::unique_ptr<GrFragmentProcessor> asFragmentProcessor(const GrFPArgs&) const override;
20 #endif
21 
22 protected:
23     SkLinearGradient(SkReadBuffer& buffer);
24     void flatten(SkWriteBuffer& buffer) const override;
25 #ifdef SK_ENABLE_LEGACY_SHADERCONTEXT
26     Context* onMakeContext(const ContextRec&, SkArenaAlloc*) const override;
27     Context* onMakeBurstPipelineContext(const ContextRec&, SkArenaAlloc*) const override;
28 #endif
29 
30     void appendGradientStages(SkArenaAlloc* alloc, SkRasterPipeline* tPipeline,
31                               SkRasterPipeline* postPipeline) const final;
32 
33 
34     sk_sp<SkShader> onMakeColorSpace(SkColorSpaceXformer* xformer) const override;
35 
36 private:
37     SK_FLATTENABLE_HOOKS(SkLinearGradient)
38 
39     class LinearGradient4fContext;
40 
41     friend class SkGradientShader;
42     typedef SkGradientShaderBase INHERITED;
43     const SkPoint fStart;
44     const SkPoint fEnd;
45 };
46 
47 #endif
48