1 /*
2  * Copyright 2016 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 Sk4fLinearGradient_DEFINED
9 #define Sk4fLinearGradient_DEFINED
10 
11 #include "Sk4fGradientBase.h"
12 #include "SkLinearGradient.h"
13 
14 class SkLinearGradient::
15 LinearGradient4fContext final : public GradientShaderBase4fContext {
16 public:
17     LinearGradient4fContext(const SkLinearGradient&, const ContextRec&);
18 
19     void shadeSpan(int x, int y, SkPMColor dst[], int count) override;
20     void shadeSpan4f(int x, int y, SkPM4f dst[], int count) override;
21 
22 private:
23     using INHERITED = GradientShaderBase4fContext;
24 
25     template<typename dstType, ApplyPremul, TileMode>
26     class LinearIntervalProcessor;
27 
28     template <typename dstType, ApplyPremul premul>
29     void shadePremulSpan(int x, int y, dstType dst[], int count, float bias0, float bias1) const;
30 
31     template <typename dstType, ApplyPremul premul, SkShader::TileMode tileMode>
32     void shadeSpanInternal(int x, int y, dstType dst[], int count, float bias0, float bias1) const;
33 
34     const Sk4fGradientInterval* findInterval(SkScalar fx) const;
35 
36     mutable const Sk4fGradientInterval* fCachedInterval;
37 };
38 
39 #endif // Sk4fLinearGradient_DEFINED
40