Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
dl_blur_image_filter.cc
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
6
7namespace flutter {
8
9std::shared_ptr<DlImageFilter> DlBlurImageFilter::Make(
10 DlScalar sigma_x,
11 DlScalar sigma_y,
12 DlTileMode tile_mode,
13 std::optional<DlRect> bounds) {
14 if (!std::isfinite(sigma_x) || !std::isfinite(sigma_y)) {
15 return nullptr;
16 }
17 if (sigma_x < SK_ScalarNearlyZero && sigma_y < SK_ScalarNearlyZero) {
18 return nullptr;
19 }
20 sigma_x = (sigma_x < SK_ScalarNearlyZero) ? 0 : sigma_x;
21 sigma_y = (sigma_y < SK_ScalarNearlyZero) ? 0 : sigma_y;
22 return std::make_shared<DlBlurImageFilter>(sigma_x, sigma_y, tile_mode,
23 bounds);
24}
25
27 DlRect& output_bounds) const {
28 output_bounds = input_bounds.Expand(sigma_x_ * 3.0f, sigma_y_ * 3.0f);
29 return &output_bounds;
30}
31
33 const DlMatrix& ctm,
34 DlIRect& output_bounds) const {
35 return outset_device_bounds(input_bounds, sigma_x_ * 3.0f, sigma_y_ * 3.0f,
36 ctm, output_bounds);
37}
38
40 const DlIRect& output_bounds,
41 const DlMatrix& ctm,
42 DlIRect& input_bounds) const {
43 // Blurs are symmetric in terms of output-for-input and input-for-output
44 return map_device_bounds(output_bounds, ctm, input_bounds);
45}
46
47bool DlBlurImageFilter::equals_(const DlImageFilter& other) const {
49 auto that = static_cast<const DlBlurImageFilter*>(&other);
50 return (DlScalarNearlyEqual(sigma_x_, that->sigma_x_) &&
51 DlScalarNearlyEqual(sigma_y_, that->sigma_y_) &&
52 tile_mode_ == that->tile_mode_ && bounds_ == that->bounds_);
53}
54
55} // namespace flutter
virtual T type() const =0
static std::shared_ptr< DlImageFilter > Make(DlScalar sigma_x, DlScalar sigma_y, DlTileMode tile_mode, std::optional< DlRect > bounds=std::nullopt)
std::optional< DlRect > bounds() const
DlIRect * get_input_device_bounds(const DlIRect &output_bounds, const DlMatrix &ctm, DlIRect &input_bounds) const override
bool equals_(const DlImageFilter &other) const override
DlRect * map_local_bounds(const DlRect &input_bounds, DlRect &output_bounds) const override
DlIRect * map_device_bounds(const DlIRect &input_bounds, const DlMatrix &ctm, DlIRect &output_bounds) const override
static DlIRect * outset_device_bounds(const DlIRect &input_bounds, DlScalar radius_x, DlScalar radius_y, const DlMatrix &ctm, DlIRect &output_bounds)
#define FML_DCHECK(condition)
Definition logging.h:122
impeller::Scalar DlScalar
constexpr bool DlScalarNearlyEqual(DlScalar x, DlScalar y, DlScalar tolerance=kEhCloseEnough)
A 4x4 matrix using column-major storage.
Definition matrix.h:37
constexpr TRect< T > Expand(T left, T top, T right, T bottom) const
Returns a rectangle with expanded edges. Negative expansion results in shrinking.
Definition rect.h:618