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