| Flutter Impeller |

linear_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_LINEAR_GRADIENT_CONTENTS_H_
6 #define FLUTTER_IMPELLER_ENTITY_CONTENTS_LINEAR_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
15 namespace impeller {
16
17 class LinearGradientContents final : public ColorSourceContents {
18 public:
19 LinearGradientContents();
20
21 ~LinearGradientContents() override;
22
23 // |Contents|
24 bool IsOpaque(const Matrix& transform) const override;
25
26 // |Contents|
27 bool Render(const ContentContext& renderer,
28 const Entity& entity,
29 RenderPass& pass) const override;
30
31 // |Contents|
32 [[nodiscard]] bool ApplyColorFilter(
33 const ColorFilterProc& color_filter_proc) override;
34
35 void SetEndPoints(Point start_point, Point end_point);
36
37 void SetColors(std::vector<Color> colors);
38
39 void SetStops(std::vector<Scalar> stops);
40
41 const std::vector<Color>& GetColors() const;
42
43 const std::vector<Scalar>& GetStops() const;
44
45 void SetTileMode(Entity::TileMode tile_mode);
46
47 private:
48 bool RenderTexture(const ContentContext& renderer,
49 const Entity& entity,
50 RenderPass& pass) const;
51
52 bool RenderSSBO(const ContentContext& renderer,
53 const Entity& entity,
54 RenderPass& pass) const;
55
56 bool RenderUniform(const ContentContext& renderer,
57 const Entity& entity,
58 RenderPass& pass) const;
59
60 bool FastLinearGradient(const ContentContext& renderer,
61 const Entity& entity,
62 RenderPass& pass) const;
63
64 bool CanApplyFastGradient() const;
65
66 Point start_point_;
67 Point end_point_;
68 std::vector<Color> colors_;
69 std::vector<Scalar> stops_;
70 Entity::TileMode tile_mode_;
71 Color decal_border_color_ = Color::BlackTransparent();
72
73 LinearGradientContents(const LinearGradientContents&) = delete;
74
75 LinearGradientContents& operator=(const LinearGradientContents&) = delete;
76 };
77
78 } // namespace impeller
79
80 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_LINEAR_GRADIENT_CONTENTS_H_
impeller::ColorSourceContents
Definition: color_source_contents.h:38
impeller::ContentContext
Definition: content_context.h:122
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::LinearGradientContents
Definition: linear_gradient_contents.h:17
impeller::LinearGradientContents::~LinearGradientContents
~LinearGradientContents() override
impeller::LinearGradientContents::GetColors
const std::vector< Color > & GetColors() const
Definition: linear_gradient_contents.cc:35
impeller::LinearGradientContents::LinearGradientContents
LinearGradientContents()
impeller::LinearGradientContents::SetTileMode
void SetTileMode(Entity::TileMode tile_mode)
Definition: linear_gradient_contents.cc:43
impeller::LinearGradientContents::GetStops
const std::vector< Scalar > & GetStops() const
Definition: linear_gradient_contents.cc:39
impeller::LinearGradientContents::SetColors
void SetColors(std::vector< Color > colors)
Definition: linear_gradient_contents.cc:27
impeller::LinearGradientContents::ApplyColorFilter
bool ApplyColorFilter(const ColorFilterProc &color_filter_proc) override
If possible, applies a color filter to this contents inputs on the CPU.
Definition: linear_gradient_contents.cc:364
impeller::LinearGradientContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: linear_gradient_contents.cc:198
impeller::LinearGradientContents::SetEndPoints
void SetEndPoints(Point start_point, Point end_point)
Definition: linear_gradient_contents.cc:22
impeller::LinearGradientContents::SetStops
void SetStops(std::vector< Scalar > stops)
Definition: linear_gradient_contents.cc:31
impeller::LinearGradientContents::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: linear_gradient_contents.cc:47
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
color.h
color_source_contents.h
entity.h
transform
Matrix transform
Definition: gaussian_blur_filter_contents.cc:312
impeller
Definition: allocation.cc:12
point.h
impeller::Color
Definition: color.h:124
impeller::Color::BlackTransparent
static constexpr Color BlackTransparent()
Definition: color.h:270
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::TPoint< Scalar >