Flutter Engine
 
Loading...
Searching...
No Matches
flutter::DlImage Class Referenceabstract

Represents an image whose allocation is (usually) resident on device memory. More...

#include <dl_image.h>

Inheritance diagram for flutter::DlImage:
flutter::DlDeferredImageGPUImpeller flutter::DlDeferredImageGPUSkia flutter::DlImageGPU flutter::DlImageSkia impeller::DlImageImpeller

Public Types

enum class  OwningContext {
  kRaster ,
  kIO
}
 

Public Member Functions

virtual ~DlImage ()
 
virtual sk_sp< SkImage > skia_image () const =0
 If this display list image is meant to be used by the Skia backend, an SkImage instance. Null otherwise.
 
virtual std::shared_ptr< impeller::Textureimpeller_texture () const =0
 If this display list image is meant to be used by the Impeller backend, an Impeller texture instance. Null otherwise.
 
virtual bool isOpaque () const =0
 If the pixel format of this image ignores alpha, this returns true. This method might conservatively return false when it cannot guarnatee an opaque image, for example when the pixel format of the image supports alpha but the image is made up of entirely opaque pixels.
 
virtual bool isTextureBacked () const =0
 
virtual bool isUIThreadSafe () const =0
 If the underlying platform image held by this object has no threading requirements for the release of that image (or if arrangements have already been made to forward that image to the correct thread upon deletion), this method returns true.
 
virtual DlISize GetSize () const =0
 
virtual size_t GetApproximateByteSize () const =0
 
int width () const
 
int height () const
 
DlIRect GetBounds () const
 
virtual OwningContext owning_context () const
 
virtual std::optional< std::string > get_error () const
 
bool Equals (const DlImage *other) const
 
bool Equals (const DlImage &other) const
 
bool Equals (const sk_sp< const DlImage > &other) const
 

Static Public Member Functions

static sk_sp< DlImageMake (const SkImage *image)
 
static sk_sp< DlImageMake (sk_sp< SkImage > image)
 

Protected Member Functions

 DlImage ()
 

Detailed Description

Represents an image whose allocation is (usually) resident on device memory.

Since it is usually impossible or expensive to transmute images for one rendering backend to another, these objects are backend specific.

Definition at line 32 of file dl_image.h.

Member Enumeration Documentation

◆ OwningContext

Enumerator
kRaster 
kIO 

Definition at line 35 of file dl_image.h.

Constructor & Destructor Documentation

◆ ~DlImage()

flutter::DlImage::~DlImage ( )
virtualdefault

◆ DlImage()

flutter::DlImage::DlImage ( )
protecteddefault

Member Function Documentation

◆ Equals() [1/3]

bool flutter::DlImage::Equals ( const DlImage other) const
inline

Definition at line 138 of file dl_image.h.

138{ return Equals(&other); }
bool Equals(const DlImage *other) const
Definition dl_image.h:127

References Equals().

Referenced by Equals().

◆ Equals() [2/3]

bool flutter::DlImage::Equals ( const DlImage other) const
inline

Definition at line 127 of file dl_image.h.

127 {
128 if (!other) {
129 return false;
130 }
131 if (this == other) {
132 return true;
133 }
134 return skia_image() == other->skia_image() &&
135 impeller_texture() == other->impeller_texture();
136 }
virtual std::shared_ptr< impeller::Texture > impeller_texture() const =0
If this display list image is meant to be used by the Impeller backend, an Impeller texture instance....
virtual sk_sp< SkImage > skia_image() const =0
If this display list image is meant to be used by the Skia backend, an SkImage instance....

References impeller_texture(), and skia_image().

Referenced by Equals().

◆ Equals() [3/3]

bool flutter::DlImage::Equals ( const sk_sp< const DlImage > &  other) const
inline

Definition at line 140 of file dl_image.h.

140 {
141 return Equals(other.get());
142 }

References Equals().

◆ get_error()

std::optional< std::string > flutter::DlImage::get_error ( ) const
virtual
Returns
An error, if any, that occurred when trying to create the image.

Reimplemented in flutter::DlDeferredImageGPUSkia.

Definition at line 35 of file dl_image.cc.

35 {
36 return std::nullopt;
37}

◆ GetApproximateByteSize()

virtual size_t flutter::DlImage::GetApproximateByteSize ( ) const
pure virtual
Returns
The approximate byte size of the allocation of this image. This takes into account details such as mip-mapping. The allocation is usually resident in device memory.

