Flutter Engine
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/lib/ui/painting/image_filter.h"
6 
7 #include "flutter/lib/ui/painting/matrix.h"
8 #include "third_party/skia/include/effects/SkBlurImageFilter.h"
9 #include "third_party/skia/include/effects/SkImageSource.h"
10 #include "third_party/skia/include/effects/SkPictureImageFilter.h"
15 
16 namespace flutter {
17 
18 static void ImageFilter_constructor(Dart_NativeArguments args) {
21 }
22 
24 
25 #define FOR_EACH_BINDING(V) \
26  V(ImageFilter, initImage) \
27  V(ImageFilter, initPicture) \
28  V(ImageFilter, initBlur) \
29  V(ImageFilter, initMatrix)
30 
32 
33 void ImageFilter::RegisterNatives(tonic::DartLibraryNatives* natives) {
34  natives->Register(
35  {{"ImageFilter_constructor", ImageFilter_constructor, 1, true},
37 }
38 
40  return fml::MakeRefCounted<ImageFilter>();
41 }
42 
43 ImageFilter::ImageFilter() {}
44 
46 
48  filter_ = SkImageSource::Make(image->image());
49 }
50 
52  filter_ = SkPictureImageFilter::Make(picture->picture());
53 }
54 
55 void ImageFilter::initBlur(double sigma_x, double sigma_y) {
56  filter_ = SkBlurImageFilter::Make(sigma_x, sigma_y, nullptr, nullptr,
57  SkBlurImageFilter::kClamp_TileMode);
58 }
59 
60 void ImageFilter::initMatrix(const tonic::Float64List& matrix4,
61  int filterQuality) {
62  filter_ = SkImageFilter::MakeMatrixFilter(
63  ToSkMatrix(matrix4), static_cast<SkFilterQuality>(filterQuality),
64  nullptr);
65 }
66 
67 } // namespace flutter
G_BEGIN_DECLS FlValue * args
void DartCallConstructor(Sig func, Dart_NativeArguments args)
Definition: dart_args.h:218
void initImage(CanvasImage *image)
Definition: image_filter.cc:47
sk_sp< SkPicture > picture() const
Definition: picture.h:30
void initBlur(double sigma_x, double sigma_y)
Definition: image_filter.cc:55
#define DART_NATIVE_CALLBACK(CLASS, METHOD)
~ImageFilter() override
Definition: image_filter.cc:45
static fml::RefPtr< ImageFilter > Create()
Definition: image_filter.cc:39
IMPLEMENT_WRAPPERTYPEINFO(ui, Scene)
static void ThrowIfUIOperationsProhibited()
static void ImageFilter_constructor(Dart_NativeArguments args)
Definition: image_filter.cc:18
void initPicture(Picture *)
Definition: image_filter.cc:51
#define DART_REGISTER_NATIVE(CLASS, METHOD)
#define FOR_EACH_BINDING(V)
Definition: image_filter.cc:25
SkMatrix ToSkMatrix(const tonic::Float64List &matrix4)
Definition: matrix.cc:20
sk_sp< SkImage > image() const
Definition: image.h:37
void initMatrix(const tonic::Float64List &matrix4, int filter_quality)
Definition: image_filter.cc:60