Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
SkMath.h File Reference
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkCPUTypes.h"
#include <cstdint>
#include <climits>

Go to the source code of this file.

Functions

static int64_t sk_64_mul (int64_t a, int64_t b)
 
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 >
constexpr bool SkIsPow2 (T value)
 
static unsigned SkMul16ShiftRound (U16CPU a, U16CPU b, int shift)
 
static U8CPU SkMulDiv255Round (U16CPU a, U16CPU b)
 

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
 

Function Documentation

◆ sk_64_mul()

static int64_t sk_64_mul ( int64_t  a,
int64_t  b 
)
inlinestatic

Definition at line 33 of file SkMath.h.

33 {
34 return a * b;
35}
static bool b
struct MyStruct a[10]

◆ SkIsPow2()

template<typename T >
constexpr bool SkIsPow2 ( T  value)
inlineconstexpr

Returns true if value is a power of 2. Does not explicitly check for value <= 0.

Definition at line 51 of file SkMath.h.

51 {
52 return (value & (value - 1)) == 0;
53}

◆ SkLeftShift() [1/2]

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

Definition at line 37 of file SkMath.h.

37 {
38 return (int32_t) ((uint32_t) value << shift);
39}

◆ SkLeftShift() [2/2]

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

Definition at line 41 of file SkMath.h.

41 {
42 return (int64_t) ((uint64_t) value << shift);
43}

◆ SkMul16ShiftRound()

static unsigned SkMul16ShiftRound ( U16CPU  a,
U16CPU  b,
int  shift 
)
inlinestatic

Return a*b/((1 << shift) - 1), rounding any fractional bits. Only valid if a and b are unsigned and <= 32767 and shift is > 0 and <= 8

Definition at line 61 of file SkMath.h.

61 {
62 SkASSERT(a <= 32767);
63 SkASSERT(b <= 32767);
64 SkASSERT(shift > 0 && shift <= 8);
65 unsigned prod = a*b + (1 << (shift - 1));
66 return (prod + (prod >> shift)) >> shift;
67}
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ SkMulDiv255Round()

static U8CPU SkMulDiv255Round ( U16CPU  a,
U16CPU  b 
)
inlinestatic

Return a*b/255, rounding any fractional bits. Only valid if a and b are unsigned and <= 32767.

Definition at line 73 of file SkMath.h.

73 {
74 return SkMul16ShiftRound(a, b, 8);
75}
static unsigned SkMul16ShiftRound(U16CPU a, U16CPU b, int shift)
Definition SkMath.h:61

Variable Documentation

◆ SK_MaxS16

constexpr int16_t SK_MaxS16 = INT16_MAX
staticconstexpr

Definition at line 18 of file SkMath.h.

◆ SK_MaxS32

constexpr int32_t SK_MaxS32 = INT32_MAX
staticconstexpr

Definition at line 21 of file SkMath.h.

◆ SK_MaxS64

constexpr int64_t SK_MaxS64 = INT64_MAX
staticconstexpr

Definition at line 25 of file SkMath.h.

◆ SK_MinS16

constexpr int16_t SK_MinS16 = -SK_MaxS16
staticconstexpr

Definition at line 19 of file SkMath.h.

◆ SK_MinS32

constexpr int32_t SK_MinS32 = -SK_MaxS32
staticconstexpr

Definition at line 22 of file SkMath.h.

◆ SK_MinS64

constexpr int64_t SK_MinS64 = -SK_MaxS64
staticconstexpr

Definition at line 26 of file SkMath.h.

◆ SK_NaN32

constexpr int32_t SK_NaN32 = INT32_MIN
staticconstexpr

Definition at line 23 of file SkMath.h.