Skia
2D Graphics Library
SkTypes.h File Reference
#include "include/config/SkUserConfig.h"
#include <stddef.h>
#include <stdint.h>
Include dependency graph for SkTypes.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SK_NOTHING_ARG1(arg1)
 
#define SK_NOTHING_ARG2(arg1, arg2)
 
#define SK_NOTHING_ARG3(arg1, arg2, arg3)
 
#define SK_BUILD_FOR_MAC
 
#define SK_RESTRICT   __restrict__
 
#define SK_WARN_UNUSED_RESULT   __attribute__((warn_unused_result))
 
#define SK_CPU_LENDIAN
 
#define SK_CPU_SSE_LEVEL_SSE1   10
 SK_CPU_SSE_LEVEL. More...
 
#define SK_CPU_SSE_LEVEL_SSE2   20
 
#define SK_CPU_SSE_LEVEL_SSE3   30
 
#define SK_CPU_SSE_LEVEL_SSSE3   31
 
#define SK_CPU_SSE_LEVEL_SSE41   41
 
#define SK_CPU_SSE_LEVEL_SSE42   42
 
#define SK_CPU_SSE_LEVEL_AVX   51
 
#define SK_CPU_SSE_LEVEL_AVX2   52
 
#define SK_CPU_SSE_LEVEL_AVX512   60
 
#define SKIA_IMPLEMENTATION   0
 
#define SK_API
 
#define SK_SPI   SK_API
 
#define SK_DEBUG
 
#define SK_ATTRIBUTE(attr)
 
#define SK_SUPPORT_GPU   1
 
#define SK_GL
 If GPU is enabled but no GPU backends are enabled then enable GL by default. More...
 
#define SK_SUPPORT_ATLAS_TEXT   0
 
#define SkUNREACHABLE   __builtin_unreachable()
 
#define SK_DUMP_GOOGLE3_STACK()
 
#define SK_DUMP_LINE_FORMAT(message)   SkDebugf("%s:%d: fatal error: \"%s\"\n", __FILE__, __LINE__, message)
 
#define SK_ABORT(message)
 
#define SK_R32_SHIFT   0
 
#define SK_B32_SHIFT   (16-SK_R32_SHIFT)
 
#define SK_G32_SHIFT   8
 
#define SK_A32_SHIFT   24
 
#define SK_PMCOLOR_BYTE_ORDER(C0, C1, C2, C3)
 SK_PMCOLOR_BYTE_ORDER can be used to query the byte order of SkPMColor at compile time. More...
 
#define SK_UNUSED   SK_ATTRIBUTE(unused)
 
#define SK_ALWAYS_INLINE   SK_ATTRIBUTE(always_inline) inline
 If your judgment is better than the compiler's (i.e. More...
 
#define SK_NEVER_INLINE   SK_ATTRIBUTE(noinline)
 If your judgment is better than the compiler's (i.e. More...
 
#define SK_PREFETCH(ptr)
 
#define SK_PRINTF_LIKE(A, B)
 
#define SK_SIZE_T_SPECIFIER   "%zu"
 
#define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS   0
 
#define SK_GAMMA_EXPONENT   (0.0f)
 
#define GR_TEST_UTILS   0
 
#define SK_HISTOGRAMS_ENABLED   0
 
#define SK_HISTOGRAM_BOOLEAN(name, value)
 
#define SK_HISTOGRAM_ENUMERATION(name, value, boundary_value)
 
#define SK_ENABLE_LEGACY_SHADERCONTEXT
 
#define SK_API_AVAILABLE(...)
 
#define SkASSERT_RELEASE(cond)   static_cast<void>( (cond) ? (void)0 : []{ SK_ABORT("assert(" #cond ")"); }() )
 
#define SkASSERT(cond)   SkASSERT_RELEASE(cond)
 
#define SkASSERTF(cond, fmt, ...)
 
#define SkDEBUGFAIL(message)   SK_ABORT(message)
 
#define SkDEBUGFAILF(fmt, ...)   SkASSERTF(false, fmt, ##__VA_ARGS__)
 
#define SkDEBUGCODE(...)   __VA_ARGS__
 
