Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
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::DlImageSkia impeller::DlImageImpeller flutter::DlDeferredImageGPUSkia flutter::DlImageGPU Skwasm::DlWimpImageBase flutter::DlDeferredImageGPUImpeller flutter::PixelDeferredImageGPUImpeller impeller::DlImageImpellerTexture Skwasm::DlWimpImageFromPicture Skwasm::DlWimpImageFromPixels Skwasm::DlWimpImageFromTexture

Public Types

enum class  OwningContext {
  kRaster ,
  kIO
}
 
enum class  Type {
  kSkia ,
  kImpeller
}
 The backend type of this image. More...
 

Public Member Functions

virtual ~DlImage ()
 
virtual Type GetImageType () const =0
 Returns the backend type of this image.
 
virtual const DlImageSkiaasSkiaImage () const
 Safe downcast to DlImageSkia.
 
virtual const impeller::DlImageImpellerasImpellerImage () const
 Safe downcast to DlImageImpeller.
 
virtual bool isTextureBacked () const =0
 Returns true if the image is backed by a GPU texture.
 
virtual DlColorSpace GetColorSpace () const =0
 Gets the color space of the image.
 
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 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
 

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 34 of file dl_image.h.

Member Enumeration Documentation

◆ OwningContext

Enumerator
kRaster 
kIO 

Definition at line 37 of file dl_image.h.

◆ Type

enum class flutter::DlImage::Type
strong

The backend type of this image.

Enumerator
kSkia 
kImpeller 

Definition at line 44 of file dl_image.h.

Constructor & Destructor Documentation

◆ ~DlImage()

flutter::DlImage::~DlImage ( )
virtualdefault

◆ DlImage()

flutter::DlImage::DlImage ( )
protecteddefault

Member Function Documentation

◆ asImpellerImage()

virtual const impeller::DlImageImpeller * flutter::DlImage::asImpellerImage ( ) const
inlinevirtual

Safe downcast to DlImageImpeller.

Returns
A pointer to DlImageImpeller or null if not an Impeller image.

Reimplemented in impeller::DlImageImpeller.

Definition at line 65 of file dl_image.h.

65 {
66 return nullptr;
67 }

◆ asSkiaImage()

virtual const DlImageSkia * flutter::DlImage::asSkiaImage ( ) const
inlinevirtual

Safe downcast to DlImageSkia.

Returns
A pointer to DlImageSkia or null if not a Skia image.

Reimplemented in flutter::DlImageSkia.

Definition at line 58 of file dl_image.h.

58{ return nullptr; }

Referenced by Equals().

◆ Equals() [1/3]

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

Definition at line 145 of file dl_image.h.

145{ return Equals(&other); }
bool Equals(const DlImage *other) const
Definition dl_image.cc:31

References Equals().

Referenced by Equals().

◆ Equals() [2/3]

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

Definition at line 31 of file dl_image.cc.

31 {
32 if (!other) {
33 return false;
34 }
35 if (this == other) {
36 return true;
37 }
38
39 auto skia_this = asSkiaImage();
40 auto skia_other = other->asSkiaImage();
41 if (!skia_this || !skia_other) {
42 // Impeller images have pointer equality (handled by this == other)
43 return false;
44 }
45 return skia_this->skia_image() == skia_other->skia_image();
46}
virtual const DlImageSkia * asSkiaImage() const
Safe downcast to DlImageSkia.
Definition dl_image.h:58

References asSkiaImage(), and flutter::DlImageSkia::skia_image().

Referenced by Equals().

◆ Equals() [3/3]

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

Definition at line 147 of file dl_image.h.

147 {
148 return Equals(other.get());
149 }

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, and flutter::PixelDeferredImageGPUImpeller.

Definition at line 27 of file dl_image.cc.

27 {
28 return std::nullopt;
29}

◆ 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::DlImageImpellerTexture, flutter::DlDeferredImageGPUImpeller, flutter::DlDeferredImageGPUSkia, flutter::DlImageGPU, flutter::PixelDeferredImageGPUImpeller, and Skwasm::DlWimpImageBase.

◆ 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 23 of file dl_image.cc.

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

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

◆ GetColorSpace()

virtual DlColorSpace flutter::DlImage::GetColorSpace ( ) const
pure virtual

◆ GetImageType()

virtual Type flutter::DlImage::GetImageType ( ) const
pure virtual

Returns the backend type of this image.

Returns
The image type.

Implemented in flutter::DlImageSkia, and impeller::DlImageImpeller.

◆ 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 19 of file dl_image.cc.

19 {
20 return GetSize().height;
21};
Type height
Definition size.h:29

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

◆ 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::DlImageImpellerTexture, flutter::DlDeferredImageGPUImpeller, flutter::DlDeferredImageGPUSkia, flutter::DlImageGPU, flutter::PixelDeferredImageGPUImpeller, and Skwasm::DlWimpImageBase.

◆ isTextureBacked()

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

Returns true if the image is backed by a GPU texture.

Implemented in flutter::DlImageSkia, and impeller::DlImageImpeller.

◆ 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::DlImageImpellerTexture, flutter::DlDeferredImageGPUImpeller, flutter::DlDeferredImageGPUSkia, flutter::DlImageGPU, flutter::PixelDeferredImageGPUImpeller, and Skwasm::DlWimpImageBase.

◆ 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::DlImageImpellerTexture, flutter::DlDeferredImageGPUImpeller, and flutter::DlDeferredImageGPUSkia.

Definition at line 136 of file dl_image.h.

136{ return OwningContext::kIO; }

References kIO.

Referenced by impeller::DlImageImpeller::Make().

◆ width()

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

Definition at line 15 of file dl_image.cc.

15 {
16 return GetSize().width;
17};
Type width
Definition size.h:28

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


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