Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Macros | Typedefs | Functions
GrColor.h File Reference
#include "include/core/SkColor.h"
#include "include/core/SkColorPriv.h"
#include "include/gpu/GrTypes.h"
#include "include/private/SkColorData.h"
#include "src/base/SkHalf.h"
#include "src/gpu/BufferWriter.h"

Go to the source code of this file.

Macros

#define GrColor_SHIFT_R   0
 
#define GrColor_SHIFT_G   8
 
#define GrColor_SHIFT_B   16
 
#define GrColor_SHIFT_A   24
 
#define GrColorUnpackR(color)   (((color) >> GrColor_SHIFT_R) & 0xFF)
 
#define GrColorUnpackG(color)   (((color) >> GrColor_SHIFT_G) & 0xFF)
 
#define GrColorUnpackB(color)   (((color) >> GrColor_SHIFT_B) & 0xFF)
 
#define GrColorUnpackA(color)   (((color) >> GrColor_SHIFT_A) & 0xFF)
 
#define GrColor_ILLEGAL   (~(0xFF << GrColor_SHIFT_A))
 

Typedefs

typedef uint32_t GrColor
 

Functions

static GrColor GrColorPackRGBA (unsigned r, unsigned g, unsigned b, unsigned a)
 
static float GrNormalizeByteToFloat (uint8_t value)
 
static bool SkPMColor4fFitsInBytes (const SkPMColor4f &color)
 
static uint64_t SkPMColor4f_toFP16 (const SkPMColor4f &color)
 

Macro Definition Documentation

◆ GrColor_ILLEGAL

#define GrColor_ILLEGAL   (~(0xFF << GrColor_SHIFT_A))

Since premultiplied means that alpha >= color, we construct a color with each component==255 and alpha == 0 to be "illegal"

Definition at line 68 of file GrColor.h.

◆ GrColor_SHIFT_A

#define GrColor_SHIFT_A   24

Definition at line 40 of file GrColor.h.

◆ GrColor_SHIFT_B

#define GrColor_SHIFT_B   16

Definition at line 39 of file GrColor.h.

◆ GrColor_SHIFT_G

#define GrColor_SHIFT_G   8

Definition at line 38 of file GrColor.h.

◆ GrColor_SHIFT_R

#define GrColor_SHIFT_R   0

Definition at line 37 of file GrColor.h.

◆ GrColorUnpackA

#define GrColorUnpackA (   color)    (((color) >> GrColor_SHIFT_A) & 0xFF)

Definition at line 62 of file GrColor.h.

◆ GrColorUnpackB

#define GrColorUnpackB (   color)    (((color) >> GrColor_SHIFT_B) & 0xFF)

Definition at line 61 of file GrColor.h.

◆ GrColorUnpackG

#define GrColorUnpackG (   color)    (((color) >> GrColor_SHIFT_G) & 0xFF)

Definition at line 60 of file GrColor.h.

◆ GrColorUnpackR

#define GrColorUnpackR (   color)    (((color) >> GrColor_SHIFT_R) & 0xFF)

Definition at line 59 of file GrColor.h.

Typedef Documentation

◆ GrColor

typedef uint32_t GrColor

GrColor is 4 bytes for R, G, B, A, in a specific order defined below. Whether the color is premultiplied or not depends on the context in which it is being used.

Definition at line 25 of file GrColor.h.

Function Documentation

◆ GrColorPackRGBA()

static GrColor GrColorPackRGBA ( unsigned  r,
unsigned  g,
unsigned  b,
unsigned  a 
)
inlinestatic

Pack 4 components (RGBA) into a GrColor int

Definition at line 46 of file GrColor.h.

46 {
47 SkASSERT((uint8_t)r == r);
48 SkASSERT((uint8_t)g == g);
49 SkASSERT((uint8_t)b == b);
50 SkASSERT((uint8_t)a == a);
51 return (r << GrColor_SHIFT_R) |
52 (g << GrColor_SHIFT_G) |
53 (b << GrColor_SHIFT_B) |
54 (a << GrColor_SHIFT_A);
55}
#define GrColor_SHIFT_G
Definition GrColor.h:38
#define GrColor_SHIFT_B
Definition GrColor.h:39
#define GrColor_SHIFT_A
Definition GrColor.h:40
#define GrColor_SHIFT_R
Definition GrColor.h:37
#define SkASSERT(cond)
Definition SkAssert.h:116
static bool b
struct MyStruct a[10]

◆ GrNormalizeByteToFloat()

static float GrNormalizeByteToFloat ( uint8_t  value)
inlinestatic

Normalizes and coverts an uint8_t to a float. [0, 255] -> [0.0, 1.0]

Definition at line 71 of file GrColor.h.

71 {
72 static const float ONE_OVER_255 = 1.f / 255.f;
73 return value * ONE_OVER_255;
74}
uint8_t value

◆ SkPMColor4f_toFP16()

static uint64_t SkPMColor4f_toFP16 ( const SkPMColor4f color)
inlinestatic

Definition at line 82 of file GrColor.h.

82 {
83 uint64_t halfColor;
84 to_half(skvx::float4::Load(color.vec())).store(&halfColor);
85 return halfColor;
86}
SkColor4f color
SIN Vec< N, uint16_t > to_half(const Vec< N, float > &x)
Definition SkVx.h:750
static SKVX_ALWAYS_INLINE Vec Load(const void *ptr)
Definition SkVx.h:109

◆ SkPMColor4fFitsInBytes()

static bool SkPMColor4fFitsInBytes ( const SkPMColor4f color)
inlinestatic

Used to pick vertex attribute types.

Definition at line 77 of file GrColor.h.

77 {
78 // Might want to instead check that the components are [0...a] instead of [0...1]?
79 return color.fitsInBytes();
80}