Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
GrGradientShader.h
Go to the documentation of this file.
1/*
2 * Copyright 2018 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 GrGradientShader_DEFINE
9#define GrGradientShader_DEFINE
10
15
16#if defined(GR_TEST_UTILS)
17#include "src/base/SkRandom.h"
18#endif
19
20namespace GrGradientShader {
21std::unique_ptr<GrFragmentProcessor> MakeGradientFP(const SkGradientBaseShader& shader,
22 const GrFPArgs& args,
24 std::unique_ptr<GrFragmentProcessor> layout,
25 const SkMatrix* overrideMatrix = nullptr);
26
27std::unique_ptr<GrFragmentProcessor> MakeLinear(const SkLinearGradient& shader,
28 const GrFPArgs& args,
30
31#if defined(GR_TEST_UTILS)
32 /** Helper struct that stores (and populates) parameters to construct a random gradient.
33 If fUseColors4f is true, then the SkColor4f factory should be called, with fColors4f and
34 fColorSpace. Otherwise, the SkColor factory should be called, with fColors. fColorCount
35 will be the number of color stops in either case, and fColors and fStops can be passed to
36 the gradient factory. (The constructor may decide not to use stops, in which case fStops
37 will be nullptr). */
38 struct RandomParams {
39 inline static constexpr int kMaxRandomGradientColors = 5;
40
41 // Should be of similar magnitude to the draw area of the tests so that the gradient
42 // sampling is done at an appropriate scale.
43 inline static constexpr SkScalar kGradientScale = 256.0f;
44
45 RandomParams(SkRandom* r);
46
47 bool fUseColors4f;
48 SkColor fColors[kMaxRandomGradientColors];
49 SkColor4f fColors4f[kMaxRandomGradientColors];
50 sk_sp<SkColorSpace> fColorSpace;
51 SkScalar fStopStorage[kMaxRandomGradientColors];
52 SkTileMode fTileMode;
53 int fColorCount;
54 SkScalar* fStops;
55 };
56#endif
57
58} // namespace GrGradientShader
59
60#endif // GrGradientShader_DEFINE
uint32_t SkColor
Definition SkColor.h:37
SkTileMode
Definition SkTileMode.h:13
static sk_sp< SkShader > MakeLinear()
float SkScalar
Definition extension.cpp:12
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
std::unique_ptr< GrFragmentProcessor > MakeGradientFP(const SkGradientBaseShader &shader, const GrFPArgs &args, const SkShaders::MatrixRec &mRec, std::unique_ptr< GrFragmentProcessor > layout, const SkMatrix *overrideMatrix)