| Flutter Impeller |

sweep_gradient_contents.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_ENTITY_CONTENTS_SWEEP_GRADIENT_CONTENTS_H_
6 #define FLUTTER_IMPELLER_ENTITY_CONTENTS_SWEEP_GRADIENT_CONTENTS_H_
7
8 #include <vector>
9
10 #include "impeller/entity/contents/color_source_contents.h"
11 #include "impeller/entity/entity.h"
12 #include "impeller/geometry/color.h"
13 #include "impeller/geometry/point.h"
14 #include "impeller/geometry/scalar.h"
15
16 namespace impeller {
17
18 class SweepGradientContents final : public ColorSourceContents {
19 public:
20 SweepGradientContents();
21
22 ~SweepGradientContents() override;
23
24 // |Contents|
25 bool IsOpaque(const Matrix& transform) const override;
26
27 // |Contents|
28 bool Render(const ContentContext& renderer,
29 const Entity& entity,
30 RenderPass& pass) const override;
31
32 // |Contents|
33 [[nodiscard]] bool ApplyColorFilter(
34 const ColorFilterProc& color_filter_proc) override;
35
36 void SetCenterAndAngles(Point center, Degrees start_angle, Degrees end_angle);
37
38 void SetColors(std::vector<Color> colors);
39
40 void SetStops(std::vector<Scalar> stops);
41
42 void SetTileMode(Entity::TileMode tile_mode);
43
44 const std::vector<Color>& GetColors() const;
45
46 const std::vector<Scalar>& GetStops() const;
47
48 private:
49 bool RenderTexture(const ContentContext& renderer,
50 const Entity& entity,
51 RenderPass& pass) const;
52
53 bool RenderSSBO(const ContentContext& renderer,
54 const Entity& entity,
55 RenderPass& pass) const;
56
57 bool RenderUniform(const ContentContext& renderer,
58 const Entity& entity,
59 RenderPass& pass) const;
60
61 Point center_;
62 Scalar bias_;
63 Scalar scale_;
64 std::vector<Color> colors_;
65 std::vector<Scalar> stops_;
66 Entity::TileMode tile_mode_;
67 Color decal_border_color_ = Color::BlackTransparent();
68
69 SweepGradientContents(const SweepGradientContents&) = delete;
70
71 SweepGradientContents& operator=(const SweepGradientContents&) = delete;
72 };
73
74 } // namespace impeller
75
76 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_SWEEP_GRADIENT_CONTENTS_H_
impeller::ColorSourceContents
Definition: color_source_contents.h:38
impeller::ContentContext
Definition: content_context.h:138
impeller::Contents::ColorFilterProc
std::function< Color(Color)> ColorFilterProc
Definition: contents.h:35
impeller::Entity
Definition: entity.h:26
impeller::Entity::TileMode
TileMode
Definition: entity.h:48
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
impeller::SweepGradientContents
Definition: sweep_gradient_contents.h:18
impeller::SweepGradientContents::SetTileMode
void SetTileMode(Entity::TileMode tile_mode)
Definition: sweep_gradient_contents.cc:40
impeller::SweepGradientContents::SweepGradientContents
SweepGradientContents()
impeller::SweepGradientContents::SetCenterAndAngles
void SetCenterAndAngles(Point center, Degrees start_angle, Degrees end_angle)
Definition: sweep_gradient_contents.cc:21
impeller::SweepGradientContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: sweep_gradient_contents.cc:72
impeller::SweepGradientContents::ApplyColorFilter
bool ApplyColorFilter(const ColorFilterProc &color_filter_proc) override
If possible, applies a color filter to this contents inputs on the CPU.
Definition: sweep_gradient_contents.cc:226
impeller::SweepGradientContents::IsOpaque
bool IsOpaque(const Matrix &transform) const override
Whether this Contents only emits opaque source colors from the fragment stage. This value does not ac...
Definition: sweep_gradient_contents.cc:52
impeller::SweepGradientContents::GetColors
const std::vector< Color > & GetColors() const
Definition: sweep_gradient_contents.cc:44
impeller::SweepGradientContents::GetStops
const std::vector< Scalar > & GetStops() const
Definition: sweep_gradient_contents.cc:48
impeller::SweepGradientContents::~SweepGradientContents
~SweepGradientContents() override
impeller::SweepGradientContents::SetStops
void SetStops(std::vector< Scalar > stops)
Definition: sweep_gradient_contents.cc:36
impeller::SweepGradientContents::SetColors
void SetColors(std::vector< Color > colors)
Definition: sweep_gradient_contents.cc:32
color.h
color_source_contents.h
entity.h
transform
Matrix transform
Definition: gaussian_blur_filter_contents.cc:214
impeller
Definition: allocation.cc:12
impeller::Scalar
float Scalar
Definition: scalar.h:19
point.h
scalar.h
impeller::Color
Definition: color.h:124
impeller::Color::BlackTransparent
static constexpr Color BlackTransparent()
Definition: color.h:270
impeller::Degrees
Definition: scalar.h:76
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::TPoint< Scalar >