Flutter Impeller
solid_rrect_like_blur_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_SOLID_RRECT_LIKE_BLUR_CONTENTS_H_
6 #define FLUTTER_IMPELLER_ENTITY_CONTENTS_SOLID_RRECT_LIKE_BLUR_CONTENTS_H_
7 
8 #include <functional>
9 #include <memory>
10 #include <vector>
11 
15 
16 namespace impeller {
17 
18 /// @brief A base class for any accelerated single color blur Contents
19 /// that lets the |Canvas::AttemptDrawBlur| call deliver the
20 /// color after the contents has been constructed and the method
21 /// has a chance to re-consider the actual color that will be
22 /// used to render the shadow.
23 class SolidBlurContents : public Contents {
24  public:
25  virtual void SetColor(Color color) = 0;
26 };
27 
28 /// @brief A base class for SolidRRectBlurContents and
29 /// SolidRSuperellipseBlurContents.
31  public:
33 
34  void SetShape(Rect rect, Scalar corner_radius);
35 
36  void SetSigma(Sigma sigma);
37 
38  // |SolidBlurContents|
39  void SetColor(Color color) override;
40 
41  Color GetColor() const;
42 
43  // |Contents|
44  std::optional<Rect> GetCoverage(const Entity& entity) const override;
45 
46  // |Contents|
47  bool Render(const ContentContext& renderer,
48  const Entity& entity,
49  RenderPass& pass) const override;
50 
51  // |Contents|
52  [[nodiscard]] bool ApplyColorFilter(
53  const ColorFilterProc& color_filter_proc) override;
54 
55  protected:
56  struct PassContext {
57  // General info
59  // Frag info
68  };
69 
71 
72  virtual bool SetPassInfo(RenderPass& pass,
73  const ContentContext& renderer,
74  PassContext& pass_context) const = 0;
75 
76  Rect GetRect() const { return rect_; }
77  Scalar GetCornerRadius() const { return corner_radius_; }
78  Sigma GetSigma() const { return sigma_; }
79 
80  static Vector4 Concat(Vector2& a, Vector2& b);
81 
82  private:
83  static bool PopulateFragContext(PassContext& pass_context,
84  Scalar blurSigma,
85  Point center,
86  Point rSize,
87  Scalar radius);
88 
89  Rect rect_;
90  Scalar corner_radius_;
91  Sigma sigma_;
92  Color color_;
93 
95 
97  delete;
98 };
99 
100 } // namespace impeller
101 
102 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_SOLID_RRECT_LIKE_BLUR_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
A base class for any accelerated single color blur Contents that lets the |Canvas::AttemptDrawBlur| c...
virtual void SetColor(Color color)=0
A base class for SolidRRectBlurContents and SolidRSuperellipseBlurContents.
void SetShape(Rect rect, Scalar corner_radius)
std::optional< Rect > GetCoverage(const Entity &entity) const override
Get the area of the render pass that will be affected when this contents is rendered.
virtual bool SetPassInfo(RenderPass &pass, const ContentContext &renderer, PassContext &pass_context) const =0
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.
static Vector4 Concat(Vector2 &a, Vector2 &b)
float Scalar
Definition: scalar.h:19
In filters that use Gaussian distributions, "sigma" is a size of one standard deviation in terms of t...
Definition: sigma.h:32