Flutter Engine
 
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(DlScalar sigma_x,
10 DlScalar sigma_y,
11 DlTileMode tile_mode) {
12 if (!std::isfinite(sigma_x) || !std::isfinite(sigma_y)) {
13 return nullptr;
14 }
15 if (sigma_x < SK_ScalarNearlyZero && sigma_y < SK_ScalarNearlyZero) {
16 return nullptr;
17 }
18 sigma_x = (sigma_x < SK_ScalarNearlyZero) ? 0 : sigma_x;
19 sigma_y = (sigma_y < SK_ScalarNearlyZero) ? 0 : sigma_y;
20 return std::make_shared<DlBlurImageFilter>(sigma_x, sigma_y, tile_mode);
21}
22
24 DlRect& output_bounds) const {
25 output_bounds = input_bounds.Expand(sigma_x_ * 3.0f, sigma_y_ * 3.0f);
26 return &output_bounds;
27}
28
30 const DlMatrix& ctm,
31 DlIRect& output_bounds) const {
32 return outset_device_bounds(input_bounds, sigma_x_ * 3.0f, sigma_y_ * 3.0f,
33 ctm, output_bounds);
34}
35
37 const DlIRect& output_bounds,
38 const DlMatrix& ctm,
39 DlIRect& input_bounds) const {
40 // Blurs are symmetric in terms of output-for-input and input-for-output
41 return map_device_bounds(output_bounds, ctm, input_bounds);
42}
43
44bool DlBlurImageFilter::equals_(const DlImageFilter& other) const {
46 auto that = static_cast<const DlBlurImageFilter*>(&other);
47 return (DlScalarNearlyEqual(sigma_x_, that->sigma_x_) &&
48 DlScalarNearlyEqual(sigma_y_, that->sigma_y_) &&
49 tile_mode_ == that->tile_mode_);
50}
51
52} // namespace flutter
virtual T type() const =0
DlIRect * get_input_device_bounds(const DlIRect &output_bounds, const DlMatrix &ctm, DlIRect &input_bounds) const override
bool equals_(const DlImageFilter &other) const override
static std::shared_ptr< DlImageFilter > Make(DlScalar sigma_x, DlScalar sigma_y, DlTileMode tile_mode)
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