Flutter Engine
The Flutter Engine
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
SkMask Class Reference

#include <SkMask.h>

Inheritance diagram for SkMask:
SkMaskBuilder

Classes

struct  AlphaIter
 
struct  AlphaIter< SkMask::kA8_Format >
 
struct  AlphaIter< SkMask::kARGB32_Format >
 
struct  AlphaIter< SkMask::kBW_Format >
 
struct  AlphaIter< SkMask::kLCD16_Format >
 

Public Types

enum  Format : uint8_t {
  kBW_Format , kA8_Format , k3D_Format , kARGB32_Format ,
  kLCD16_Format , kSDF_Format
}
 
enum  { kCountMaskFormats = kSDF_Format + 1 }
 

Public Member Functions

 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 bool IsValidFormat (uint8_t format)
 

Public Attributes

uint8_t const *const fImage
 
const SkIRect fBounds
 
const uint32_t fRowBytes
 
const Format fFormat
 

Detailed Description

SkMask is used to describe alpha bitmaps, either 1bit, 8bit, or the 3-channel 3D format. These are passed to SkMaskFilter objects.

Definition at line 25 of file SkMask.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
kCountMaskFormats 

Definition at line 35 of file SkMask.h.

35 {
37 };
@ kSDF_Format
8bits representing signed distance field
Definition: SkMask.h:32
@ kCountMaskFormats
Definition: SkMask.h:36

◆ Format

enum SkMask::Format : uint8_t
Enumerator
kBW_Format 

1bit per pixel mask (e.g. monochrome)

kA8_Format 

8bits per pixel mask (e.g. antialiasing)

k3D_Format 

3 8bit per pixl planes: alpha, mul, add

kARGB32_Format 

SkPMColor.

kLCD16_Format 

565 alpha for r/g/b

kSDF_Format 

8bits representing signed distance field

Definition at line 26 of file SkMask.h.

26 : uint8_t {
27 kBW_Format, //!< 1bit per pixel mask (e.g. monochrome)
28 kA8_Format, //!< 8bits per pixel mask (e.g. antialiasing)
29 k3D_Format, //!< 3 8bit per pixl planes: alpha, mul, add
30 kARGB32_Format, //!< SkPMColor
31 kLCD16_Format, //!< 565 alpha for r/g/b
32 kSDF_Format, //!< 8bits representing signed distance field
33 };
@ k3D_Format
3 8bit per pixl planes: alpha, mul, add
Definition: SkMask.h:29
@ kA8_Format
8bits per pixel mask (e.g. antialiasing)
Definition: SkMask.h:28
@ kLCD16_Format
565 alpha for r/g/b
Definition: SkMask.h:31
@ kARGB32_Format
SkPMColor.
Definition: SkMask.h:30
@ kBW_Format
1bit per pixel mask (e.g. monochrome)
Definition: SkMask.h:27

Constructor & Destructor Documentation

◆ SkMask()

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

Definition at line 39 of file SkMask.h.

40 : fImage(img), fBounds(bounds), fRowBytes(rowBytes), fFormat(format) {}
uint32_t uint32_t * format
Optional< SkRect > bounds
Definition: SkRecords.h:189
const uint32_t fRowBytes
Definition: SkMask.h:43
uint8_t const *const fImage
Definition: SkMask.h:41
const SkIRect fBounds
Definition: SkMask.h:42
const Format fFormat
Definition: SkMask.h:44

Member Function Documentation

◆ computeImageSize()

size_t SkMask::computeImageSize ( ) const

Return the byte size of the mask, assuming only 1 plane. Does not account for k3D_Format. For that, use computeTotalImageSize(). If there is an overflow of 32bits, then returns 0.

Definition at line 30 of file SkMask.cpp.

30 {
32}
static int32_t safeMul32(int32_t a, int32_t b)
Definition: SkMask.cpp:22
constexpr int32_t height() const
Definition: SkRect.h:165

◆ computeTotalImageSize()

size_t SkMask::computeTotalImageSize ( ) const

Return the byte size of the mask, taking into account any extra planes (e.g. k3D_Format). If there is an overflow of 32bits, then returns 0.

Definition at line 34 of file SkMask.cpp.

34 {
35 size_t size = this->computeImageSize();
37 size = safeMul32(SkToS32(size), 3);
38 }
39 return size;
40}
constexpr int32_t SkToS32(S x)
Definition: SkTo.h:25
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
size_t computeImageSize() const
Definition: SkMask.cpp:30

◆ getAddr()

const void * SkMask::getAddr ( int  x,
int  y 
) const

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 112 of file SkMask.cpp.

112 {
116
117 const char* addr = (const char*)fImage;
118 addr += (y - fBounds.fTop) * fRowBytes;
120 return addr;
121}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static int maskFormatToShift(SkMask::Format format)
Definition: SkMask.cpp:106
double y
double x
int32_t fTop
smaller y-axis bounds
Definition: SkRect.h:34
int32_t fLeft
smaller x-axis bounds
Definition: SkRect.h:33
bool contains(int32_t x, int32_t y) const
Definition: SkRect.h:463

◆ getAddr1()

const uint8_t * SkMask::getAddr1 ( int  x,
int  y 
) const
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 68 of file SkMask.h.

68 {
71 SkASSERT(fImage != nullptr);
72 return fImage + ((x - fBounds.fLeft) >> 3) + (y - fBounds.fTop) * fRowBytes;
73 }

◆ getAddr32()

const uint32_t * SkMask::getAddr32 ( int  x,
int  y 
) const
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 104 of file SkMask.h.

104 {
107 SkASSERT(fImage != nullptr);
108 const uint32_t* row = (const uint32_t*)(fImage + (y - fBounds.fTop) * fRowBytes);
109 return row + (x - fBounds.fLeft);
110 }

◆ getAddr8()

const uint8_t * SkMask::getAddr8 ( int  x,
int  y 
) const
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 79 of file SkMask.h.

79 {
82 SkASSERT(fImage != nullptr);
83 return fImage + x - fBounds.fLeft + (y - fBounds.fTop) * fRowBytes;
84 }

◆ getAddrLCD16()

const uint16_t * SkMask::getAddrLCD16 ( int  x,
int  y 
) const
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 91 of file SkMask.h.

91 {
94 SkASSERT(fImage != nullptr);
95 const uint16_t* row = (const uint16_t*)(fImage + (y - fBounds.fTop) * fRowBytes);
96 return row + (x - fBounds.fLeft);
97 }

◆ isEmpty()

bool SkMask::isEmpty ( ) const
inline

Returns true if the mask is empty: i.e. it has an empty bounds.

Definition at line 50 of file SkMask.h.

50{ return fBounds.isEmpty(); }
bool isEmpty() const
Definition: SkRect.h:202

◆ IsValidFormat()

static bool SkMask::IsValidFormat ( uint8_t  format)
inlinestatic

Definition at line 46 of file SkMask.h.

46{ return format < kCountMaskFormats; }

Member Data Documentation

◆ fBounds

const SkIRect SkMask::fBounds

Definition at line 42 of file SkMask.h.

◆ fFormat

const Format SkMask::fFormat

Definition at line 44 of file SkMask.h.

◆ fImage

uint8_t const* const SkMask::fImage

Definition at line 41 of file SkMask.h.

◆ fRowBytes

const uint32_t SkMask::fRowBytes

Definition at line 43 of file SkMask.h.


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