#define SkDEBUGF(...)   SkDebugf(__VA_ARGS__)
 
#define SkAssertResult(cond)   SkASSERT(cond)
 
#define SK_ARRAY_COUNT(array)   (sizeof(SkArrayCountHelper(array)))
 

Typedefs

typedef unsigned U8CPU
 Fast type for unsigned 8 bits. More...
 
typedef unsigned U16CPU
 Fast type for unsigned 16 bits. More...
 
typedef uint32_t SkFourByteTag
 
typedef int32_t SkUnichar
 32 bit integer to hold a unicode value More...
 
typedef uint16_t SkGlyphID
 16 bit unsigned integer to hold a glyph index More...
 
typedef uint32_t SkMSec
 32 bit value to hold a millisecond duration Note that SK_MSecMax is about 25 days. More...
 

Enumerations

enum  SkBudgeted : bool { SkBudgeted::kNo = false, SkBudgeted::kYes = true }
 Indicates whether an allocation should count against a cache budget. More...
 
enum  SkBackingFit { SkBackingFit::kApprox, SkBackingFit::kExact }
 Indicates whether a backing store needs to be an exact match or can be larger than is strictly necessary. More...
 

Functions

SK_API void sk_abort_no_print (void)
 Called internally if we hit an unrecoverable error. More...
 
SK_API void SkDebugf (const char format[],...)
 
template<typename T >
static constexpr bool SkToBool (const T &x)
 
static constexpr int32_t SkLeftShift (int32_t value, int32_t shift)
 
static constexpr int64_t SkLeftShift (int64_t value, int32_t shift)
 
template<typename T , size_t N>
char(& SkArrayCountHelper (T(&array)[N]))[N]
 
template<typename T >
static constexpr T SkAlign2 (T x)
 
template<typename T >
static constexpr T SkAlign4 (T x)
 
template<typename T >
static constexpr T SkAlign8 (T x)
 
template<typename T >
static constexpr bool SkIsAlign2 (T x)
 
template<typename T >
static constexpr bool SkIsAlign4 (T x)
 
template<typename T >
static constexpr bool SkIsAlign8 (T x)
 
template<typename T >
static constexpr T SkAlignPtr (T x)
 
template<typename T >
static constexpr bool SkIsAlignPtr (T x)
 
static constexpr SkFourByteTag SkSetFourByteTag (char a, char b, char c, char d)
 
static int32_t SkAbs32 (int32_t value)
 
template<typename T >
static T SkTAbs (T value)
 
template<typename T >
static constexpr const T & SkTPin (const T &value, const T &min, const T &max)
 

Variables

static constexpr int16_t SK_MaxS16 = INT16_MAX
 
static constexpr int16_t SK_MinS16 = -SK_MaxS16
 
static constexpr int32_t SK_MaxS32 = INT32_MAX
 
static constexpr int32_t SK_MinS32 = -SK_MaxS32
 
static constexpr int32_t SK_NaN32 = INT32_MIN
 
static constexpr int64_t SK_MaxS64 = INT64_MAX
 
static constexpr int64_t SK_MinS64 = -SK_MaxS64
 
static constexpr SkMSec SK_MSecMax = INT32_MAX
 Maximum representable milliseconds; 24d 20h 31m 23.647s. More...
 
static constexpr uint32_t SK_InvalidGenID = 0
 The generation IDs in Skia reserve 0 has an invalid marker. More...
 
static constexpr uint32_t SK_InvalidUniqueID = 0
 The unique IDs in Skia reserve 0 has an invalid marker. More...
 

Macro Definition Documentation

◆ GR_TEST_UTILS

#define GR_TEST_UTILS   0

◆ SK_A32_SHIFT

#define SK_A32_SHIFT   24

◆ SK_ABORT

#define SK_ABORT (   message)
Value:
do { \
SK_DUMP_LINE_FORMAT(message); \
SK_DUMP_GOOGLE3_STACK(); \
sk_abort_no_print(); \
SkUNREACHABLE; \
} while (false)

◆ SK_ALLOW_STATIC_GLOBAL_INITIALIZERS

#define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS   0

◆ SK_ALWAYS_INLINE

