| 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 <functional>
9 #include <memory>
10 #include <vector>
11
12 #include "flutter/fml/macros.h"
13 #include "impeller/entity/contents/color_source_contents.h"
14 #include "impeller/entity/entity.h"
15 #include "impeller/geometry/color.h"
16 #include "impeller/geometry/gradient.h"
17 #include "impeller/geometry/path.h"
18 #include "impeller/geometry/point.h"
19 #include "impeller/geometry/scalar.h"
20
21 namespace impeller {
22
23 class SweepGradientContents final : public ColorSourceContents {
24 public:
25 SweepGradientContents();
26
27 ~SweepGradientContents() override;
28
29 // |Contents|
30 bool IsOpaque() const override;
31
32 // |Contents|
33 bool Render(const ContentContext& renderer,
34 const Entity& entity,
35 RenderPass& pass) const override;
36
37 // |Contents|
38 [[nodiscard]] bool ApplyColorFilter(
39 const ColorFilterProc& color_filter_proc) override;
40
41 void SetCenterAndAngles(Point center, Degrees start_angle, Degrees end_angle);
42
43 void SetColors(std::vector<Color> colors);
44
45 void SetStops(std::vector<Scalar> stops);
46
47 void SetTileMode(Entity::TileMode tile_mode);
48
49 const std::vector<Color>& GetColors() const;
50
51 const std::vector<Scalar>& GetStops() const;
52
53 private:
54 bool RenderTexture(const ContentContext& renderer,
55 const Entity& entity,
56 RenderPass& pass) const;
57
58 bool RenderSSBO(const ContentContext& renderer,
59 const Entity& entity,
60 RenderPass& pass) const;
61
62 Point center_;
63 Scalar bias_;
64 Scalar scale_;
65 std::vector<Color> colors_;
66 std::vector<Scalar> stops_;
67 Entity::TileMode tile_mode_;
68 Color decal_border_color_ = Color::BlackTransparent();
69
70 SweepGradientContents(const SweepGradientContents&) = delete;
71
72 SweepGradientContents& operator=(const SweepGradientContents&) = delete;
73 };
74
75 } // namespace impeller
76
77 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_SWEEP_GRADIENT_CONTENTS_H_
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:195
path.h
impeller::SweepGradientContents::SetTileMode
void SetTileMode(Entity::TileMode tile_mode)
Definition: sweep_gradient_contents.cc:40
point.h
impeller::Scalar
float Scalar
Definition: scalar.h:18
entity.h
impeller::SweepGradientContents::SetColors
void SetColors(std::vector< Color > colors)
Definition: sweep_gradient_contents.cc:32
impeller::SweepGradientContents::SetCenterAndAngles
void SetCenterAndAngles(Point center, Degrees start_angle, Degrees end_angle)
Definition: sweep_gradient_contents.cc:21
impeller::Color
Definition: color.h:124
impeller::SweepGradientContents::~SweepGradientContents
~SweepGradientContents() override
impeller::SweepGradientContents::GetStops
const std::vector< Scalar > & GetStops() const
Definition: sweep_gradient_contents.cc:48
impeller::SweepGradientContents
Definition: sweep_gradient_contents.h:23
gradient.h
impeller::Entity
Definition: entity.h:21
color_source_contents.h
impeller::SweepGradientContents::SetStops
void SetStops(std::vector< Scalar > stops)
Definition: sweep_gradient_contents.cc:36
impeller::Contents::ColorFilterProc
std::function< Color(Color)> ColorFilterProc
Definition: contents.h:38
impeller::SweepGradientContents::SweepGradientContents
SweepGradientContents()
impeller::Entity::TileMode
TileMode
Definition: entity.h:40
impeller::SweepGradientContents::IsOpaque
bool IsOpaque() 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
scalar.h
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:29
impeller::SweepGradientContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: sweep_gradient_contents.cc:64
impeller::TPoint< Scalar >
impeller::Color::BlackTransparent
static constexpr Color BlackTransparent()
Definition: color.h:262
impeller::Degrees
Definition: scalar.h:46
color.h
impeller::SweepGradientContents::GetColors
const std::vector< Color > & GetColors() const
Definition: sweep_gradient_contents.cc:44
impeller::ColorSourceContents
Definition: color_source_contents.h:34
impeller
Definition: aiks_context.cc:10
impeller::ContentContext
Definition: content_context.h:332