Flutter Engine
The Flutter Engine
Public Types | Public Member Functions | Static Public Member Functions | List of all members
SkMaskBuilder Struct Reference

#include <SkMask.h>

Inheritance diagram for SkMaskBuilder:
SkMask

Public Types

enum  AllocType { kUninit_Alloc , kZeroInit_Alloc }
 
enum  CreateMode { kJustComputeBounds_CreateMode , kJustRenderImage_CreateMode , kComputeBoundsAndRenderImage_CreateMode }
 
- Public Types inherited from SkMask
enum  Format : uint8_t {
  kBW_Format , kA8_Format , k3D_Format , kARGB32_Format ,
  kLCD16_Format , kSDF_Format
}
 
enum  { kCountMaskFormats = kSDF_Format + 1 }
 

Public Member Functions

 SkMaskBuilder ()
 
 SkMaskBuilder (const SkMaskBuilder &)=delete
 
 SkMaskBuilder (SkMaskBuilder &&)=default
 
SkMaskBuilderoperator= (const SkMaskBuilder &)=delete
 
SkMaskBuilderoperator= (SkMaskBuilder &&that)
 
 SkMaskBuilder (uint8_t *img, const SkIRect &bounds, uint32_t rowBytes, Format format)
 
uint8_t *& image ()
 
SkIRectbounds ()
 
uint32_t & rowBytes ()
 
Formatformat ()
 
uint8_t * getAddr1 (int x, int y)
 
uint8_t * getAddr8 (int x, int y)
 
uint16_t * getAddrLCD16 (int x, int y)
 
uint32_t * getAddr32 (int x, int y)
 
void * getAddr (int x, int y)
 
- Public Member Functions inherited from SkMask
 SkMask (const uint8_t *img, const SkIRect &bounds, uint32_t rowBytes, Format format)
 
bool isEmpty () const
 
size_t computeImageSize () const
 
size_t computeTotalImageSize () const
 
const uint8_t * getAddr1 (int x, int y) const
 
const uint8_t * getAddr8 (int x, int y) const
 
const uint16_t * getAddrLCD16 (int x, int y) const
 
const uint32_t * getAddr32 (int x, int y) const
 
const void * getAddr (int x, int y) const
 

Static Public Member Functions

static uint8_t * AllocImage (size_t bytes, AllocType=kUninit_Alloc)
 
static void FreeImage (void *image)
 
static SkMaskBuilder PrepareDestination (int radiusX, int radiusY, const SkMask &src)
 
- Static Public Member Functions inherited from SkMask
static bool IsValidFormat (uint8_t format)
 

Additional Inherited Members

- Public Attributes inherited from SkMask
uint8_t const *const fImage
 
const SkIRect fBounds
 
const uint32_t fRowBytes
 
const Format fFormat
 

Detailed Description

Definition at line 219 of file SkMask.h.

Member Enumeration Documentation

◆ AllocType

Enumerator
kUninit_Alloc 
kZeroInit_Alloc 

Definition at line 291 of file SkMask.h.

291 {
294 };
@ kUninit_Alloc
Definition: SkMask.h:292
@ kZeroInit_Alloc
Definition: SkMask.h:293

◆ CreateMode

Enumerator
kJustComputeBounds_CreateMode 

compute bounds and return

kJustRenderImage_CreateMode 

render into preallocate mask

kComputeBoundsAndRenderImage_CreateMode 

compute bounds, alloc image and render into it

Definition at line 298 of file SkMask.h.

298 {
299 kJustComputeBounds_CreateMode, //!< compute bounds and return
300 kJustRenderImage_CreateMode, //!< render into preallocate mask
301 kComputeBoundsAndRenderImage_CreateMode //!< compute bounds, alloc image and render into it
302 };
@ kComputeBoundsAndRenderImage_CreateMode
compute bounds, alloc image and render into it
Definition: SkMask.h:301
@ kJustRenderImage_CreateMode
render into preallocate mask
Definition: SkMask.h:300
@ kJustComputeBounds_CreateMode
compute bounds and return
Definition: SkMask.h:299

Constructor & Destructor Documentation

◆ SkMaskBuilder() [1/4]

SkMaskBuilder::SkMaskBuilder ( )
inline

Definition at line 220 of file SkMask.h.

