Flutter Engine
flutter::CanvasImage Class Referencefinal

#include <image.h>

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

Public Member Functions

 ~CanvasImage () override
 
int width ()
 
int height ()
 
Dart_Handle toByteData (int format, Dart_Handle callback)
 
void dispose ()
 
sk_sp< SkImage > image () const
 
void set_image (flutter::SkiaGPUObject< SkImage > image)
 
size_t GetAllocationSize () const override
 
- Public Member Functions inherited from flutter::RefCountedDartWrappable< CanvasImage >
virtual void RetainDartWrappableReference () const override
 
virtual void ReleaseDartWrappableReference () const override
 
- Public Member Functions inherited from fml::RefCountedThreadSafe< CanvasImage >
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
 
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< CanvasImageCreate ()
 
static void RegisterNatives (tonic::DartLibraryNatives *natives)
 

Additional Inherited Members

- Public Types inherited from tonic::DartWrappable
enum  DartNativeFields {
  kPeerIndex,
  kWrapperInfoIndex,
  kNumberOfNativeFields
}
 
- Protected Member Functions inherited from fml::RefCountedThreadSafe< CanvasImage >
 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 19 of file image.h.

Constructor & Destructor Documentation

◆ ~CanvasImage()

flutter::CanvasImage::~CanvasImage ( )
overridedefault

Referenced by RegisterNatives().

Member Function Documentation

◆ Create()

static fml::RefPtr<CanvasImage> flutter::CanvasImage::Create ( )
inlinestatic

Definition at line 25 of file image.h.

Referenced by flutter::CopyToBitmap(), and flutter::Picture::RasterizeToImage().

25  {
26  return fml::MakeRefCounted<CanvasImage>();
27  }

◆ dispose()

void flutter::CanvasImage::dispose ( )

Definition at line 46 of file image.cc.

References tonic::DartWrappable::ClearDartWrapper(), flutter::UIDartState::Current(), GetAllocationSize(), flutter::UIDartState::GetHintFreedDelegate(), and flutter::SkiaGPUObject< T >::reset().

46  {
47  auto hint_freed_delegate = UIDartState::Current()->GetHintFreedDelegate();
48  if (hint_freed_delegate) {
49  hint_freed_delegate->HintFreed(GetAllocationSize());
50  }
51  image_.reset();
53 }
size_t GetAllocationSize() const override
Definition: image.cc:55
fml::WeakPtr< HintFreedDelegate > GetHintFreedDelegate() const
static UIDartState * Current()

◆ GetAllocationSize()

size_t flutter::CanvasImage::GetAllocationSize ( ) const
overridevirtual

Reimplemented from tonic::DartWrappable.

Definition at line 55 of file image.cc.

References flutter::SkiaGPUObject< T >::get(), and image().

Referenced by dispose().

55  {
56  if (auto image = image_.get()) {
57  const auto& info = image->imageInfo();
58  const auto kMipmapOverhead = 4.0 / 3.0;
59  const size_t image_byte_size = info.computeMinByteSize() * kMipmapOverhead;
60  return image_byte_size + sizeof(this);
61  } else {
62  return sizeof(CanvasImage);
63  }
64 }
sk_sp< SkiaObjectType > get() const
sk_sp< SkImage > image() const
Definition: image.h:37

◆ height()

int flutter::CanvasImage::height ( )
inline

Definition at line 31 of file image.h.

31 { return image_.get()->height(); }
sk_sp< SkiaObjectType > get() const

◆ image()

◆ RegisterNatives()

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

Definition at line 34 of file image.cc.

References DART_REGISTER_NATIVE, FOR_EACH_BINDING, and ~CanvasImage().

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

34  {
36 }
void Register(std::initializer_list< Entry > entries)
#define FOR_EACH_BINDING(V)
Definition: image.cc:26
#define DART_REGISTER_NATIVE(CLASS, METHOD)

◆ set_image()

void flutter::CanvasImage::set_image ( flutter::SkiaGPUObject< SkImage >  image)
inline

Definition at line 38 of file image.h.

38  {
39  image_ = std::move(image);
40  }

◆ toByteData()

Dart_Handle flutter::CanvasImage::toByteData ( int  format,
Dart_Handle  callback 
)

Definition at line 42 of file image.cc.

References flutter::EncodeImage().

42  {
43  return EncodeImage(this, format, callback);
44 }
Dart_Handle EncodeImage(CanvasImage *canvas_image, int format, Dart_Handle callback_handle)

◆ width()

int flutter::CanvasImage::width ( )
inline

Definition at line 29 of file image.h.

29 { return image_.get()->width(); }
sk_sp< SkiaObjectType > get() const

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