Flutter Engine
flutter::ImageFilter Class Reference

#include <image_filter.h>

Inheritance diagram for flutter::ImageFilter:
flutter::RefCountedDartWrappable< ImageFilter > fml::RefCountedThreadSafe< ImageFilter > tonic::DartWrappable fml::internal::RefCountedThreadSafeBase

Public Member Functions

 ~ImageFilter () override
 
void initImage (CanvasImage *image)
 
void initPicture (Picture *)
 
void initBlur (double sigma_x, double sigma_y, SkTileMode tile_mode)
 
void initMatrix (const tonic::Float64List &matrix4, int filter_quality_index)
 
void initColorFilter (ColorFilter *colorFilter)
 
void initComposeFilter (ImageFilter *outer, ImageFilter *inner)
 
const sk_sp< SkImageFilter > & filter () const
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< ImageFilter >
virtual void RetainDartWrappableReference () const override
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< ImageFilter >
void Release () const
 
- Public Member Functions inherited from fml::internal::RefCountedThreadSafeBase
void AddRef () const
 
bool HasOneRef () const
 
void AssertHasOneRef () const
 
- Public Member Functions inherited from tonic::DartWrappable
 DartWrappable ()
 
virtual const DartWrapperInfoGetDartWrapperInfo () const =0
 
virtual size_t GetAllocationSize () const
 
Dart_Handle CreateDartWrapper (DartState *dart_state)
 
void AssociateWithDartWrapper (Dart_Handle wrappable)
 
void ClearDartWrapper ()
 
Dart_WeakPersistentHandle dart_wrapper () const
 

Static Public Member Functions

static fml::RefPtr< ImageFilterCreate ()
 
static SkSamplingOptions SamplingFromIndex (int filterQualityIndex)
 
static SkFilterMode FilterModeFromIndex (int index)
 
static void RegisterNatives (tonic::DartLibraryNatives *natives)
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields {
  kPeerIndex,
  kNumberOfNativeFields
}
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< ImageFilter >
 RefCountedThreadSafe ()
 
 ~RefCountedThreadSafe ()
 
- Protected Member Functions inherited from fml::internal::RefCountedThreadSafeBase
 RefCountedThreadSafeBase ()
 
 ~RefCountedThreadSafeBase ()
 
bool Release () const
 
void Adopt ()
 
- Protected Member Functions inherited from tonic::DartWrappable
virtual ~DartWrappable ()
 
- Static Protected Member Functions inherited from tonic::DartWrappable
static Dart_PersistentHandle GetTypeForWrapper (tonic::DartState *dart_state, const tonic::DartWrapperInfo &wrapper_info)
 

Detailed Description

Definition at line 17 of file image_filter.h.

Constructor & Destructor Documentation

◆ ~ImageFilter()

flutter::ImageFilter::~ImageFilter ( )
override

Definition at line 70 of file image_filter.cc.

70 {}

Member Function Documentation

◆ Create()

fml::RefPtr< ImageFilter > flutter::ImageFilter::Create ( )
static

Definition at line 39 of file image_filter.cc.

Referenced by flutter::ImageFilter_constructor().

39  {
40  return fml::MakeRefCounted<ImageFilter>();
41 }

◆ filter()

const sk_sp<SkImageFilter>& flutter::ImageFilter::filter ( ) const
inline

◆ FilterModeFromIndex()

SkFilterMode flutter::ImageFilter::FilterModeFromIndex ( int  index)
static

Definition at line 61 of file image_filter.cc.

Referenced by flutter::Canvas::drawImageNine().

61  {
62  if (filterQualityIndex <= 0) {
63  return SkFilterMode::kNearest;
64  }
65  return SkFilterMode::kLinear;
66 }

◆ initBlur()

void flutter::ImageFilter::initBlur ( double  sigma_x,
double  sigma_y,
SkTileMode  tile_mode 
)

Definition at line 80 of file image_filter.cc.

References flutter::Blur.

