Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Member Functions | List of all members
SkAutoPixmapStorage Class Reference

#include <SkAutoPixmapStorage.h>

Inheritance diagram for SkAutoPixmapStorage:
SkPixmap

Public Member Functions

 SkAutoPixmapStorage ()
 
 ~SkAutoPixmapStorage ()
 
 SkAutoPixmapStorage (SkAutoPixmapStorage &&other)
 
SkAutoPixmapStorageoperator= (SkAutoPixmapStorage &&other)
 
bool tryAlloc (const SkImageInfo &)
 
void alloc (const SkImageInfo &)
 
void * detachPixels ()
 
sk_sp< SkDatadetachPixelsAsData ()
 
void reset ()
 
void reset (const SkImageInfo &info, const void *addr, size_t rb)
 
bool reset (const SkMask &mask)
 
- Public Member Functions inherited from SkPixmap
 SkPixmap ()
 
 SkPixmap (const SkImageInfo &info, const void *addr, size_t rowBytes)
 
void reset ()
 
void reset (const SkImageInfo &info, const void *addr, size_t rowBytes)
 
void setColorSpace (sk_sp< SkColorSpace > colorSpace)
 
bool reset (const SkMask &mask)
 
bool extractSubset (SkPixmap *subset, const SkIRect &area) const
 
const SkImageInfoinfo () const
 
size_t rowBytes () const
 
const void * addr () const
 
int width () const
 
int height () const
 
SkISize dimensions () const
 
SkColorType colorType () const
 
SkAlphaType alphaType () const
 
SkColorSpacecolorSpace () const
 
sk_sp< SkColorSpacerefColorSpace () const
 
bool isOpaque () const
 
SkIRect bounds () const
 
int rowBytesAsPixels () const
 
int shiftPerPixel () const
 
size_t computeByteSize () const
 
bool computeIsOpaque () const
 
SkColor getColor (int x, int y) const
 
SkColor4f getColor4f (int x, int y) const
 
float getAlphaf (int x, int y) const
 
const void * addr (int x, int y) const
 
const uint8_t * addr8 () const
 
const uint16_t * addr16 () const
 
const uint32_t * addr32 () const
 
const uint64_t * addr64 () const
 
const uint16_t * addrF16 () const
 
const uint8_t * addr8 (int x, int y) const
 
const uint16_t * addr16 (int x, int y) const
 
const uint32_t * addr32 (int x, int y) const
 
const uint64_t * addr64 (int x, int y) const
 
const uint16_t * addrF16 (int x, int y) const
 
void * writable_addr () const
 
void * writable_addr (int x, int y) const
 
uint8_t * writable_addr8 (int x, int y) const
 
uint16_t * writable_addr16 (int x, int y) const
 
uint32_t * writable_addr32 (int x, int y) const
 
uint64_t * writable_addr64 (int x, int y) const
 
uint16_t * writable_addrF16 (int x, int y) const
 
bool readPixels (const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes) const
 
bool readPixels (const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY) const
 
bool readPixels (const SkPixmap &dst, int srcX, int srcY) const
 
bool readPixels (const SkPixmap &dst) const
 
bool scalePixels (const SkPixmap &dst, const SkSamplingOptions &) const
 
bool erase (SkColor color, const SkIRect &subset) const
 
bool erase (SkColor color) const
 
bool erase (const SkColor4f &color, const SkIRect *subset=nullptr) const
 

Static Public Member Functions

static size_t AllocSize (const SkImageInfo &info, size_t *rowBytes)
 

Detailed Description

Definition at line 21 of file SkAutoPixmapStorage.h.

Constructor & Destructor Documentation

◆ SkAutoPixmapStorage() [1/2]

SkAutoPixmapStorage::SkAutoPixmapStorage ( )

Definition at line 15 of file SkAutoPixmapStorage.cpp.

15: fStorage(nullptr) {}

◆ ~SkAutoPixmapStorage()

SkAutoPixmapStorage::~SkAutoPixmapStorage ( )

Definition at line 17 of file SkAutoPixmapStorage.cpp.

17 {
18 this->freeStorage();
19}

◆ SkAutoPixmapStorage() [2/2]

SkAutoPixmapStorage::SkAutoPixmapStorage ( SkAutoPixmapStorage &&  other)

Definition at line 21 of file SkAutoPixmapStorage.cpp.

21 : fStorage(nullptr) {
22 *this = std::move(other);
23}

Member Function Documentation

◆ alloc()

void SkAutoPixmapStorage::alloc ( const SkImageInfo info)

Allocate memory for the pixels needed to match the specified Info and fill out the pixmap to point to that memory. The storage will be freed when this object is destroyed, or if another call to tryAlloc() or alloc() is made.

If the memory cannot be allocated, calls SK_ABORT().

