Flutter Engine
 
Loading...
Searching...
No Matches
dl_compose_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
8
9namespace flutter {
10
11std::shared_ptr<DlImageFilter> DlComposeImageFilter::Make(
12 const std::shared_ptr<DlImageFilter>& outer,
13 const std::shared_ptr<DlImageFilter>& inner) {
14 if (!outer) {
15 return inner;
16 }
17 if (!inner) {
18 return outer;
19 }
20 return std::make_shared<DlComposeImageFilter>(outer, inner);
21}
22
24 if (inner_ && inner_->modifies_transparent_black()) {
25 return true;
26 }
27 if (outer_ && outer_->modifies_transparent_black()) {
28 return true;
29 }
30 return false;
31}
32
34 DlRect& output_bounds) const {
35 DlRect cur_bounds = input_bounds;
36 DlRect* ret = &output_bounds;
37 // We set this result in case neither filter is present.
38 output_bounds = input_bounds;
39 if (inner_) {
40 if (!inner_->map_local_bounds(cur_bounds, output_bounds)) {
41 ret = nullptr;
42 }
43 cur_bounds = output_bounds;
44 }
45 if (outer_) {
46 if (!outer_->map_local_bounds(cur_bounds, output_bounds)) {
47 ret = nullptr;
48 }
49 }
50 return ret;
51}
52
54 const DlMatrix& ctm,
55 DlIRect& output_bounds) const {
56 DlIRect cur_bounds = input_bounds;
57 DlIRect* ret = &output_bounds;
58 // We set this result in case neither filter is present.
59 output_bounds = input_bounds;
60 if (inner_) {
61 if (!inner_->map_device_bounds(cur_bounds, ctm, output_bounds)) {
62 ret = nullptr;
63 }
64 cur_bounds = output_bounds;
65 }
66 if (outer_) {
67 if (!outer_->map_device_bounds(cur_bounds, ctm, output_bounds)) {
68 ret = nullptr;
69 }
70 }
71 return ret;
72}
73
75 const DlIRect& output_bounds,
76 const DlMatrix& ctm,
77 DlIRect& input_bounds) const {
78 DlIRect cur_bounds = output_bounds;
79 DlIRect* ret = &input_bounds;
80 // We set this result in case neither filter is present.
81 input_bounds = output_bounds;
82 if (outer_) {
83 if (!outer_->get_input_device_bounds(cur_bounds, ctm, input_bounds)) {
84 ret = nullptr;
85 }
86 cur_bounds = input_bounds;
87 }
88 if (inner_) {
89 if (!inner_->get_input_device_bounds(cur_bounds, ctm, input_bounds)) {
90 ret = nullptr;
91 }
92 }
93 return ret;
94}
95
97 const {
98 return std::min(outer_->matrix_capability(), inner_->matrix_capability());
99}
100
103 auto that = static_cast<const DlComposeImageFilter*>(&other);
104 return (Equals(outer_, that->outer_) && Equals(inner_, that->inner_));
105}
106
107} // namespace flutter
virtual T type() const =0
std::shared_ptr< DlImageFilter > inner() const
std::shared_ptr< DlImageFilter > outer() const
DlIRect * get_input_device_bounds(const DlIRect &output_bounds, const DlMatrix &ctm, DlIRect &input_bounds) const override
DlIRect * map_device_bounds(const DlIRect &input_bounds, const DlMatrix &ctm, DlIRect &output_bounds) const override
MatrixCapability matrix_capability() const override
DlRect * map_local_bounds(const DlRect &input_bounds, DlRect &output_bounds) const override
bool modifies_transparent_black() const override
bool equals_(const DlImageFilter &other) const override
static std::shared_ptr< DlImageFilter > Make(const std::shared_ptr< DlImageFilter > &outer, const std::shared_ptr< DlImageFilter > &inner)
#define FML_DCHECK(condition)
Definition logging.h:122
bool Equals(const T *a, const U *b)
A 4x4 matrix using column-major storage.
Definition matrix.h:37