#define SK_ALWAYS_INLINE   SK_ATTRIBUTE(always_inline) inline

If your judgment is better than the compiler's (i.e.

you've profiled it), you can use SK_ALWAYS_INLINE to force inlining. E.g. inline void someMethod() { ... } // may not be inlined SK_ALWAYS_INLINE void someMethod() { ... } // should always be inlined

◆ SK_API

#define SK_API

◆ SK_API_AVAILABLE

#define SK_API_AVAILABLE (   ...)

◆ SK_ARRAY_COUNT

#define SK_ARRAY_COUNT (   array)    (sizeof(SkArrayCountHelper(array)))

◆ SK_ATTRIBUTE

#define SK_ATTRIBUTE (   attr)

◆ SK_B32_SHIFT

#define SK_B32_SHIFT   (16-SK_R32_SHIFT)

◆ SK_BUILD_FOR_MAC

#define SK_BUILD_FOR_MAC

◆ SK_CPU_LENDIAN

#define SK_CPU_LENDIAN

◆ SK_CPU_SSE_LEVEL_AVX

#define SK_CPU_SSE_LEVEL_AVX   51

◆ SK_CPU_SSE_LEVEL_AVX2

#define SK_CPU_SSE_LEVEL_AVX2   52

◆ SK_CPU_SSE_LEVEL_AVX512

#define SK_CPU_SSE_LEVEL_AVX512   60

◆ SK_CPU_SSE_LEVEL_SSE1

#define SK_CPU_SSE_LEVEL_SSE1   10

SK_CPU_SSE_LEVEL.

If defined, SK_CPU_SSE_LEVEL should be set to the highest supported level. On non-intel CPU this should be undefined.

◆ SK_CPU_SSE_LEVEL_SSE2

#define SK_CPU_SSE_LEVEL_SSE2   20

◆ SK_CPU_SSE_LEVEL_SSE3

#define SK_CPU_SSE_LEVEL_SSE3   30

◆ SK_CPU_SSE_LEVEL_SSE41

#define SK_CPU_SSE_LEVEL_SSE41   41

◆ SK_CPU_SSE_LEVEL_SSE42

#define SK_CPU_SSE_LEVEL_SSE42   42

◆ SK_CPU_SSE_LEVEL_SSSE3

#define SK_CPU_SSE_LEVEL_SSSE3   31

◆ SK_DEBUG

#define SK_DEBUG

◆ SK_DUMP_GOOGLE3_STACK

#define SK_DUMP_GOOGLE3_STACK ( )

◆ SK_DUMP_LINE_FORMAT

#define SK_DUMP_LINE_FORMAT (   message)    SkDebugf("%s:%d: fatal error: \"%s\"\n", __FILE__, __LINE__, message)

◆ SK_ENABLE_LEGACY_SHADERCONTEXT

#define SK_ENABLE_LEGACY_SHADERCONTEXT

◆ SK_G32_SHIFT

#define SK_G32_SHIFT   8

◆ SK_GAMMA_EXPONENT

#define SK_GAMMA_EXPONENT   (0.0f)

◆ SK_GL

#define SK_GL

If GPU is enabled but no GPU backends are enabled then enable GL by default.

Traditionally clients have relied on Skia always building with the GL backend and opting in to additional backends. TODO: Require explicit opt in for GL.

◆ SK_HISTOGRAM_BOOLEAN

#define SK_HISTOGRAM_BOOLEAN (   name,
  value 
)

◆ SK_HISTOGRAM_ENUMERATION

#define SK_HISTOGRAM_ENUMERATION (   name,
  value,
  boundary_value 
)

◆ SK_HISTOGRAMS_ENABLED

#define SK_HISTOGRAMS_ENABLED   0

◆ SK_NEVER_INLINE

#define SK_NEVER_INLINE   SK_ATTRIBUTE(noinline)

If your judgment is better than the compiler's (i.e.

you've profiled it), you can use SK_NEVER_INLINE to prevent inlining.

◆ SK_NOTHING_ARG1

#define SK_NOTHING_ARG1 (   arg1)

◆ SK_NOTHING_ARG2

#define SK_NOTHING_ARG2 (   arg1,
  arg2 
)

