Flutter Engine
The Flutter Engine
dl_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
5#include "flutter/display_list/effects/dl_image_filter.h"
6
7namespace flutter {
8
9std::shared_ptr<DlImageFilter> DlImageFilter::makeWithLocalMatrix(
10 const SkMatrix& matrix) const {
11 if (matrix.isIdentity()) {
12 return shared();
13 }
14 // Matrix
15 switch (this->matrix_capability()) {
17 if (!matrix.isTranslate()) {
18 // Nothing we can do at this point
19 return nullptr;
20 }
21 break;
22 }
24 if (!matrix.isScaleTranslate()) {
25 // Nothing we can do at this point
26 return nullptr;
27 }
28 break;
29 }
30 default:
31 break;
32 }
33 return std::make_shared<DlLocalMatrixImageFilter>(matrix, shared());
34}
35
37 SkRect& output_bounds) const {
38 SkRect cur_bounds = input_bounds;
39 SkRect* ret = &output_bounds;
40 // We set this result in case neither filter is present.
41 output_bounds = input_bounds;
42 if (inner_) {
43 if (!inner_->map_local_bounds(cur_bounds, output_bounds)) {
44 ret = nullptr;
45 }
46 cur_bounds = output_bounds;
47 }
48 if (outer_) {
49 if (!outer_->map_local_bounds(cur_bounds, output_bounds)) {
50 ret = nullptr;
51 }
52 }
53 return ret;
54}
55
57 const SkMatrix& ctm,
58 SkIRect& output_bounds) const {
59 SkIRect cur_bounds = input_bounds;
60 SkIRect* ret = &output_bounds;
61 // We set this result in case neither filter is present.
62 output_bounds = input_bounds;
63 if (inner_) {
64 if (!inner_->map_device_bounds(cur_bounds, ctm, output_bounds)) {
65 ret = nullptr;
66 }
67 cur_bounds = output_bounds;
68 }
69 if (outer_) {
70 if (!outer_->map_device_bounds(cur_bounds, ctm, output_bounds)) {
71 ret = nullptr;
72 }
73 }
74 return ret;
75}
76
78 const SkIRect& output_bounds,
79 const SkMatrix& ctm,
80 SkIRect& input_bounds) const {
81 SkIRect cur_bounds = output_bounds;
82 SkIRect* ret = &input_bounds;
83 // We set this result in case neither filter is present.
84 input_bounds = output_bounds;
85 if (outer_) {
86 if (!outer_->get_input_device_bounds(cur_bounds, ctm, input_bounds)) {
87 ret = nullptr;
88 }
89 cur_bounds = input_bounds;
90 }
91 if (inner_) {
92 if (!inner_->get_input_device_bounds(cur_bounds, ctm, input_bounds)) {
93 ret = nullptr;
94 }
95 }
96 return ret;
97}
98
99} // namespace flutter
bool isTranslate() const
Definition: SkMatrix.h:248
virtual std::shared_ptr< DlImageFilter > shared() const=0
SkIRect * get_input_device_bounds(const SkIRect &output_bounds, const SkMatrix &ctm, SkIRect &input_bounds) const override
SkRect * map_local_bounds(const SkRect &input_bounds, SkRect &output_bounds) const override
SkIRect * map_device_bounds(const SkIRect &input_bounds, const SkMatrix &ctm, SkIRect &output_bounds) const override
virtual MatrixCapability matrix_capability() const
virtual std::shared_ptr< DlImageFilter > makeWithLocalMatrix(const SkMatrix &matrix) const
unsigned useCenter Optional< SkMatrix > matrix
Definition: SkRecords.h:258
Definition: SkRect.h:32