82  {
83  filter_ = SkImageFilters::Blur(sigma_x, sigma_y, tile_mode, nullptr, nullptr);
84 }

◆ initColorFilter()

void flutter::ImageFilter::initColorFilter ( ColorFilter colorFilter)

Definition at line 93 of file image_filter.cc.

References flutter::ColorFilter::filter().

93  {
94  filter_ = SkImageFilters::ColorFilter(
95  colorFilter ? colorFilter->filter() : nullptr, nullptr);
96 }

◆ initComposeFilter()

void flutter::ImageFilter::initComposeFilter ( ImageFilter outer,
ImageFilter inner 
)

Definition at line 98 of file image_filter.cc.

References filter().

98  {
99  filter_ = SkImageFilters::Compose(outer ? outer->filter() : nullptr,
100  inner ? inner->filter() : nullptr);
101 }

◆ initImage()

void flutter::ImageFilter::initImage ( CanvasImage image)

Definition at line 72 of file image_filter.cc.

References flutter::CanvasImage::image().

72  {
73  filter_ = SkImageFilters::Image(image->image());
74 }
CanvasImage Image
Definition: image.cc:15

◆ initMatrix()

void flutter::ImageFilter::initMatrix ( const tonic::Float64List &  matrix4,
int  filter_quality_index 
)

Definition at line 86 of file image_filter.cc.

References SamplingFromIndex(), and flutter::ToSkMatrix().

87  {
88  auto sampling = ImageFilter::SamplingFromIndex(filterQualityIndex);
89  filter_ =
90  SkImageFilters::MatrixTransform(ToSkMatrix(matrix4), sampling, nullptr);
91 }
static SkSamplingOptions SamplingFromIndex(int filterQualityIndex)
Definition: image_filter.cc:50
SkMatrix ToSkMatrix(const tonic::Float64List &matrix4)
Definition: matrix.cc:20

◆ initPicture()

void flutter::ImageFilter::initPicture ( Picture picture)

Definition at line 76 of file image_filter.cc.

References flutter::Picture::picture().

76  {
77  filter_ = SkImageFilters::Picture(picture->picture());
78 }

◆ RegisterNatives()

void flutter::ImageFilter::RegisterNatives ( tonic::DartLibraryNatives natives)
static

Definition at line 33 of file image_filter.cc.

References DART_REGISTER_NATIVE, FOR_EACH_BINDING, and flutter::ImageFilter_constructor().

Referenced by filter(), and flutter::DartUI::InitForGlobal().

33  {
34  natives->Register(
35  {{"ImageFilter_constructor", ImageFilter_constructor, 1, true},
37 }
void Register(std::initializer_list< Entry > entries)
static void ImageFilter_constructor(Dart_NativeArguments args)
Definition: image_filter.cc:16
#define DART_REGISTER_NATIVE(CLASS, METHOD)
#define FOR_EACH_BINDING(V)
Definition: image_filter.cc:23

◆ SamplingFromIndex()

SkSamplingOptions flutter::ImageFilter::SamplingFromIndex ( int  filterQualityIndex)
static

Definition at line 50 of file image_filter.cc.

Referenced by flutter::SceneBuilder::addTexture(), flutter::Canvas::drawAtlas(), flutter::Canvas::drawImage(), flutter::Canvas::drawImageRect(), initMatrix(), flutter::ImageShader::initWithImage(), flutter::Paint::paint(), flutter::SceneBuilder::pushShaderMask(), and flutter::Paint::sync_to().

50  {
51  if (filterQualityIndex < 0) {
52  return filter_qualities.front();
53  } else if (static_cast<size_t>(filterQualityIndex) >=
54  filter_qualities.size()) {
55  return filter_qualities.back();
56  } else {
57  return filter_qualities[filterQualityIndex];
58  }
59 }
static const std::array< SkSamplingOptions, 4 > filter_qualities
Definition: image_filter.cc:43

The documentation for this class was generated from the following files: