Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | List of all members
impeller::DecompressedImage Class Reference

#include <decompressed_image.h>

Public Types

enum class  Format {
  kInvalid , kGrey , kGreyAlpha , kRGB ,
  kRGBA
}
 

Public Member Functions

 DecompressedImage ()
 
 DecompressedImage (ISize size, Format format, std::shared_ptr< const fml::Mapping > allocation)
 
 ~DecompressedImage ()
 
const ISizeGetSize () const
 
bool IsValid () const
 
Format GetFormat () const
 
const std::shared_ptr< const fml::Mapping > & GetAllocation () const
 
DecompressedImage ConvertToRGBA () const
 

Detailed Description

Definition at line 15 of file decompressed_image.h.

Member Enumeration Documentation

◆ Format

Enumerator
kInvalid 
kGrey 
kGreyAlpha 
kRGB 
kRGBA 

Definition at line 17 of file decompressed_image.h.

17 {
19 kGrey,
20 kGreyAlpha,
21 kRGB,
22 kRGBA,
23 };
@ kInvalid
@ kRGBA
Definition: embedder.h:607

Constructor & Destructor Documentation

◆ DecompressedImage() [1/2]

impeller::DecompressedImage::DecompressedImage ( )
default

◆ DecompressedImage() [2/2]

impeller::DecompressedImage::DecompressedImage ( ISize  size,
Format  format,
std::shared_ptr< const fml::Mapping allocation 
)

Definition at line 16 of file decompressed_image.cc.

20 : size_(size), format_(format), allocation_(std::move(allocation)) {
21 if (!allocation_ || size.IsEmpty() || format_ == Format::kInvalid) {
22 return;
23 }
24 is_valid_ = true;
25}
uint32_t uint32_t * format
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
Definition: switches.h:259

◆ ~DecompressedImage()

impeller::DecompressedImage::~DecompressedImage ( )
default

Member Function Documentation

◆ ConvertToRGBA()

DecompressedImage impeller::DecompressedImage::ConvertToRGBA ( ) const

Definition at line 62 of file decompressed_image.cc.

62 {
63 if (!is_valid_) {
64 return {};
65 }
66
67 if (format_ == Format::kRGBA) {
68 return DecompressedImage{size_, format_, allocation_};
69 }
70
71 const auto bpp = GetBytesPerPixel(format_);
72 const auto source_byte_size = size_.Area() * bpp;
73 if (allocation_->GetSize() < source_byte_size) {
74 return {};
75 }
76
77 auto rgba_allocation = std::make_shared<Allocation>();
78 if (!rgba_allocation->Truncate(size_.Area() * 4u, false)) {
79 return {};
80 }
81
82 const uint8_t* source = allocation_->GetMapping();
83 uint8_t* dest = rgba_allocation->GetBuffer();
84
85 for (size_t i = 0, j = 0; i < source_byte_size; i += bpp, j += 4u) {
86 switch (format_) {
88 dest[j + 0] = source[i];
89 dest[j + 1] = source[i];
90 dest[j + 2] = source[i];
92 break;
97 dest[j + 3] = source[i];
98 break;
100 dest[j + 0] = source[i + 0];
101 dest[j + 1] = source[i + 1];
102 dest[j + 2] = source[i + 2];
104 break;
107 // Should never happen. The necessary checks have already been
108 // performed.
109 FML_CHECK(false);
110 break;
111 }
112 }
113
114 return DecompressedImage{
115 size_, Format::kRGBA,
116 std::make_shared<fml::NonOwnedMapping>(
117 rgba_allocation->GetBuffer(), //
118 rgba_allocation->GetLength(), //
119 [rgba_allocation](auto, auto) {}) //
120 };
121}
SkBitmap source
Definition: examples.cpp:28
#define FML_CHECK(condition)
Definition: logging.h:85
static float max(float r, float g, float b)
Definition: hsl.cpp:49
static size_t GetBytesPerPixel(DecompressedImage::Format format)
dest
Definition: zip.py:79
constexpr Type Area() const
Definition: size.h:102

◆ GetAllocation()

const std::shared_ptr< const fml::Mapping > & impeller::DecompressedImage::GetAllocation ( ) const

Definition at line 41 of file decompressed_image.cc.

42 {
43 return allocation_;
44}

◆ GetFormat()

DecompressedImage::Format impeller::DecompressedImage::GetFormat ( ) const

Definition at line 37 of file decompressed_image.cc.

37 {
38 return format_;
39}

◆ GetSize()

const ISize & impeller::DecompressedImage::GetSize ( ) const

Definition at line 33 of file decompressed_image.cc.

33 {
34 return size_;
35}

◆ IsValid()

bool impeller::DecompressedImage::IsValid ( ) const

Definition at line 29 of file decompressed_image.cc.

29 {
30 return is_valid_;
31}

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