Flutter Engine
 
Loading...
Searching...
No Matches
dl_matrix_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> DlMatrixImageFilter::Make(
10 const DlMatrix& matrix,
11 DlImageSampling sampling) {
12 if (matrix.IsFinite() && !matrix.IsIdentity()) {
13 return std::make_shared<DlMatrixImageFilter>(matrix, sampling);
14 }
15 return nullptr;
16}
17
19 DlRect& output_bounds) const {
20 output_bounds = input_bounds.TransformAndClipBounds(matrix_);
21 return &output_bounds;
22}
23
25 const DlMatrix& ctm,
26 DlIRect& output_bounds) const {
27 if (!ctm.IsInvertible()) {
28 output_bounds = input_bounds;
29 return nullptr;
30 }
31 DlMatrix matrix = ctm * matrix_ * ctm.Invert();
32 DlRect device_rect =
34 output_bounds = DlIRect::RoundOut(device_rect);
35 return &output_bounds;
36}
37
39 const DlIRect& output_bounds,
40 const DlMatrix& ctm,
41 DlIRect& input_bounds) const {
42 DlMatrix matrix = ctm * matrix_;
43 if (!matrix.IsInvertible()) {
44 input_bounds = output_bounds;
45 return nullptr;
46 }
47 DlMatrix inverse = ctm * matrix.Invert();
48 DlRect bounds = DlRect::Make(output_bounds);
49 bounds = bounds.TransformAndClipBounds(inverse);
50 input_bounds = DlIRect::RoundOut(bounds);
51 return &input_bounds;
52}
53
56 auto that = static_cast<const DlMatrixImageFilter*>(&other);
57 return (matrix_ == that->matrix_ && sampling_ == that->sampling_);
58}
59
60} // namespace flutter
virtual T type() const =0
DlIRect * get_input_device_bounds(const DlIRect &output_bounds, const DlMatrix &ctm, DlIRect &input_bounds) 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
bool equals_(const DlImageFilter &other) const override
const DlMatrix & matrix() const
static std::shared_ptr< DlImageFilter > Make(const DlMatrix &matrix, DlImageSampling sampling)
#define FML_DCHECK(condition)
Definition logging.h:122
A 4x4 matrix using column-major storage.
Definition matrix.h:37
constexpr bool IsIdentity() const
Definition matrix.h:467
bool IsInvertible() const
Definition matrix.h:321
Matrix Invert() const
Definition matrix.cc:99
bool IsFinite() const
Definition matrix.h:404
static constexpr std::enable_if_t< std::is_floating_point_v< FT >, TRect > Make(const TRect< U > &rect)
Definition rect.h:157
RoundOut(const TRect< U > &r)
Definition rect.h:679
constexpr TRect TransformAndClipBounds(const Matrix &transform) const
Creates a new bounding box that contains this transformed rectangle, clipped against the near clippin...
Definition rect.h:438