Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
impeller::CompressedImageSkia Class Referencefinal

#include <compressed_image_skia.h>

Inheritance diagram for impeller::CompressedImageSkia:
impeller::CompressedImage

Public Member Functions

 CompressedImageSkia (std::shared_ptr< const fml::Mapping > allocation)
 
 ~CompressedImageSkia () override
 
DecompressedImage Decode () const override
 
- Public Member Functions inherited from impeller::CompressedImage
virtual ~CompressedImage ()
 
virtual DecompressedImage Decode () const =0
 
bool IsValid () const
 

Static Public Member Functions

static std::shared_ptr< CompressedImageCreate (std::shared_ptr< const fml::Mapping > allocation)
 

Additional Inherited Members

- Protected Member Functions inherited from impeller::CompressedImage
 CompressedImage (std::shared_ptr< const fml::Mapping > allocation)
 
- Protected Attributes inherited from impeller::CompressedImage
const std::shared_ptr< const fml::Mappingsource_
 

Detailed Description

Definition at line 12 of file compressed_image_skia.h.

Constructor & Destructor Documentation

◆ CompressedImageSkia()

impeller::CompressedImageSkia::CompressedImageSkia ( std::shared_ptr< const fml::Mapping allocation)
explicit

Definition at line 27 of file compressed_image_skia.cc.

29 : CompressedImage(std::move(allocation)) {}
CompressedImage(std::shared_ptr< const fml::Mapping > allocation)

◆ ~CompressedImageSkia()

impeller::CompressedImageSkia::~CompressedImageSkia ( )
overridedefault

Member Function Documentation

◆ Create()

std::shared_ptr< CompressedImage > impeller::CompressedImageSkia::Create ( std::shared_ptr< const fml::Mapping allocation)
static

Definition at line 18 of file compressed_image_skia.cc.

19 {
20 // There is only one backend today.
21 if (!allocation) {
22 return nullptr;
23 }
24 return std::make_shared<CompressedImageSkia>(std::move(allocation));
25}

◆ Decode()

DecompressedImage impeller::CompressedImageSkia::Decode ( ) const
overridevirtual

Implements impeller::CompressedImage.

Definition at line 34 of file compressed_image_skia.cc.

34 {
35 if (!IsValid()) {
36 return {};
37 }
38 if (source_->GetSize() == 0u) {
39 return {};
40 }
41
42 auto src = new std::shared_ptr<const fml::Mapping>(source_);
43 auto sk_data = SkData::MakeWithProc(
44 source_->GetMapping(), source_->GetSize(),
45 [](const void* ptr, void* context) {
46 delete reinterpret_cast<decltype(src)>(context);
47 },
48 src);
49
51 if (!image) {
52 return {};
53 }
54
55 const auto dims = image->imageInfo().dimensions();
56 auto info = SkImageInfo::Make(dims.width(), dims.height(),
58
59 auto bitmap = std::make_shared<SkBitmap>();
60 if (!bitmap->tryAllocPixels(info)) {
61 VALIDATION_LOG << "Could not allocate arena for decompressing image.";
62 return {};
63 }
64
65 if (!image->readPixels(nullptr, bitmap->pixmap(), 0, 0)) {
66 VALIDATION_LOG << "Could not decompress image into arena.";
67 return {};
68 }
69
70 auto mapping = std::make_shared<fml::NonOwnedMapping>(
71 reinterpret_cast<const uint8_t*>(bitmap->pixmap().addr()), // data
72 bitmap->pixmap().rowBytes() * bitmap->pixmap().height(), // size
73 [bitmap](const uint8_t* data, size_t size) mutable {
74 bitmap.reset();
75 } // proc
76 );
77
78 return {
79 {bitmap->pixmap().dimensions().fWidth,
80 bitmap->pixmap().dimensions().fHeight}, // size
82 mapping // allocation
83 };
84}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
Definition: SkAlphaType.h:29
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
Definition: SkColorType.h:24
static sk_sp< SkData > MakeWithProc(const void *ptr, size_t length, ReleaseProc proc, void *ctx)
Definition: SkData.cpp:128
const SkImageInfo & imageInfo() const
Definition: SkImage.h:279
bool readPixels(GrDirectContext *context, const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY, CachingHint cachingHint=kAllow_CachingHint) const
Definition: SkImage.cpp:42
const std::shared_ptr< const fml::Mapping > source_
SK_API sk_sp< SkImage > DeferredFromEncodedData(sk_sp< SkData > encoded, std::optional< SkAlphaType > alphaType=std::nullopt)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
Definition: bitmap.py:1
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
SkISize dimensions() const
Definition: SkImageInfo.h:421
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63
#define VALIDATION_LOG
Definition: validation.h:73

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