Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
dl_blur_image_filter.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_DISPLAY_LIST_EFFECTS_IMAGE_FILTERS_DL_BLUR_IMAGE_FILTER_H_
6#define FLUTTER_DISPLAY_LIST_EFFECTS_IMAGE_FILTERS_DL_BLUR_IMAGE_FILTER_H_
7
9
11
12namespace flutter {
13
14class DlBlurImageFilter final : public DlImageFilter {
15 public:
16 /**
17 * @brief Creates an ImageFilter that applies a Gaussian blur to its input.
18 *
19 * @param sigma_x The standard deviation of the Gaussian kernel in the X
20 * direction.
21 * @param sigma_y The standard deviation of the Gaussian kernel in the Y
22 * direction.
23 * @param bounds An optional rectangle that enables "bounded blur" mode.
24 * @param tile_mode Defines how to sample from areas outside the bounds of the
25 * input texture.
26 *
27 * If `bounds` is std::nullopt, a standard Gaussian blur is applied and to the
28 * entire surface.
29 *
30 * If `bounds` is not std::nullopt, the filter performs a "bounded blur": the
31 * image filter substitutes transparent black for any sample it reads from
32 * outside the defined bounding rectangle. The final weighted sum is then
33 * divided by the total weight of the non-transparent samples (the effective
34 * alpha), resulting in opaque output.
35 *
36 * The bounded mode prevents color bleeding from content adjacent to the
37 * bounds into the blurred area, and is typically used when the blur must be
38 * strictly contained within a clipped region, such as for iOS-style frosted
39 * glass effects.
40 *
41 * The `bounds` rectangle is specified in the canvas's current coordinate
42 * space and is affected by the current transform; consequently, the bounds
43 * may not be axis-aligned in the final canvas coordinates.
44 */
48 std::optional<DlRect> bounds = std::nullopt)
49 : sigma_x_(sigma_x),
50 sigma_y_(sigma_y),
51 tile_mode_(tile_mode),
52 bounds_(bounds) {}
53 explicit DlBlurImageFilter(const DlBlurImageFilter* filter)
54 : DlBlurImageFilter(filter->sigma_x_,
55 filter->sigma_y_,
56 filter->tile_mode_,
57 filter->bounds_) {}
59 : DlBlurImageFilter(&filter) {}
60
61 static std::shared_ptr<DlImageFilter> Make(
65 std::optional<DlRect> bounds = std::nullopt);
66
67 std::shared_ptr<DlImageFilter> shared() const override {
68 return std::make_shared<DlBlurImageFilter>(this);
69 }
70
71 DlImageFilterType type() const override { return DlImageFilterType::kBlur; }
72 size_t size() const override { return sizeof(*this); }
73
74 const DlBlurImageFilter* asBlur() const override { return this; }
75
76 bool modifies_transparent_black() const override { return false; }
77
78 DlRect* map_local_bounds(const DlRect& input_bounds,
79 DlRect& output_bounds) const override;
80
81 DlIRect* map_device_bounds(const DlIRect& input_bounds,
82 const DlMatrix& ctm,
83 DlIRect& output_bounds) const override;
84
85 DlIRect* get_input_device_bounds(const DlIRect& output_bounds,
86 const DlMatrix& ctm,
87 DlIRect& input_bounds) const override;
88
89 DlScalar sigma_x() const { return sigma_x_; }
90 DlScalar sigma_y() const { return sigma_y_; }
91 DlTileMode tile_mode() const { return tile_mode_; }
92 std::optional<DlRect> bounds() const { return bounds_; }
93
94 protected:
95 bool equals_(const DlImageFilter& other) const override;
96
97 private:
98 DlScalar sigma_x_;
99 DlScalar sigma_y_;
100 DlTileMode tile_mode_;
101 std::optional<DlRect> bounds_;
102};
103
104} // namespace flutter
105
106#endif // FLUTTER_DISPLAY_LIST_EFFECTS_IMAGE_FILTERS_DL_BLUR_IMAGE_FILTER_H_
bool modifies_transparent_black() const override
static std::shared_ptr< DlImageFilter > Make(DlScalar sigma_x, DlScalar sigma_y, DlTileMode tile_mode, std::optional< DlRect > bounds=std::nullopt)
DlImageFilterType type() const override
std::optional< DlRect > bounds() const
DlIRect * get_input_device_bounds(const DlIRect &output_bounds, const DlMatrix &ctm, DlIRect &input_bounds) const override
DlBlurImageFilter(DlScalar sigma_x, DlScalar sigma_y, DlTileMode tile_mode, std::optional< DlRect > bounds=std::nullopt)
Creates an ImageFilter that applies a Gaussian blur to its input.
std::shared_ptr< DlImageFilter > shared() const override
bool equals_(const DlImageFilter &other) const override
const DlBlurImageFilter * asBlur() const override
size_t size() const override
DlRect * map_local_bounds(const DlRect &input_bounds, DlRect &output_bounds) const override
DlBlurImageFilter(const DlBlurImageFilter *filter)
DlBlurImageFilter(const DlBlurImageFilter &filter)
DlIRect * map_device_bounds(const DlIRect &input_bounds, const DlMatrix &ctm, DlIRect &output_bounds) const override
impeller::Scalar DlScalar
A 4x4 matrix using column-major storage.
Definition matrix.h:37