1 | // Copyright 2013 The Flutter Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. |
4 | |
5 | #ifndef FLUTTER_LIB_UI_PAINTING_GRADIENT_H_ |
6 | #define FLUTTER_LIB_UI_PAINTING_GRADIENT_H_ |
7 | |
8 | #include "flutter/lib/ui/dart_wrapper.h" |
9 | #include "flutter/lib/ui/painting/matrix.h" |
10 | #include "flutter/lib/ui/painting/shader.h" |
11 | #include "third_party/skia/include/effects/SkGradientShader.h" |
12 | #include "third_party/tonic/typed_data/typed_list.h" |
13 | |
14 | namespace tonic { |
15 | class DartLibraryNatives; |
16 | } // namespace tonic |
17 | |
18 | namespace flutter { |
19 | |
20 | // TODO: update this if/when Skia adds Decal mode skbug.com/7638 |
21 | static_assert(kSkTileModeCount >= 3, "Need to update tile mode enum" ); |
22 | |
23 | class CanvasGradient : public Shader { |
24 | DEFINE_WRAPPERTYPEINFO(); |
25 | FML_FRIEND_MAKE_REF_COUNTED(CanvasGradient); |
26 | |
27 | public: |
28 | ~CanvasGradient() override; |
29 | static fml::RefPtr<CanvasGradient> Create(); |
30 | |
31 | void initLinear(const tonic::Float32List& end_points, |
32 | const tonic::Int32List& colors, |
33 | const tonic::Float32List& color_stops, |
34 | SkTileMode tile_mode, |
35 | const tonic::Float64List& matrix4); |
36 | |
37 | void initRadial(double center_x, |
38 | double center_y, |
39 | double radius, |
40 | const tonic::Int32List& colors, |
41 | const tonic::Float32List& color_stops, |
42 | SkTileMode tile_mode, |
43 | const tonic::Float64List& matrix4); |
44 | |
45 | void initSweep(double center_x, |
46 | double center_y, |
47 | const tonic::Int32List& colors, |
48 | const tonic::Float32List& color_stops, |
49 | SkTileMode tile_mode, |
50 | double start_angle, |
51 | double end_angle, |
52 | const tonic::Float64List& matrix4); |
53 | |
54 | void initTwoPointConical(double start_x, |
55 | double start_y, |
56 | double start_radius, |
57 | double end_x, |
58 | double end_y, |
59 | double end_radius, |
60 | const tonic::Int32List& colors, |
61 | const tonic::Float32List& color_stops, |
62 | SkTileMode tile_mode, |
63 | const tonic::Float64List& matrix4); |
64 | |
65 | static void RegisterNatives(tonic::DartLibraryNatives* natives); |
66 | |
67 | private: |
68 | CanvasGradient(); |
69 | }; |
70 | |
71 | } // namespace flutter |
72 | |
73 | #endif // FLUTTER_LIB_UI_PAINTING_GRADIENT_H_ |
74 | |