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