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