◆ SK_NOTHING_ARG3

#define SK_NOTHING_ARG3 (   arg1,
  arg2,
  arg3 
)

◆ SK_PMCOLOR_BYTE_ORDER

#define SK_PMCOLOR_BYTE_ORDER (   C0,
  C1,
  C2,
  C3 
)
Value:
(SK_ ## C0 ## 32_SHIFT == 0 && \
SK_ ## C1 ## 32_SHIFT == 8 && \
SK_ ## C2 ## 32_SHIFT == 16 && \
SK_ ## C3 ## 32_SHIFT == 24)

SK_PMCOLOR_BYTE_ORDER can be used to query the byte order of SkPMColor at compile time.

The relationship between the byte order and shift values depends on machine endianness. If the shift order is R=0, G=8, B=16, A=24 then ((char*)&pmcolor)[0] will produce the R channel on a little endian machine and the A channel on a big endian machine. Thus, given those shifts values, SK_PMCOLOR_BYTE_ORDER(R,G,B,A) will be true on a little endian machine and SK_PMCOLOR_BYTE_ORDER(A,B,G,R) will be true on a big endian machine.

◆ SK_PREFETCH

#define SK_PREFETCH (   ptr)

◆ SK_PRINTF_LIKE

#define SK_PRINTF_LIKE (   A,
 
)

◆ SK_R32_SHIFT

#define SK_R32_SHIFT   0

◆ SK_RESTRICT

#define SK_RESTRICT   __restrict__

◆ SK_SIZE_T_SPECIFIER

#define SK_SIZE_T_SPECIFIER   "%zu"

◆ SK_SPI

#define SK_SPI   SK_API

◆ SK_SUPPORT_ATLAS_TEXT

#define SK_SUPPORT_ATLAS_TEXT   0

◆ SK_SUPPORT_GPU

#define SK_SUPPORT_GPU   1

◆ SK_UNUSED

#define SK_UNUSED   SK_ATTRIBUTE(unused)

◆ SK_WARN_UNUSED_RESULT

#define SK_WARN_UNUSED_RESULT   __attribute__((warn_unused_result))

◆ SkASSERT

#define SkASSERT (   cond)    SkASSERT_RELEASE(cond)

◆ SkASSERT_RELEASE

#define SkASSERT_RELEASE (   cond)    static_cast<void>( (cond) ? (void)0 : []{ SK_ABORT("assert(" #cond ")"); }() )

◆ SkASSERTF

