| 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
12 #include "impeller/entity/contents/contents.h"
13 #include "impeller/entity/contents/filters/filter_contents.h"
14 #include "impeller/geometry/color.h"
15
16 namespace impeller {
17
18 /// @brief A base class for SolidRRectBlurContents and
19 /// SolidRSuperellipseBlurContents.
20 class SolidRRectLikeBlurContents : public Contents {
21 public:
22 ~SolidRRectLikeBlurContents() override;
23
24 void SetShape(Rect rect, Scalar corner_radius);
25
26 void SetSigma(Sigma sigma);
27
28 void SetColor(Color color);
29
30 Color GetColor() const;
31
32 // |Contents|
33 std::optional<Rect> GetCoverage(const Entity& entity) const override;
34
35 // |Contents|
36 bool Render(const ContentContext& renderer,
37 const Entity& entity,
38 RenderPass& pass) const override;
39
40 // |Contents|
41 [[nodiscard]] bool ApplyColorFilter(
42 const ColorFilterProc& color_filter_proc) override;
43
44 protected:
45 struct PassContext {
46 // General info
47 ContentContextOptions opts;
48 // Frag info
49 Point center;
50 Point adjust;
51 Scalar minEdge;
52 Scalar r1;
53 Scalar exponent;
54 Scalar sInv;
55 Scalar exponentInv;
56 Scalar scale;
57 };
58
59 SolidRRectLikeBlurContents();
60
61 virtual bool SetPassInfo(RenderPass& pass,
62 const ContentContext& renderer,
63 PassContext& pass_context) const = 0;
64
65 Rect GetRect() const { return rect_; }
66 Scalar GetCornerRadius() const { return corner_radius_; }
67 Sigma GetSigma() const { return sigma_; }
68
69 static Vector4 Concat(Vector2& a, Vector2& b);
70
71 private:
72 static bool PopulateFragContext(PassContext& pass_context,
73 Scalar blurSigma,
74 Point center,
75 Point rSize,
76 Scalar radius);
77
78 Rect rect_;
79 Scalar corner_radius_;
80 Sigma sigma_;
81 Color color_;
82
83 SolidRRectLikeBlurContents(const SolidRRectLikeBlurContents&) = delete;
84
85 SolidRRectLikeBlurContents& operator=(const SolidRRectLikeBlurContents&) =
86 delete;
87 };
88
89 } // namespace impeller
90
91 #endif // FLUTTER_IMPELLER_ENTITY_CONTENTS_SOLID_RRECT_LIKE_BLUR_CONTENTS_H_
impeller::ContentContext
Definition: content_context.h:138
impeller::Contents
Definition: contents.h:31
impeller::Contents::ColorFilterProc
std::function< Color(Color)> ColorFilterProc
Definition: contents.h:35
impeller::Entity
Definition: entity.h:26
impeller::RenderPass
Render passes encode render commands directed as one specific render target into an underlying comman...
Definition: render_pass.h:30
impeller::SolidRRectLikeBlurContents
A base class for SolidRRectBlurContents and SolidRSuperellipseBlurContents.
Definition: solid_rrect_like_blur_contents.h:20
impeller::SolidRRectLikeBlurContents::SetShape
void SetShape(Rect rect, Scalar corner_radius)
Definition: solid_rrect_like_blur_contents.cc:33
impeller::SolidRRectLikeBlurContents::GetCoverage
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.
Definition: solid_rrect_like_blur_contents.cc:108
impeller::SolidRRectLikeBlurContents::~SolidRRectLikeBlurContents
~SolidRRectLikeBlurContents() override
impeller::SolidRRectLikeBlurContents::SetPassInfo
virtual bool SetPassInfo(RenderPass &pass, const ContentContext &renderer, PassContext &pass_context) const =0
impeller::SolidRRectLikeBlurContents::Render
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
Definition: solid_rrect_like_blur_contents.cc:115
impeller::SolidRRectLikeBlurContents::SetSigma
void SetSigma(Sigma sigma)
Definition: solid_rrect_like_blur_contents.cc:38
impeller::SolidRRectLikeBlurContents::GetColor
Color GetColor() const
Definition: solid_rrect_like_blur_contents.cc:46
impeller::SolidRRectLikeBlurContents::ApplyColorFilter
bool ApplyColorFilter(const ColorFilterProc &color_filter_proc) override
If possible, applies a color filter to this contents inputs on the CPU.
Definition: solid_rrect_like_blur_contents.cc:187
impeller::SolidRRectLikeBlurContents::Concat
static Vector4 Concat(Vector2 &a, Vector2 &b)
Definition: solid_rrect_like_blur_contents.cc:193
impeller::SolidRRectLikeBlurContents::SolidRRectLikeBlurContents
SolidRRectLikeBlurContents()
impeller::SolidRRectLikeBlurContents::GetCornerRadius
Scalar GetCornerRadius() const
Definition: solid_rrect_like_blur_contents.h:66
impeller::SolidRRectLikeBlurContents::SetColor
void SetColor(Color color)
Definition: solid_rrect_like_blur_contents.cc:42
impeller::SolidRRectLikeBlurContents::GetRect
Rect GetRect() const
Definition: solid_rrect_like_blur_contents.h:65
impeller::SolidRRectLikeBlurContents::GetSigma
Sigma GetSigma() const
Definition: solid_rrect_like_blur_contents.h:67
color.h
contents.h
filter_contents.h
impeller::saturated::b
SI b
Definition: saturated_math.h:87
impeller
Definition: allocation.cc:12
impeller::Scalar
float Scalar
Definition: scalar.h:19
impeller::Color
Definition: color.h:124
impeller::ContentContextOptions
Definition: content_context.h:40
impeller::Sigma
In filters that use Gaussian distributions, "sigma" is a size of one standard deviation in terms of t...
Definition: sigma.h:32
impeller::SolidRRectLikeBlurContents::PassContext
Definition: solid_rrect_like_blur_contents.h:45
impeller::SolidRRectLikeBlurContents::PassContext::scale
Scalar scale
Definition: solid_rrect_like_blur_contents.h:56
impeller::SolidRRectLikeBlurContents::PassContext::r1
Scalar r1
Definition: solid_rrect_like_blur_contents.h:52
impeller::SolidRRectLikeBlurContents::PassContext::adjust
Point adjust
Definition: solid_rrect_like_blur_contents.h:50
impeller::SolidRRectLikeBlurContents::PassContext::exponentInv
Scalar exponentInv
Definition: solid_rrect_like_blur_contents.h:55
impeller::SolidRRectLikeBlurContents::PassContext::sInv
Scalar sInv
Definition: solid_rrect_like_blur_contents.h:54
impeller::SolidRRectLikeBlurContents::PassContext::opts
ContentContextOptions opts
Definition: solid_rrect_like_blur_contents.h:47
impeller::SolidRRectLikeBlurContents::PassContext::minEdge
Scalar minEdge
Definition: solid_rrect_like_blur_contents.h:51
impeller::SolidRRectLikeBlurContents::PassContext::exponent
Scalar exponent
Definition: solid_rrect_like_blur_contents.h:53
impeller::SolidRRectLikeBlurContents::PassContext::center
Point center
Definition: solid_rrect_like_blur_contents.h:49
impeller::TPoint< Scalar >
impeller::TRect< Scalar >
impeller::Vector4
Definition: vector.h:232