Skia
2D Graphics Library
SkColorPriv.h File Reference
#include "include/core/SkColor.h"
#include "include/private/base/SkMath.h"
#include "include/private/base/SkTPin.h"
#include "include/private/base/SkTo.h"
#include <algorithm>
Include dependency graph for SkColorPriv.h:

Go to the source code of this file.

Macros

#define SkAlphaMul(value, alpha256)   (((value) * (alpha256)) >> 8)
 Multiplify value by 0..256, and shift the result down 8 (i.e. More...
 
#define SK_A32_BITS   8
 
#define SK_R32_BITS   8
 
#define SK_G32_BITS   8
 
#define SK_B32_BITS   8
 
#define SK_A32_MASK   ((1 << SK_A32_BITS) - 1)
 
#define SK_R32_MASK   ((1 << SK_R32_BITS) - 1)
 
#define SK_G32_MASK   ((1 << SK_G32_BITS) - 1)
 
#define SK_B32_MASK   ((1 << SK_B32_BITS) - 1)
 
#define SK_RGBA_R32_SHIFT   0
 
#define SK_RGBA_G32_SHIFT   8
 
#define SK_RGBA_B32_SHIFT   16
 
#define SK_RGBA_A32_SHIFT   24
 
#define SK_BGRA_B32_SHIFT   0
 
#define SK_BGRA_G32_SHIFT   8
 
#define SK_BGRA_R32_SHIFT   16
 
#define SK_BGRA_A32_SHIFT   24
 
#define SkGetPackedA32(packed)   ((uint32_t)((packed) << (24 - SK_A32_SHIFT)) >> 24)
 
#define SkGetPackedR32(packed)   ((uint32_t)((packed) << (24 - SK_R32_SHIFT)) >> 24)
 
#define SkGetPackedG32(packed)   ((uint32_t)((packed) << (24 - SK_G32_SHIFT)) >> 24)
 
#define SkGetPackedB32(packed)   ((uint32_t)((packed) << (24 - SK_B32_SHIFT)) >> 24)
 
#define SkA32Assert(a)   SkASSERT((unsigned)(a) <= SK_A32_MASK)
 
#define SkR32Assert(r)   SkASSERT((unsigned)(r) <= SK_R32_MASK)
 
#define SkG32Assert(g)   SkASSERT((unsigned)(g) <= SK_G32_MASK)
 
#define SkB32Assert(b)   SkASSERT((unsigned)(b) <= SK_B32_MASK)
 

Functions

static unsigned SkAlpha255To256 (U8CPU alpha)
 Turn 0..255 into 0..256 by adding 1 at the half-way point. More...
 
static U8CPU SkUnitScalarClampToByte (SkScalar x)
 
static SkPMColor SkPackARGB32 (U8CPU a, U8CPU r, U8CPU g, U8CPU b)
 Pack the components into a SkPMColor, checking (in the debug version) that the components are 0..255, and are already premultiplied (i.e. More...
 
static SkPMColor SkPackARGB32NoCheck (U8CPU a, U8CPU r, U8CPU g, U8CPU b)
 Same as SkPackARGB32, but this version guarantees to not check that the values are premultiplied in the debug version. More...
 
static SkPMColor SkPremultiplyARGBInline (U8CPU a, U8CPU r, U8CPU g, U8CPU b)
 
static SK_ALWAYS_INLINE uint32_t SkAlphaMulQ (uint32_t c, unsigned scale)
 
static SkPMColor SkPMSrcOver (SkPMColor src, SkPMColor dst)
 

Macro Definition Documentation

◆ SK_A32_BITS

#define SK_A32_BITS   8

◆ SK_A32_MASK

#define SK_A32_MASK   ((1 << SK_A32_BITS) - 1)

◆ SK_B32_BITS

#define SK_B32_BITS   8

◆ SK_B32_MASK

#define SK_B32_MASK   ((1 << SK_B32_BITS) - 1)

◆ SK_BGRA_A32_SHIFT

#define SK_BGRA_A32_SHIFT   24

◆ SK_BGRA_B32_SHIFT

#define SK_BGRA_B32_SHIFT   0

◆ SK_BGRA_G32_SHIFT

#define SK_BGRA_G32_SHIFT   8

◆ SK_BGRA_R32_SHIFT

#define SK_BGRA_R32_SHIFT   16

◆ SK_G32_BITS

#define SK_G32_BITS   8

◆ SK_G32_MASK

#define SK_G32_MASK   ((1 << SK_G32_BITS) - 1)

◆ SK_R32_BITS

#define SK_R32_BITS   8

◆ SK_R32_MASK

#define SK_R32_MASK   ((1 << SK_R32_BITS) - 1)

◆ SK_RGBA_A32_SHIFT

#define SK_RGBA_A32_SHIFT   24

◆ SK_RGBA_B32_SHIFT

#define SK_RGBA_B32_SHIFT   16

◆ SK_RGBA_G32_SHIFT

#define SK_RGBA_G32_SHIFT   8

◆ SK_RGBA_R32_SHIFT

#define SK_RGBA_R32_SHIFT   0

◆ SkA32Assert

#define SkA32Assert (   a)    SkASSERT((unsigned)(a) <= SK_A32_MASK)

◆ SkAlphaMul

#define SkAlphaMul (   value,
  alpha256 
)    (((value) * (alpha256)) >> 8)

Multiplify value by 0..256, and shift the result down 8 (i.e.

return (value * alpha256) >> 8)

◆ SkB32Assert

#define SkB32Assert (   b)    SkASSERT((unsigned)(b) <= SK_B32_MASK)

◆ SkG32Assert

#define SkG32Assert (   g)    SkASSERT((unsigned)(g) <= SK_G32_MASK)

◆ SkGetPackedA32

#define SkGetPackedA32 (   packed)    ((uint32_t)((packed) << (24 - SK_A32_SHIFT)) >> 24)

◆ SkGetPackedB32

#define SkGetPackedB32 (   packed)    ((uint32_t)((packed) << (24 - SK_B32_SHIFT)) >> 24)

◆ SkGetPackedG32

#define SkGetPackedG32 (   packed)    ((uint32_t)((packed) << (24 - SK_G32_SHIFT)) >> 24)

◆ SkGetPackedR32

#define SkGetPackedR32 (   packed)    ((uint32_t)((packed) << (24 - SK_R32_SHIFT)) >> 24)

◆ SkR32Assert

#define SkR32Assert (   r)    SkASSERT((unsigned)(r) <= SK_R32_MASK)

Function Documentation

◆ SkAlpha255To256()

static unsigned SkAlpha255To256 ( U8CPU  alpha)
inlinestatic

Turn 0..255 into 0..256 by adding 1 at the half-way point.

Used to turn a byte into a scale value, so that we can say scale * value >> 8 instead of alpha * value / 255.

In debugging, asserts that alpha is 0..255

◆ SkAlphaMulQ()

static SK_ALWAYS_INLINE uint32_t SkAlphaMulQ ( uint32_t  c,
unsigned  scale 
)
static

◆ SkPackARGB32()

static SkPMColor SkPackARGB32 ( U8CPU  a,
U8CPU  r,
U8CPU  g,
U8CPU  b 
)
inlinestatic

Pack the components into a SkPMColor, checking (in the debug version) that the components are 0..255, and are already premultiplied (i.e.

alpha >= color)

◆ SkPackARGB32NoCheck()

static SkPMColor SkPackARGB32NoCheck ( U8CPU  a,
U8CPU  r,
U8CPU  g,
U8CPU  b 
)
inlinestatic

Same as SkPackARGB32, but this version guarantees to not check that the values are premultiplied in the debug version.

◆ SkPMSrcOver()

static SkPMColor SkPMSrcOver ( SkPMColor  src,
SkPMColor  dst 
)
inlinestatic

◆ SkPremultiplyARGBInline()

static SkPMColor SkPremultiplyARGBInline ( U8CPU  a,
U8CPU  r,
U8CPU  g,
U8CPU  b 
)
inlinestatic

◆ SkUnitScalarClampToByte()

static U8CPU SkUnitScalarClampToByte ( SkScalar  x)
inlinestatic