15#include "flutter/fml/logging.h"
42 const std::shared_ptr<Geometry>& mask_geometry) {
43 auto blur = std::make_shared<GaussianBlurFilterContents>(
44 sigma_x.
sigma, sigma_y.
sigma, tile_mode, mask_blur_style, mask_geometry);
45 blur->SetInputs({input});
54 auto filter = std::make_shared<BorderMaskBlurFilterContents>();
55 filter->SetInputs({std::move(input)});
56 filter->SetSigma(sigma_x, sigma_y);
57 filter->SetBlurStyle(blur_style);
66 auto filter = std::make_shared<DirectionalMorphologyFilterContents>();
67 filter->SetInputs({std::move(input)});
68 filter->SetRadius(radius);
69 filter->SetDirection(direction);
70 filter->SetMorphType(morph_type);
80 Point(1, 0), morph_type);
90 auto filter = std::make_shared<MatrixFilterContents>();
91 filter->SetInputs({std::move(input)});
93 filter->SetSamplerDescriptor(
desc);
100 auto filter = std::make_shared<LocalMatrixFilterContents>();
101 filter->SetInputs({std::move(input)});
102 filter->SetMatrix(
matrix);
107 std::shared_ptr<Texture> y_texture,
108 std::shared_ptr<Texture> uv_texture,
110 auto filter = std::make_shared<impeller::YUVToRGBFilterContents>();
113 filter->SetYUVColorSpace(yuv_color_space);
122 inputs_ = std::move(
inputs);
126 effect_transform_ = effect_transform;
128 for (
auto& input : inputs_) {
129 input->SetEffectTransform(effect_transform);
137 if (!filter_coverage.has_value()) {
144 if (!maybe_entity.has_value()) {
148 return maybe_entity->Render(
renderer, pass);
151std::optional<Rect> FilterContents::GetLocalCoverage(
152 const Entity& local_entity)
const {
155 if (coverage_hint.has_value() &&
coverage.has_value()) {
163 Entity entity_with_local_transform = entity.
Clone();
166 return GetLocalCoverage(entity_with_local_transform);
170 const std::shared_ptr<LazyGlyphAtlas>& lazy_glyph_atlas,
172 for (
auto& input : inputs_) {
173 input->PopulateGlyphAtlas(lazy_glyph_atlas,
scale);
180 const Matrix& effect_transform)
const {
185 if (inputs_.empty()) {
189 std::optional<Rect>
result;
190 for (
const auto& input :
inputs) {
191 auto coverage = input->GetCoverage(entity);
195 if (!
result.has_value()) {
205 const Matrix& effect_transform,
206 const Rect& output_limit)
const {
207 auto filter_input_coverage =
210 if (!filter_input_coverage.has_value()) {
214 std::optional<Rect> inputs_coverage;
215 for (
const auto& input : inputs_) {
216 auto input_coverage = input->GetSourceCoverage(
217 effect_transform, filter_input_coverage.value());
218 if (!input_coverage.has_value()) {
221 inputs_coverage =
Rect::Union(inputs_coverage, input_coverage.value());
223 return inputs_coverage;
229 const std::optional<Rect>& coverage_hint)
const {
230 Entity entity_with_local_transform = entity.
Clone();
233 auto coverage = GetLocalCoverage(entity_with_local_transform);
239 effect_transform_,
coverage.value(), coverage_hint);
245 std::optional<Rect> coverage_limit,
246 const std::optional<SamplerDescriptor>& sampler_descriptor,
249 const std::string& label)
const {
252 if (std::optional<Entity>
result =
255 return result->GetContents()->RenderToSnapshot(
280 for (
auto& input : inputs_) {
281 if (!input->IsTranslationOnly()) {
289 for (
auto& input : inputs_) {
290 if (!input->IsLeaf()) {
302 for (
auto& input : inputs_) {
303 input->SetLeafInputs(
inputs);
308 for (
auto& input : inputs_) {
309 input->SetRenderingMode(rendering_mode);
const std::optional< Rect > & GetCoverageHint() const
void SetTransform(const Matrix &transform)
Set the global transform matrix for this Entity.
const Matrix & GetTransform() const
Get the global transform matrix for this Entity.
uint32_t GetClipDepth() const
virtual std::optional< Rect > GetFilterSourceCoverage(const Matrix &effect_transform, const Rect &output_limit) const =0
Internal utility method for |GetSourceCoverage| that computes the inverse effect of this transform on...
static std::shared_ptr< FilterContents > MakeGaussianBlur(const FilterInput::Ref &input, Sigma sigma_x, Sigma sigma_y, Entity::TileMode tile_mode=Entity::TileMode::kDecal, BlurStyle mask_blur_style=BlurStyle::kNormal, const std::shared_ptr< Geometry > &mask_geometry=nullptr)
static const int32_t kBlurFilterRequiredMipCount
virtual bool IsTranslationOnly() const
Returns true if this filter graph doesn't perform any basis transforms to the filtered content....
std::optional< Entity > GetEntity(const ContentContext &renderer, const Entity &entity, const std::optional< Rect > &coverage_hint) const
Create an Entity that renders this filter's output.
static std::shared_ptr< FilterContents > MakeDirectionalMorphology(FilterInput::Ref input, Radius radius, Vector2 direction, MorphType morph_type)
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 std::optional< Entity > RenderFilter(const FilterInput::Vector &inputs, const ContentContext &renderer, const Entity &entity, const Matrix &effect_transform, const Rect &coverage, const std::optional< Rect > &coverage_hint) const =0
Converts zero or more filter inputs into a render instruction.
~FilterContents() override
Matrix GetTransform(const Matrix &parent_transform) const
void SetLeafInputs(const FilterInput::Vector &inputs)
Replaces the set of all leaf FilterContents with a new set of FilterInputs.
bool Render(const ContentContext &renderer, const Entity &entity, RenderPass &pass) const override
static std::shared_ptr< FilterContents > MakeMorphology(FilterInput::Ref input, Radius radius_x, Radius radius_y, MorphType morph_type)
void PopulateGlyphAtlas(const std::shared_ptr< LazyGlyphAtlas > &lazy_glyph_atlas, Scalar scale) override
Add any text data to the specified lazy atlas. The scale parameter must be used again later when draw...
static std::shared_ptr< FilterContents > MakeBorderMaskBlur(FilterInput::Ref input, Sigma sigma_x, Sigma sigma_y, BlurStyle blur_style=BlurStyle::kNormal)
static std::shared_ptr< FilterContents > MakeLocalMatrixFilter(FilterInput::Ref input, const Matrix &matrix)
void SetInputs(FilterInput::Vector inputs)
The input texture sources for this filter. Each input's emitted texture is expected to have premultip...
virtual void SetRenderingMode(Entity::RenderingMode rendering_mode)
Marks this filter chain as applying in a subpass scenario.
std::optional< Rect > GetSourceCoverage(const Matrix &effect_transform, const Rect &output_limit) const
Determines the coverage of source pixels that will be needed to produce results for the specified |ou...
bool IsLeaf() const
Returns true if this filter does not have any FilterInput children.
void SetEffectTransform(const Matrix &effect_transform)
Sets the transform which gets appended to the effect of this filter. Note that this is in addition to...
const FilterContents * AsFilter() const override
Cast to a filter. Returns nullptr if this Contents is not a filter.
virtual std::optional< Rect > GetFilterCoverage(const FilterInput::Vector &inputs, const Entity &entity, const Matrix &effect_transform) const
Internal utility method for |GetLocalCoverage| that computes the output coverage of this filter acros...
static std::shared_ptr< FilterContents > MakeMatrixFilter(FilterInput::Ref input, const Matrix &matrix, const SamplerDescriptor &desc)
std::optional< Snapshot > RenderToSnapshot(const ContentContext &renderer, const Entity &entity, std::optional< Rect > coverage_limit=std::nullopt, const std::optional< SamplerDescriptor > &sampler_descriptor=std::nullopt, bool msaa_enabled=true, int32_t mip_count=1, const std::string &label="Filter Snapshot") const override
Render this contents to a snapshot, respecting the entity's transform, path, clip depth,...
static std::shared_ptr< FilterContents > MakeYUVToRGBFilter(std::shared_ptr< Texture > y_texture, std::shared_ptr< Texture > uv_texture, YUVColorSpace yuv_color_space)
virtual Matrix GetLocalTransform(const Matrix &parent_transform) const
static const int32_t kBlurFilterRequiredMipCount
Render passes encode render commands directed as one specific render target into an underlying comman...
unsigned useCenter Optional< SkMatrix > matrix
SK_API sk_sp< PrecompileColorFilter > Matrix()
A 4x4 matrix using column-major storage.
For convolution filters, the "radius" is the size of the convolution kernel to use on the local space...
In filters that use Gaussian distributions, "sigma" is a size of one standard deviation in terms of t...
constexpr TRect Union(const TRect &o) const