220: SkMask(nullptr, {0}, 0, SkMask::Format::kBW_Format) {}
SkMask(const uint8_t *img, const SkIRect &bounds, uint32_t rowBytes, Format format)
Definition: SkMask.h:39

◆ SkMaskBuilder() [2/4]

SkMaskBuilder::SkMaskBuilder ( const SkMaskBuilder )
delete

◆ SkMaskBuilder() [3/4]

SkMaskBuilder::SkMaskBuilder ( SkMaskBuilder &&  )
default

◆ SkMaskBuilder() [4/4]

SkMaskBuilder::SkMaskBuilder ( uint8_t *  img,
const SkIRect bounds,
uint32_t  rowBytes,
Format  format 
)
inline

Definition at line 233 of file SkMask.h.

234 : SkMask(img, bounds, rowBytes, format) {}
Format & format()
Definition: SkMask.h:239
uint32_t & rowBytes()
Definition: SkMask.h:238
SkIRect & bounds()
Definition: SkMask.h:237

Member Function Documentation

◆ AllocImage()

uint8_t * SkMaskBuilder::AllocImage ( size_t  size,
AllocType  at = kUninit_Alloc 
)
static

We explicitly use this allocator for SkBimap pixels, so that we can freely assign memory allocated by one class to the other.

Definition at line 45 of file SkMask.cpp.

45 {
46 size_t aligned_size = SkSafeMath::Align4(size);
47 unsigned flags = SK_MALLOC_THROW;
48 if (at == kZeroInit_Alloc) {
50 }
51 return static_cast<uint8_t*>(sk_malloc_flags(aligned_size, flags));
52}
SK_API void * sk_malloc_flags(size_t size, unsigned flags)
@ SK_MALLOC_ZERO_INITIALIZE
Definition: SkMalloc.h:34
@ SK_MALLOC_THROW
Definition: SkMalloc.h:40
static size_t Align4(size_t x)
Definition: SkSafeMath.h:69
FlutterSemanticsFlag flags
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

◆ bounds()

SkIRect & SkMaskBuilder::bounds ( )
inline

Definition at line 237 of file SkMask.h.

237{ return *const_cast<SkIRect*>(&fBounds); }
Definition: SkRect.h:32
const SkIRect fBounds
Definition: SkMask.h:42

◆ format()

Format & SkMaskBuilder::format ( )
inline

Definition at line 239 of file SkMask.h.

239{ return *const_cast<Format*>(&fFormat); }
Format
Definition: SkMask.h:26
const Format fFormat
Definition: SkMask.h:44

◆ FreeImage()

void SkMaskBuilder::FreeImage ( void *  image)
static

We explicitly use this allocator for SkBimap pixels, so that we can freely assign memory allocated by one class to the other.

Definition at line 57 of file SkMask.cpp.

57 {
59}
SK_API void sk_free(void *)
uint8_t *& image()
Definition: SkMask.h:236

◆ getAddr()

void * SkMaskBuilder::getAddr ( int  x,
int  y 
)
inline

Returns the address of the specified pixel, computing the pixel-size at runtime based on the mask format. This will be slightly slower than using one of the routines where the format is implied by the name e.g. getAddr8 or getAddr32.

x,y must be contained by the mask's bounds (this is asserted in the debug build, but not checked in the release build.)

This should not be called with kBW_Format, as it will give unspecified results (and assert in the debug build).

Definition at line 287 of file SkMask.h.

287 {
288 return const_cast<void*>(this->SkMask::getAddr(x, y));
289 }
double y
double x
const void * getAddr(int x, int y) const
Definition: SkMask.cpp:112

◆ getAddr1()

uint8_t * SkMaskBuilder::getAddr1 ( int  x,
int  y 
)
inline

Returns the address of the byte that holds the specified bit. Asserts that the mask is kBW_Format, and that x,y are in range. x,y are in the same coordiate space as fBounds.

Definition at line 245 of file SkMask.h.

245 {
246 return const_cast<uint8_t*>(this->SkMask::getAddr1(x, y));
247 }
const uint8_t * getAddr1(int x, int y) const
Definition: SkMask.h:68

◆ getAddr32()

uint32_t * SkMaskBuilder::getAddr32 ( int  x,
int  y 
)
inline

Return the address of the specified 32bit mask. In the debug build, this asserts that the mask's format is 32bits, and that (x,y) are contained in the mask's fBounds.