Definition at line 60 of file SkAutoPixmapStorage.cpp.

60 {
61 SkASSERT_RELEASE(this->tryAlloc(info));
62}
#define SkASSERT_RELEASE(cond)
Definition: SkAssert.h:100
bool tryAlloc(const SkImageInfo &)

◆ AllocSize()

size_t SkAutoPixmapStorage::AllocSize ( const SkImageInfo info,
size_t *  rowBytes 
)
static

Gets the size and optionally the rowBytes that would be allocated by SkAutoPixmapStorage if alloc/tryAlloc was called.

Definition at line 35 of file SkAutoPixmapStorage.cpp.

35 {
36 size_t rb = info.minRowBytes();
37 if (rowBytes) {
38 *rowBytes = rb;
39 }
40 return info.computeByteSize(rb);
41}
size_t rowBytes() const
Definition: SkPixmap.h:145
const SkImageInfo & info() const
Definition: SkPixmap.h:135
size_t minRowBytes() const
Definition: SkImageInfo.h:517
size_t computeByteSize(size_t rowBytes) const

◆ detachPixels()

void * SkAutoPixmapStorage::detachPixels ( )

Returns a void* of the allocated pixel memory and resets the pixmap. If the storage hasn't been allocated, the result is NULL. The caller is responsible for calling sk_free to free the returned memory.

Definition at line 64 of file SkAutoPixmapStorage.cpp.

64 {
65 if (!fStorage) {
66 return nullptr;
67 }
68
69 void* data = fStorage;
70 fStorage = nullptr;
71 this->INHERITED::reset();
72
73 return data;
74}
void reset()
Definition: SkPixmap.cpp:32
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ detachPixelsAsData()

sk_sp< SkData > SkAutoPixmapStorage::detachPixelsAsData ( )

Returns an SkData object wrapping the allocated pixels memory, and resets the pixmap. If the storage hasn't been allocated, the result is NULL.

Definition at line 76 of file SkAutoPixmapStorage.cpp.

76 {
77 if (!fStorage) {
78 return nullptr;
79 }
80
82 fStorage = nullptr;
83 this->INHERITED::reset();
84
85 return data;
86}
static sk_sp< SkData > MakeFromMalloc(const void *data, size_t length)
Definition: SkData.cpp:107
size_t computeByteSize() const
Definition: SkPixmap.h:231

◆ operator=()

SkAutoPixmapStorage & SkAutoPixmapStorage::operator= ( SkAutoPixmapStorage &&  other)

Leave the moved-from object in a free-but-valid state.

Definition at line 25 of file SkAutoPixmapStorage.cpp.

25 {
26 this->fStorage = other.fStorage;
27 this->INHERITED::reset(other.info(), this->fStorage, other.rowBytes());
28
29 other.fStorage = nullptr;
30 other.INHERITED::reset();
31
32 return *this;
33}

◆ reset() [1/3]

void SkAutoPixmapStorage::reset ( )
inline

Definition at line 72 of file SkAutoPixmapStorage.h.

72 {
73 this->freeStorage();
74 this->INHERITED::reset();
75 }

◆ reset() [2/3]

void SkAutoPixmapStorage::reset ( const SkImageInfo info,
const void *  addr,
size_t  rb 
)
inline

Definition at line 76 of file SkAutoPixmapStorage.h.

76 {
77 this->freeStorage();
78 this->INHERITED::reset(info, addr, rb);
79 }
const void * addr() const
Definition: SkPixmap.h:153

◆ reset() [3/3]

bool SkAutoPixmapStorage::reset ( const SkMask mask)
inline

Definition at line 81 of file SkAutoPixmapStorage.h.

81 {
82 this->freeStorage();
83 return this->INHERITED::reset(mask);
84 }

◆ tryAlloc()

bool SkAutoPixmapStorage::tryAlloc ( const SkImageInfo info)

Try to allocate memory for the pixels needed to match the specified Info. On success return true and fill out the pixmap to point to that memory. The storage will be freed when this object is destroyed, or if another call to tryAlloc() or alloc() is made.

On failure, return false and reset() the pixmap to empty.

Definition at line 43 of file SkAutoPixmapStorage.cpp.

43 {
44 this->freeStorage();
45
46 size_t rb;
47 size_t size = AllocSize(info, &rb);
49 return false;
50 }
51 void* pixels = sk_malloc_canfail(size);
52 if (nullptr == pixels) {
53 return false;
54 }
55 this->reset(info, pixels, rb);
56 fStorage = pixels;
57 return true;
58}
static void * sk_malloc_canfail(size_t size)
Definition: SkMalloc.h:93
static size_t AllocSize(const SkImageInfo &info, size_t *rowBytes)
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
static bool ByteSizeOverflowed(size_t byteSize)
Definition: SkImageInfo.h:588

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