2 * Copyright 2018 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
8 #ifndef GrGradientShader_DEFINE
9 #define GrGradientShader_DEFINE
11 #include "src/gpu/ganesh/GrFPArgs.h"
12 #include "src/gpu/ganesh/GrFragmentProcessor.h"
13 #include "src/shaders/gradients/SkGradientShaderPriv.h"
14 #include "src/shaders/gradients/SkLinearGradient.h"
15 #include "src/shaders/gradients/SkRadialGradient.h"
16 #include "src/shaders/gradients/SkSweepGradient.h"
17 #include "src/shaders/gradients/SkTwoPointConicalGradient.h"
20 #include "include/utils/SkRandom.h"
23 namespace GrGradientShader {
24 std::unique_ptr<GrFragmentProcessor> MakeLinear(const SkLinearGradient& shader,
25 const GrFPArgs& args);
27 std::unique_ptr<GrFragmentProcessor> MakeRadial(const SkRadialGradient& shader,
28 const GrFPArgs& args);
30 std::unique_ptr<GrFragmentProcessor> MakeSweep(const SkSweepGradient& shader,
31 const GrFPArgs& args);
33 std::unique_ptr<GrFragmentProcessor> MakeConical(const SkTwoPointConicalGradient& shader,
34 const GrFPArgs& args);
37 /** Helper struct that stores (and populates) parameters to construct a random gradient.
38 If fUseColors4f is true, then the SkColor4f factory should be called, with fColors4f and
39 fColorSpace. Otherwise, the SkColor factory should be called, with fColors. fColorCount
40 will be the number of color stops in either case, and fColors and fStops can be passed to
41 the gradient factory. (The constructor may decide not to use stops, in which case fStops
44 inline static constexpr int kMaxRandomGradientColors = 5;
46 // Should be of similar magnitude to the draw area of the tests so that the gradient
47 // sampling is done at an appropriate scale.
48 inline static constexpr SkScalar kGradientScale = 256.0f;
50 RandomParams(SkRandom* r);
53 SkColor fColors[kMaxRandomGradientColors];
54 SkColor4f fColors4f[kMaxRandomGradientColors];
55 sk_sp<SkColorSpace> fColorSpace;
56 SkScalar fStopStorage[kMaxRandomGradientColors];
63 } // namespace GrGradientShader
65 #endif // GrGradientShader_DEFINE