Definition at line 271 of file SkMask.h.

271 {
272 return const_cast<uint32_t*>(this->SkMask::getAddr32(x, y));
273 }
const uint32_t * getAddr32(int x, int y) const
Definition: SkMask.h:104

◆ getAddr8()

uint8_t * SkMaskBuilder::getAddr8 ( int  x,
int  y 
)
inline

Returns the address of the specified byte. Asserts that the mask is kA8_Format, and that x,y are in range. x,y are in the same coordiate space as fBounds.

Definition at line 253 of file SkMask.h.

253 {
254 return const_cast<uint8_t*>(this->SkMask::getAddr8(x, y));
255 }
const uint8_t * getAddr8(int x, int y) const
Definition: SkMask.h:79

◆ getAddrLCD16()

uint16_t * SkMaskBuilder::getAddrLCD16 ( int  x,
int  y 
)
inline

Return the address of the specified 16bit mask. In the debug build, this asserts that the mask's format is kLCD16_Format, and that (x,y) are contained in the mask's fBounds.

Definition at line 262 of file SkMask.h.

262 {
263 return const_cast<uint16_t*>(this->SkMask::getAddrLCD16(x, y));
264 }
const uint16_t * getAddrLCD16(int x, int y) const
Definition: SkMask.h:91

◆ image()

uint8_t *& SkMaskBuilder::image ( )
inline

Definition at line 236 of file SkMask.h.

236{ return *const_cast<uint8_t**>(&fImage); }
uint8_t const *const fImage
Definition: SkMask.h:41

◆ operator=() [1/2]

SkMaskBuilder & SkMaskBuilder::operator= ( const SkMaskBuilder )
delete

◆ operator=() [2/2]

SkMaskBuilder & SkMaskBuilder::operator= ( SkMaskBuilder &&  that)
inline

Definition at line 224 of file SkMask.h.

224 {
225 this->image() = that.image();
226 this->bounds() = that.bounds();
227 this->rowBytes() = that.rowBytes();
228 this->format() = that.format();
229 that.image() = nullptr;
230 return *this;
231 }

◆ PrepareDestination()

SkMaskBuilder SkMaskBuilder::PrepareDestination ( int  radiusX,
int  radiusY,
const SkMask src 
)
static

Returns initial destination mask data padded by radiusX and radiusY

Definition at line 61 of file SkMask.cpp.

61 {
62 SkSafeMath safe;
63
65 dst.image() = nullptr;
66 dst.format() = SkMask::kA8_Format;
67
68 // dstW = srcW + 2 * radiusX;
69 size_t dstW = safe.add(src.fBounds.width(), safe.add(radiusX, radiusX));
70 // dstH = srcH + 2 * radiusY;
71 size_t dstH = safe.add(src.fBounds.height(), safe.add(radiusY, radiusY));
72
73 size_t toAlloc = safe.mul(dstW, dstH);
74
75 // We can only deal with masks that fit in INT_MAX and sides that fit in int.
76 if (!SkTFitsIn<int>(dstW) || !SkTFitsIn<int>(dstH) || toAlloc > INT_MAX || !safe) {
77 dst.bounds().setEmpty();
78 dst.rowBytes() = 0;
79 return dst;
80 }
81
82 dst.bounds().setWH(SkTo<int>(dstW), SkTo<int>(dstH));
83 dst.bounds().offset(src.fBounds.x(), src.fBounds.y());
84 dst.bounds().offset(-radiusX, -radiusY);
85 dst.rowBytes() = SkTo<uint32_t>(dstW);
86
87 if (src.fImage != nullptr) {
88 dst.image() = SkMaskBuilder::AllocImage(toAlloc);
89 }
90
91 return dst;
92}
size_t add(size_t x, size_t y)
Definition: SkSafeMath.h:33
size_t mul(size_t x, size_t y)
Definition: SkSafeMath.h:29
dst
Definition: cp.py:12
static uint8_t * AllocImage(size_t bytes, AllocType=kUninit_Alloc)
Definition: SkMask.cpp:45
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
Definition: SkMask.h:28

◆ rowBytes()

uint32_t & SkMaskBuilder::rowBytes ( )
inline

Definition at line 238 of file SkMask.h.

238{ return *const_cast<uint32_t*>(&fRowBytes); }
const uint32_t fRowBytes
Definition: SkMask.h:43

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