| Flutter Impeller |

color_source.h
Go to the documentation of this file.
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_IMPELLER_TOOLKIT_INTEROP_COLOR_SOURCE_H_
6 #define FLUTTER_IMPELLER_TOOLKIT_INTEROP_COLOR_SOURCE_H_
7
8 #include <vector>
9
10 #include "flutter/display_list/effects/dl_color_source.h"
11 #include "impeller/geometry/color.h"
12 #include "impeller/geometry/matrix.h"
13 #include "impeller/geometry/point.h"
14 #include "impeller/toolkit/interop/formats.h"
15 #include "impeller/toolkit/interop/fragment_program.h"
16 #include "impeller/toolkit/interop/impeller.h"
17 #include "impeller/toolkit/interop/object.h"
18 #include "impeller/toolkit/interop/texture.h"
19
20 namespace impeller::interop {
21
22 class ColorSource final
23 : public Object<ColorSource,
24 IMPELLER_INTERNAL_HANDLE_NAME(ImpellerColorSource)> {
25 public:
26 static ScopedObject<ColorSource> MakeLinearGradient(
27 const Point& start_point,
28 const Point& end_point,
29 const std::vector<flutter::DlColor>& colors,
30 const std::vector<Scalar>& stops,
31 flutter::DlTileMode tile_mode,
32 const Matrix& transformation);
33
34 static ScopedObject<ColorSource> MakeRadialGradient(
35 const Point& center,
36 Scalar radius,
37 const std::vector<flutter::DlColor>& colors,
38 const std::vector<Scalar>& stops,
39 flutter::DlTileMode tile_mode,
40 const Matrix& transformation);
41
42 static ScopedObject<ColorSource> MakeConicalGradient(
43 const Point& start_center,
44 Scalar start_radius,
45 const Point& end_center,
46 Scalar end_radius,
47 const std::vector<flutter::DlColor>& colors,
48 const std::vector<Scalar>& stops,
49 flutter::DlTileMode tile_mode,
50 const Matrix& transformation);
51
52 static ScopedObject<ColorSource> MakeSweepGradient(
53 const Point& center,
54 Scalar start,
55 Scalar end,
56 const std::vector<flutter::DlColor>& colors,
57 const std::vector<Scalar>& stops,
58 flutter::DlTileMode tile_mode,
59 const Matrix& transformation);
60
61 static ScopedObject<ColorSource> MakeImage(
62 const Texture& image,
63 flutter::DlTileMode horizontal_tile_mode,
64 flutter::DlTileMode vertical_tile_mode,
65 flutter::DlImageSampling sampling,
66 const Matrix& transformation);
67
68 static ScopedObject<ColorSource> MakeFragmentProgram(
69 const Context& context,
70 const FragmentProgram& program,
71 std::vector<std::shared_ptr<flutter::DlColorSource>> samplers,
72 std::shared_ptr<std::vector<uint8_t>> uniform_data);
73
74 explicit ColorSource(std::shared_ptr<flutter::DlColorSource> source);
75
76 ~ColorSource() override;
77
78 ColorSource(const ColorSource&) = delete;
79
80 ColorSource& operator=(const ColorSource&) = delete;
81
82 bool IsValid() const;
83
84 const std::shared_ptr<flutter::DlColorSource>& GetColorSource() const;
85
86 private:
87 std::shared_ptr<flutter::DlColorSource> color_source_;
88 };
89
90 } // namespace impeller::interop
91
92 #endif // FLUTTER_IMPELLER_TOOLKIT_INTEROP_COLOR_SOURCE_H_
impeller::interop::ColorSource
Definition: color_source.h:24
impeller::interop::ColorSource::~ColorSource
~ColorSource() override
impeller::interop::ColorSource::MakeSweepGradient
static ScopedObject< ColorSource > MakeSweepGradient(const Point &center, Scalar start, Scalar end, const std::vector< flutter::DlColor > &colors, const std::vector< Scalar > &stops, flutter::DlTileMode tile_mode, const Matrix &transformation)
Definition: color_source.cc:78
impeller::interop::ColorSource::GetColorSource
const std::shared_ptr< flutter::DlColorSource > & GetColorSource() const
Definition: color_source.cc:155
impeller::interop::ColorSource::ColorSource
ColorSource(std::shared_ptr< flutter::DlColorSource > source)
Definition: color_source.cc:146
impeller::interop::ColorSource::operator=
ColorSource & operator=(const ColorSource &)=delete
impeller::interop::ColorSource::MakeFragmentProgram
static ScopedObject< ColorSource > MakeFragmentProgram(const Context &context, const FragmentProgram &program, std::vector< std::shared_ptr< flutter::DlColorSource >> samplers, std::shared_ptr< std::vector< uint8_t >> uniform_data)
Definition: color_source.cc:116
impeller::interop::ColorSource::MakeImage
static ScopedObject< ColorSource > MakeImage(const Texture &image, flutter::DlTileMode horizontal_tile_mode, flutter::DlTileMode vertical_tile_mode, flutter::DlImageSampling sampling, const Matrix &transformation)
Definition: color_source.cc:101
impeller::interop::ColorSource::ColorSource
ColorSource(const ColorSource &)=delete
impeller::interop::ColorSource::IsValid
bool IsValid() const
Definition: color_source.cc:151
impeller::interop::ColorSource::MakeRadialGradient
static ScopedObject< ColorSource > MakeRadialGradient(const Point &center, Scalar radius, const std::vector< flutter::DlColor > &colors, const std::vector< Scalar > &stops, flutter::DlTileMode tile_mode, const Matrix &transformation)
Definition: color_source.cc:32
impeller::interop::ColorSource::MakeLinearGradient
static ScopedObject< ColorSource > MakeLinearGradient(const Point &start_point, const Point &end_point, const std::vector< flutter::DlColor > &colors, const std::vector< Scalar > &stops, flutter::DlTileMode tile_mode, const Matrix &transformation)
Definition: color_source.cc:11
impeller::interop::ColorSource::MakeConicalGradient
static ScopedObject< ColorSource > MakeConicalGradient(const Point &start_center, Scalar start_radius, const Point &end_center, Scalar end_radius, const std::vector< flutter::DlColor > &colors, const std::vector< Scalar > &stops, flutter::DlTileMode tile_mode, const Matrix &transformation)
Definition: color_source.cc:53
impeller::interop::Context
Definition: context.h:16
impeller::interop::FragmentProgram
Definition: fragment_program.h:17
impeller::interop::Object
Definition: object.h:56
impeller::interop::ScopedObject
Definition: object.h:67
impeller::interop::Texture
Definition: texture.h:17
color.h
fragment_program.h
impeller.h
matrix.h
impeller::interop
Definition: context_gles.cc:12
impeller::Scalar
float Scalar
Definition: scalar.h:19
object.h
point.h
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::TPoint< Scalar >
start
const size_t start
Definition: tessellator_libtess.cc:62
end
const size_t end
Definition: tessellator_libtess.cc:63
formats.h
texture.h