Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
paint.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_AIKS_PAINT_H_
6#define FLUTTER_IMPELLER_AIKS_PAINT_H_
7
8#include <memory>
9
20
21namespace impeller {
22
23struct Paint {
24 using ImageFilterProc = std::function<std::shared_ptr<FilterContents>(
26 const Matrix& effect_transform,
27 Entity::RenderingMode rendering_mode)>;
28 using MaskFilterProc = std::function<std::shared_ptr<FilterContents>(
30 bool is_solid_color,
31 const Matrix& effect_transform)>;
32 using ColorSourceProc = std::function<std::shared_ptr<ColorSourceContents>()>;
33
34 enum class Style {
35 kFill,
36 kStroke,
37 };
38
42
43 std::shared_ptr<FilterContents> CreateMaskBlur(
44 std::shared_ptr<ColorSourceContents> color_source_contents,
45 const std::shared_ptr<ColorFilter>& color_filter) const;
46
47 std::shared_ptr<FilterContents> CreateMaskBlur(
48 std::shared_ptr<TextureContents> texture_contents) const;
49
50 std::shared_ptr<FilterContents> CreateMaskBlur(
51 const FilterInput::Ref& input,
52 bool is_solid_color) const;
53 };
54
57 bool dither = false;
58
65 bool invert_colors = false;
66
67 std::shared_ptr<ImageFilter> image_filter;
68 std::shared_ptr<ColorFilter> color_filter;
69 std::optional<MaskBlurDescriptor> mask_blur_descriptor;
70
71 std::shared_ptr<ColorFilter> GetColorFilter() const;
72
73 /// @brief Wrap this paint's configured filters to the given contents.
74 /// @param[in] input The contents to wrap with paint's filters.
75 /// @return The filter-wrapped contents. If there are no filters that need
76 /// to be wrapped for the current paint configuration, the
77 /// original contents is returned.
78 std::shared_ptr<Contents> WithFilters(std::shared_ptr<Contents> input) const;
79
80 /// @brief Wrap this paint's configured filters to the given contents of
81 /// subpass target.
82 /// @param[in] input The contents of subpass target to wrap with paint's
83 /// filters.
84 ///
85 /// @return The filter-wrapped contents. If there are no filters that need
86 /// to be wrapped for the current paint configuration, the
87 /// original contents is returned.
88 std::shared_ptr<Contents> WithFiltersForSubpassTarget(
89 std::shared_ptr<Contents> input,
90 const Matrix& effect_transform = Matrix()) const;
91
92 std::shared_ptr<Contents> CreateContentsForGeometry(
93 const std::shared_ptr<Geometry>& geometry) const;
94
95 /// @brief Whether this paint has a color filter that can apply opacity
96 bool HasColorFilter() const;
97
98 std::shared_ptr<Contents> WithMaskBlur(std::shared_ptr<Contents> input,
99 bool is_solid_color) const;
100
101 std::shared_ptr<FilterContents> WithImageFilter(
102 const FilterInput::Variant& input,
103 const Matrix& effect_transform,
104 Entity::RenderingMode rendering_mode) const;
105
106 private:
107 std::shared_ptr<Contents> WithColorFilter(
108 std::shared_ptr<Contents> input,
111};
112
113} // namespace impeller
114
115#endif // FLUTTER_IMPELLER_AIKS_PAINT_H_
std::shared_ptr< FilterInput > Ref
std::variant< std::shared_ptr< FilterContents >, std::shared_ptr< Contents >, std::shared_ptr< Texture >, Rect > Variant
float Scalar
Definition scalar.h:18
BlendMode
Definition color.h:59
static constexpr Color Black()
Definition color.h:258
A 4x4 matrix using column-major storage.
Definition matrix.h:37
std::shared_ptr< FilterContents > CreateMaskBlur(std::shared_ptr< ColorSourceContents > color_source_contents, const std::shared_ptr< ColorFilter > &color_filter) const
Definition paint.cc:153
FilterContents::BlurStyle style
Definition paint.h:40
std::shared_ptr< Contents > WithMaskBlur(std::shared_ptr< Contents > input, bool is_solid_color) const
Definition paint.cc:79
bool dither
Definition paint.h:57
ColorSource color_source
Definition paint.h:56
std::shared_ptr< ColorFilter > GetColorFilter() const
Definition paint.cc:213
std::function< std::shared_ptr< FilterContents >(FilterInput::Ref, const Matrix &effect_transform, Entity::RenderingMode rendering_mode)> ImageFilterProc
Definition paint.h:27
bool HasColorFilter() const
Whether this paint has a color filter that can apply opacity.
Definition paint.cc:227
Cap stroke_cap
Definition paint.h:60
Join stroke_join
Definition paint.h:61
Scalar stroke_miter
Definition paint.h:62
std::function< std::shared_ptr< ColorSourceContents >()> ColorSourceProc
Definition paint.h:32
std::shared_ptr< Contents > CreateContentsForGeometry(const std::shared_ptr< Geometry > &geometry) const
Definition paint.cc:30
Style style
Definition paint.h:63
bool invert_colors
Definition paint.h:65
std::shared_ptr< ImageFilter > image_filter
Definition paint.h:67
std::optional< MaskBlurDescriptor > mask_blur_descriptor
Definition paint.h:69
Color color
Definition paint.h:55
BlendMode blend_mode
Definition paint.h:64
std::function< std::shared_ptr< FilterContents >(FilterInput::Ref, bool is_solid_color, const Matrix &effect_transform)> MaskFilterProc
Definition paint.h:31
std::shared_ptr< Contents > WithFiltersForSubpassTarget(std::shared_ptr< Contents > input, const Matrix &effect_transform=Matrix()) const
Wrap this paint's configured filters to the given contents of subpass target.
Definition paint.cc:67
std::shared_ptr< Contents > WithFilters(std::shared_ptr< Contents > input) const
Wrap this paint's configured filters to the given contents.
Definition paint.cc:56
std::shared_ptr< FilterContents > WithImageFilter(const FilterInput::Variant &input, const Matrix &effect_transform, Entity::RenderingMode rendering_mode) const
Definition paint.cc:88
std::shared_ptr< ColorFilter > color_filter
Definition paint.h:68
Scalar stroke_width
Definition paint.h:59
In filters that use Gaussian distributions, "sigma" is a size of one standard deviation in terms of t...
Definition sigma.h:32