Implemented in flutter::DlImageSkia, impeller::DlImageImpeller, flutter::DlDeferredImageGPUImpeller, flutter::DlDeferredImageGPUSkia, and flutter::DlImageGPU.

◆ GetBounds()

DlIRect flutter::DlImage::GetBounds ( ) const
Returns
The bounds of the pixel grid with 0, 0 as origin. A convenience method that calls |DlImage::dimensions|.

Definition at line 31 of file dl_image.cc.

31 {
32 return DlIRect::MakeSize(GetSize());
33}
virtual DlISize GetSize() const =0
static constexpr TRect MakeSize(const TSize< U > &size)
Definition rect.h:150

References GetSize(), and impeller::TRect< T >::MakeSize().

◆ GetSize()

virtual DlISize flutter::DlImage::GetSize ( ) const
pure virtual

◆ height()

int flutter::DlImage::height ( ) const
Returns
The height of the pixel grid. A convenience method that calls |DlImage::dimensions|.

Definition at line 27 of file dl_image.cc.

27 {
28 return GetSize().height;
29};
Type height
Definition size.h:29

References GetSize(), and impeller::TSize< T >::height.

◆ impeller_texture()

virtual std::shared_ptr< impeller::Texture > flutter::DlImage::impeller_texture ( ) const
pure virtual

If this display list image is meant to be used by the Impeller backend, an Impeller texture instance. Null otherwise.

Returns
An Impeller texture instance or null.

Implemented in flutter::DlImageSkia, impeller::DlImageImpeller, flutter::DlDeferredImageGPUImpeller, flutter::DlDeferredImageGPUSkia, and flutter::DlImageGPU.

Referenced by Equals().

◆ isOpaque()

virtual bool flutter::DlImage::isOpaque ( ) const
pure virtual

If the pixel format of this image ignores alpha, this returns true. This method might conservatively return false when it cannot guarnatee an opaque image, for example when the pixel format of the image supports alpha but the image is made up of entirely opaque pixels.

Returns
True if the pixel format of this image ignores alpha.

Implemented in flutter::DlImageSkia, impeller::DlImageImpeller, flutter::DlDeferredImageGPUImpeller, flutter::DlDeferredImageGPUSkia, and flutter::DlImageGPU.

◆ isTextureBacked()

virtual bool flutter::DlImage::isTextureBacked ( ) const
pure virtual

◆ isUIThreadSafe()

virtual bool flutter::DlImage::isUIThreadSafe ( ) const
pure virtual

If the underlying platform image held by this object has no threading requirements for the release of that image (or if arrangements have already been made to forward that image to the correct thread upon deletion), this method returns true.

Returns
True if the underlying image is held in a thread-safe manner.

Implemented in flutter::DlImageSkia, impeller::DlImageImpeller, flutter::DlDeferredImageGPUImpeller, flutter::DlDeferredImageGPUSkia, and flutter::DlImageGPU.

◆ Make() [1/2]

◆ Make() [2/2]

sk_sp< DlImage > flutter::DlImage::Make ( sk_sp< SkImage >  image)
static

Definition at line 15 of file dl_image.cc.

15 {
16 return sk_make_sp<DlImageSkia>(std::move(image));
17}

References image.

◆ owning_context()

virtual OwningContext flutter::DlImage::owning_context ( ) const
inlinevirtual
Returns
Specifies which context was used to create this image. The image must be collected on the same task runner as its context.

Reimplemented in impeller::DlImageImpeller, flutter::DlDeferredImageGPUImpeller, and flutter::DlDeferredImageGPUSkia.

Definition at line 116 of file dl_image.h.

116{ return OwningContext::kIO; }

References kIO.

◆ skia_image()

virtual sk_sp< SkImage > flutter::DlImage::skia_image ( ) const
pure virtual

If this display list image is meant to be used by the Skia backend, an SkImage instance. Null otherwise.

Returns
A Skia image instance or null.

Implemented in flutter::DlImageSkia, impeller::DlImageImpeller, flutter::DlDeferredImageGPUImpeller, flutter::DlDeferredImageGPUSkia, and flutter::DlImageGPU.

Referenced by Equals().

◆ width()

int flutter::DlImage::width ( ) const
Returns
The width of the pixel grid. A convenience method that calls |DlImage::dimensions|.

Definition at line 23 of file dl_image.cc.

23 {
24 return GetSize().width;
25};
Type width
Definition size.h:28

References GetSize(), and impeller::TSize< T >::width.


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