Flutter Engine
flutter::ImageShader Class Reference

#include <image_shader.h>

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

Public Member Functions

 ~ImageShader () override
 
void initWithImage (CanvasImage *image, SkTileMode tmx, SkTileMode tmy, int filter_quality_index, const tonic::Float64List &matrix4)
 
sk_sp< SkShader > shader (SkSamplingOptions) override
 
- Public Member Functions inherited from flutter::Shader
 ~Shader () override
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< Shader >
virtual void RetainDartWrappableReference () const override
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< Shader >
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< ImageShaderCreate ()
 
static void RegisterNatives (tonic::DartLibraryNatives *natives)
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields {
  kPeerIndex,
  kNumberOfNativeFields
}
 
- Protected Member Functions inherited from flutter::Shader
 Shader ()
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< Shader >
 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 23 of file image_shader.h.

Constructor & Destructor Documentation

◆ ~ImageShader()

flutter::ImageShader::~ImageShader ( )
overridedefault

Referenced by shader().

Member Function Documentation

◆ Create()

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

Definition at line 34 of file image_shader.cc.

Referenced by flutter::ImageShader_constructor().

34  {
35  return fml::MakeRefCounted<ImageShader>();
36 }

◆ initWithImage()

void flutter::ImageShader::initWithImage ( CanvasImage image,
SkTileMode  tmx,
SkTileMode  tmy,
int  filter_quality_index,
const tonic::Float64List &  matrix4 
)

Definition at line 38 of file image_shader.cc.

References flutter::UIDartState::CreateGPUObject(), flutter::CanvasImage::image(), flutter::ImageFilter::SamplingFromIndex(), tonic::ToDart(), and flutter::ToSkMatrix().

42  {
43  if (!image) {
44  Dart_ThrowException(
45  ToDart("ImageShader constructor called with non-genuine Image."));
46  return;
47  }
48  sk_image_ = UIDartState::CreateGPUObject(image->image());
49  tmx_ = tmx;
50  tmy_ = tmy;
51  local_matrix_ = ToSkMatrix(matrix4);
52  if (filter_quality_index >= 0) {
53  cached_sampling_ = ImageFilter::SamplingFromIndex(filter_quality_index);
54  sampling_is_locked_ = true;
55  } else {
56  sampling_is_locked_ = false;
57  }
58 }
static SkSamplingOptions SamplingFromIndex(int filterQualityIndex)
Definition: image_filter.cc:50
Dart_Handle ToDart(const T &object)
SkMatrix ToSkMatrix(const tonic::Float64List &matrix4)
Definition: matrix.cc:20
static flutter::SkiaGPUObject< T > CreateGPUObject(sk_sp< T > object)

◆ RegisterNatives()

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

Definition at line 28 of file image_shader.cc.

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

Referenced by flutter::DartUI::InitForGlobal().

28  {
29  natives->Register(
30  {{"ImageShader_constructor", ImageShader_constructor, 1, true},
32 }
static void ImageShader_constructor(Dart_NativeArguments args)
Definition: image_shader.cc:18
void Register(std::initializer_list< Entry > entries)
#define DART_REGISTER_NATIVE(CLASS, METHOD)
#define FOR_EACH_BINDING(V)
Definition: image_shader.cc:24

◆ shader()

sk_sp< SkShader > flutter::ImageShader::shader ( SkSamplingOptions  sampling)
overridevirtual

Implements flutter::Shader.

Definition at line 60 of file image_shader.cc.

References flutter::UIDartState::CreateGPUObject(), flutter::SkiaGPUObject< T >::skia_object(), and ~ImageShader().

60  {
61  if (sampling_is_locked_) {
62  sampling = cached_sampling_;
63  }
64  if (!cached_shader_.skia_object() || cached_sampling_ != sampling) {
65  cached_sampling_ = sampling;
66  cached_shader_ =
67  UIDartState::CreateGPUObject(sk_image_.skia_object()->makeShader(
68  tmx_, tmy_, sampling, &local_matrix_));
69  }
70  return cached_shader_.skia_object();
71 }
sk_sp< SkiaObjectType > skia_object() const
static flutter::SkiaGPUObject< T > CreateGPUObject(sk_sp< T > object)

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