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

#include <SkMasks.h>

Classes

struct  InputMasks
 
struct  MaskInfo
 

Public Member Functions

constexpr SkMasks (const MaskInfo red, const MaskInfo green, const MaskInfo blue, const MaskInfo alpha)
 
uint8_t getRed (uint32_t pixel) const
 
uint8_t getGreen (uint32_t pixel) const
 
uint8_t getBlue (uint32_t pixel) const
 
uint8_t getAlpha (uint32_t pixel) const
 
uint32_t getAlphaMask () const
 

Static Public Member Functions

static SkMasksCreateMasks (InputMasks masks, int bytesPerPixel)
 

Detailed Description

Definition at line 14 of file SkMasks.h.

Constructor & Destructor Documentation

◆ SkMasks()

constexpr SkMasks::SkMasks ( const MaskInfo  red,
const MaskInfo  green,
const MaskInfo  blue,
const MaskInfo  alpha 
)
inlineconstexpr

Definition at line 23 of file SkMasks.h.

27 : fRed(red), fGreen(green), fBlue(blue), fAlpha(alpha) {}

Member Function Documentation

◆ CreateMasks()

SkMasks * SkMasks::CreateMasks ( InputMasks  masks,
int  bytesPerPixel 
)
static

Definition at line 126 of file SkMasks.cpp.

126 {
127 SkASSERT(0 < bytesPerPixel && bytesPerPixel <= 4);
128
129 // Trim the input masks to match bytesPerPixel.
130 if (bytesPerPixel < 4) {
131 int bitsPerPixel = 8*bytesPerPixel;
132 masks.red &= (1 << bitsPerPixel) - 1;
133 masks.green &= (1 << bitsPerPixel) - 1;
134 masks.blue &= (1 << bitsPerPixel) - 1;
135 masks.alpha &= (1 << bitsPerPixel) - 1;
136 }
137
138 // Check that masks do not overlap.
139 if (((masks.red & masks.green) |
140 (masks.red & masks.blue ) |
141 (masks.red & masks.alpha) |
142 (masks.green & masks.blue ) |
143 (masks.green & masks.alpha) |
144 (masks.blue & masks.alpha) ) != 0) {
145 return nullptr;
146 }
147
148 return new SkMasks(process_mask(masks.red ),
149 process_mask(masks.green),
150 process_mask(masks.blue ),
151 process_mask(masks.alpha));
152}
#define SkASSERT(cond)
Definition: SkAssert.h:116
static SkMasks::MaskInfo process_mask(uint32_t mask)
Definition: SkMasks.cpp:88
constexpr SkMasks(const MaskInfo red, const MaskInfo green, const MaskInfo blue, const MaskInfo alpha)
Definition: SkMasks.h:23

◆ getAlpha()

uint8_t SkMasks::getAlpha ( uint32_t  pixel) const

Definition at line 79 of file SkMasks.cpp.

79 {
80 return get_comp(pixel, fAlpha.mask, fAlpha.shift, fAlpha.size);
81}
static uint8_t get_comp(uint32_t pixel, uint32_t mask, uint32_t shift, uint32_t size)
Definition: SkMasks.cpp:60
uint32_t mask
Definition: SkMasks.h:18
uint32_t size
Definition: SkMasks.h:20
uint32_t shift
Definition: SkMasks.h:19

◆ getAlphaMask()

uint32_t SkMasks::getAlphaMask ( ) const
inline

Definition at line 48 of file SkMasks.h.

48{ return fAlpha.mask; }

◆ getBlue()

uint8_t SkMasks::getBlue ( uint32_t  pixel) const

Definition at line 76 of file SkMasks.cpp.

76 {
77 return get_comp(pixel, fBlue.mask, fBlue.shift, fBlue.size);
78}

◆ getGreen()

uint8_t SkMasks::getGreen ( uint32_t  pixel) const

Definition at line 73 of file SkMasks.cpp.

73 {
74 return get_comp(pixel, fGreen.mask, fGreen.shift, fGreen.size);
75}

◆ getRed()

uint8_t SkMasks::getRed ( uint32_t  pixel) const

Definition at line 70 of file SkMasks.cpp.

70 {
71 return get_comp(pixel, fRed.mask, fRed.shift, fRed.size);
72}

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