| Flutter Impeller |

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 "impeller/toolkit/interop/image_filter.h"
6
7 namespace impeller::interop {
8
9 ImageFilter::ImageFilter(std::shared_ptr<const flutter::DlImageFilter> filter)
10 : filter_(std::move(filter)) {}
11
12 ImageFilter::~ImageFilter() = default;
13
14 ScopedObject<ImageFilter> ImageFilter::MakeBlur(Scalar x_sigma,
15 Scalar y_sigma,
16 flutter::DlTileMode tile_mode) {
17 auto filter = flutter::DlBlurImageFilter::Make(x_sigma, y_sigma, tile_mode);
18 if (!filter) {
19 return nullptr;
20 }
21 return Create<ImageFilter>(std::move(filter));
22 }
23
24 ScopedObject<ImageFilter> ImageFilter::MakeDilate(Scalar x_radius,
25 Scalar y_radius) {
26 auto filter = flutter::DlDilateImageFilter::Make(x_radius, y_radius);
27 if (!filter) {
28 return nullptr;
29 }
30 return Create<ImageFilter>(std::move(filter));
31 }
32
33 ScopedObject<ImageFilter> ImageFilter::MakeErode(Scalar x_radius,
34 Scalar y_radius) {
35 auto filter = flutter::DlErodeImageFilter::Make(x_radius, y_radius);
36 if (!filter) {
37 return nullptr;
38 }
39 return Create<ImageFilter>(std::move(filter));
40 }
41
42 ScopedObject<ImageFilter> ImageFilter::MakeMatrix(
43 const Matrix& matrix,
44 flutter::DlImageSampling sampling) {
45 auto filter =
46 flutter::DlMatrixImageFilter::Make(ToSkMatrix(matrix), sampling);
47 if (!filter) {
48 return nullptr;
49 }
50 return Create<ImageFilter>(std::move(filter));
51 }
52
53 ScopedObject<ImageFilter> ImageFilter::MakeCompose(const ImageFilter& outer,
54 const ImageFilter& inner) {
55 auto filter = flutter::DlComposeImageFilter::Make(outer.GetImageFilter(),
56 inner.GetImageFilter());
57 if (!filter) {
58 return nullptr;
59 }
60 return Create<ImageFilter>(std::move(filter));
61 }
62
63 const std::shared_ptr<const flutter::DlImageFilter>&
64 ImageFilter::GetImageFilter() const {
65 return filter_;
66 }
67
68 } // namespace impeller::interop
impeller::Scalar
float Scalar
Definition: scalar.h:18
image_filter.h
impeller::interop::ImageFilter::MakeMatrix
static ScopedObject< ImageFilter > MakeMatrix(const Matrix &matrix, flutter::DlImageSampling sampling)
Definition: image_filter.cc:42
impeller::interop::ImageFilter::~ImageFilter
~ImageFilter() override
impeller::interop::ScopedObject
Definition: object.h:67
impeller::interop
Definition: color_filter.cc:7
impeller::interop::ImageFilter::ImageFilter
ImageFilter(std::shared_ptr< const flutter::DlImageFilter > filter)
Definition: image_filter.cc:9
impeller::interop::ImageFilter::MakeErode
static ScopedObject< ImageFilter > MakeErode(Scalar x_radius, Scalar y_radius)
Definition: image_filter.cc:33
impeller::interop::ImageFilter
Definition: image_filter.h:15
std
Definition: comparable.h:95
impeller::interop::ImageFilter::GetImageFilter
const std::shared_ptr< const flutter::DlImageFilter > & GetImageFilter() const
Definition: image_filter.cc:64
impeller::interop::ToSkMatrix
constexpr SkMatrix ToSkMatrix(const Matrix &matrix)
Definition: formats.h:81
impeller::interop::ImageFilter::MakeDilate
static ScopedObject< ImageFilter > MakeDilate(Scalar x_radius, Scalar y_radius)
Definition: image_filter.cc:24
impeller::interop::ImageFilter::MakeBlur
static ScopedObject< ImageFilter > MakeBlur(Scalar x_sigma, Scalar y_sigma, flutter::DlTileMode tile_mode)
Definition: image_filter.cc:14
impeller::Matrix
A 4x4 matrix using column-major storage.
Definition: matrix.h:37
impeller::interop::ImageFilter::MakeCompose
static ScopedObject< ImageFilter > MakeCompose(const ImageFilter &outer, const ImageFilter &inner)
Definition: image_filter.cc:53