#define SkASSERTF (   cond,
  fmt,
  ... 
)
Value:
static_cast<void>( (cond) ? (void)0 : [&]{ \
SkDebugf(fmt"\n", __VA_ARGS__); \
SK_ABORT("assert(" #cond ")"); \
}() )

◆ SkAssertResult

#define SkAssertResult (   cond)    SkASSERT(cond)

◆ SkDEBUGCODE

#define SkDEBUGCODE (   ...)    __VA_ARGS__

◆ SkDEBUGF

#define SkDEBUGF (   ...)    SkDebugf(__VA_ARGS__)

◆ SkDEBUGFAIL

#define SkDEBUGFAIL (   message)    SK_ABORT(message)

◆ SkDEBUGFAILF

#define SkDEBUGFAILF (   fmt,
  ... 
)    SkASSERTF(false, fmt, ##__VA_ARGS__)

◆ SKIA_IMPLEMENTATION

#define SKIA_IMPLEMENTATION   0

◆ SkUNREACHABLE

#define SkUNREACHABLE   __builtin_unreachable()

Typedef Documentation

◆ SkFourByteTag

typedef uint32_t SkFourByteTag

◆ SkGlyphID

typedef uint16_t SkGlyphID

16 bit unsigned integer to hold a glyph index

◆ SkMSec

typedef uint32_t SkMSec

32 bit value to hold a millisecond duration Note that SK_MSecMax is about 25 days.

◆ SkUnichar

typedef int32_t SkUnichar

32 bit integer to hold a unicode value

◆ U16CPU

typedef unsigned U16CPU

Fast type for unsigned 16 bits.

Use for parameter passing and local variables, not for storage

◆ U8CPU

typedef unsigned U8CPU

Fast type for unsigned 8 bits.

Use for parameter passing and local variables, not for storage

Enumeration Type Documentation

◆ SkBackingFit

enum SkBackingFit
strong

Indicates whether a backing store needs to be an exact match or can be larger than is strictly necessary.

Enumerator
kApprox 
kExact 

◆ SkBudgeted

enum SkBudgeted : bool
strong

Indicates whether an allocation should count against a cache budget.

Enumerator
kNo 
kYes 

Function Documentation

◆ sk_abort_no_print()

SK_API void sk_abort_no_print ( void  )

Called internally if we hit an unrecoverable error.

The platform implementation must not return, but should either throw an exception or otherwise exit.

◆ SkAbs32()

static int32_t SkAbs32 ( int32_t  value)
inlinestatic

◆ SkAlign2()

template<typename T >
static constexpr T SkAlign2 ( x)
static

◆ SkAlign4()

template<typename T >
static constexpr T SkAlign4 ( x)
static

◆ SkAlign8()

template<typename T >
static constexpr T SkAlign8 ( x)
static

◆ SkAlignPtr()

template<typename T >
static constexpr T SkAlignPtr ( x)
static

◆ SkArrayCountHelper()

template<typename T , size_t N>
char(& SkArrayCountHelper ( T(&)  array[N]) )[N]
Returns
the number of entries in an array (not a pointer)

◆ SkDebugf()

SK_API void SkDebugf ( const char  format[],
  ... 
)

◆ SkIsAlign2()

template<typename T >
static constexpr bool SkIsAlign2 ( x)
static

◆ SkIsAlign4()

template<typename T >
static constexpr bool SkIsAlign4 ( x)
static

◆ SkIsAlign8()

template<typename T >
static constexpr bool SkIsAlign8 ( x)
static

◆ SkIsAlignPtr()

template<typename T >
static constexpr bool SkIsAlignPtr ( x)
static

◆ SkLeftShift() [1/2]

static constexpr int32_t SkLeftShift ( int32_t  value,
int32_t  shift 
)
inlinestatic

◆ SkLeftShift() [2/2]

static constexpr int64_t SkLeftShift ( int64_t  value,
int32_t  shift 
)
inlinestatic

◆ SkSetFourByteTag()

static constexpr SkFourByteTag SkSetFourByteTag ( char  a,
char  b,
char  c,
char  d 
)
inlinestatic

◆ SkTAbs()

template<typename T >
static T SkTAbs ( value)
inlinestatic

◆ SkToBool()

template<typename T >
static constexpr bool SkToBool ( const T &  x)
static
Returns
false or true based on the condition

◆ SkTPin()

template<typename T >
static constexpr const T& SkTPin ( const T &  value,
const T &  min,
const T &  max 
)
static
Returns
value pinned (clamped) between min and max, inclusively.

NOTE: Unlike std::clamp, SkTPin has well-defined behavior if 'value' is a floating point NaN. In that case, 'max' is returned.

Variable Documentation

◆ SK_InvalidGenID

constexpr uint32_t SK_InvalidGenID = 0
static

The generation IDs in Skia reserve 0 has an invalid marker.

◆ SK_InvalidUniqueID

constexpr uint32_t SK_InvalidUniqueID = 0
static

The unique IDs in Skia reserve 0 has an invalid marker.

◆ SK_MaxS16

constexpr int16_t SK_MaxS16 = INT16_MAX
static

◆ SK_MaxS32

constexpr int32_t SK_MaxS32 = INT32_MAX
static

◆ SK_MaxS64

constexpr int64_t SK_MaxS64 = INT64_MAX
static

◆ SK_MinS16

constexpr int16_t SK_MinS16 = -SK_MaxS16
static

◆ SK_MinS32

constexpr int32_t SK_MinS32 = -SK_MaxS32
static

◆ SK_MinS64

constexpr int64_t SK_MinS64 = -SK_MaxS64
static

◆ SK_MSecMax

constexpr SkMSec SK_MSecMax = INT32_MAX
static

Maximum representable milliseconds; 24d 20h 31m 23.647s.

◆ SK_NaN32

constexpr int32_t SK_NaN32 = INT32_MIN
static