Flutter Engine
The Flutter Engine
Macros | Typedefs | Functions
SkFixed.h File Reference
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkDebug.h"
#include "include/private/base/SkMath.h"
#include "include/private/base/SkTPin.h"
#include <cstdint>

Go to the source code of this file.

Macros

#define SK_Fixed1   (1 << 16)
 
#define SK_FixedHalf   (1 << 15)
 
#define SK_FixedQuarter   (1 << 14)
 
#define SK_FixedMax   (0x7FFFFFFF)
 
#define SK_FixedMin   (-SK_FixedMax)
 
#define SK_FixedPI   (0x3243F)
 
#define SK_FixedSqrt2   (92682)
 
#define SK_FixedTanPIOver8   (0x6A0A)
 
#define SK_FixedRoot2Over2   (0xB505)
 
#define SkFixedToFloat(x)   ((x) * 1.52587890625e-5f)
 
#define SkFloatToFixed(x)   sk_float_saturate2int((x) * SK_Fixed1)
 
#define SkFloatToFixed_Check(x)   SkFloatToFixed(x)
 
#define SkFixedToDouble(x)   ((x) * 1.52587890625e-5)
 
#define SkDoubleToFixed(x)   ((SkFixed)((x) * SK_Fixed1))
 
#define SkIntToFixed(n)   (SkFixed)((unsigned)(n) << 16)
 
#define SkFixedRoundToInt(x)   (((x) + SK_FixedHalf) >> 16)
 
#define SkFixedCeilToInt(x)   (((x) + SK_Fixed1 - 1) >> 16)
 
#define SkFixedFloorToInt(x)   ((x) >> 16)
 
#define SkFixedAve(a, b)   (((a) + (b)) >> 1)
 
#define SkFixedDiv(numer, denom)    SkToS32(SkTPin<int64_t>((SkLeftShift((int64_t)(numer), 16) / (denom)), SK_MinS32, SK_MaxS32))
 
#define SkFixedToScalar(x)   SkFixedToFloat(x)
 
#define SkScalarToFixed(x)   SkFloatToFixed(x)
 
#define SkFixed3232Max   SK_MaxS64
 
#define SkFixed3232Min   (-SkFixed3232Max)
 
#define SkIntToFixed3232(x)   (SkLeftShift((SkFixed3232)(x), 32))
 
#define SkFixed3232ToInt(x)   ((int)((x) >> 32))
 
#define SkFixedToFixed3232(x)   (SkLeftShift((SkFixed3232)(x), 16))
 
#define SkFixed3232ToFixed(x)   ((SkFixed)((x) >> 16))
 
#define SkFloatToFixed3232(x)   sk_float_saturate2int64((x) * (65536.0f * 65536.0f))
 
#define SkFixed3232ToFloat(x)   (x * (1 / (65536.0f * 65536.0f)))
 
#define SkScalarToFixed3232(x)   SkFloatToFixed3232(x)
 

Typedefs

typedef int32_t SkFixed
 
typedef int64_t SkFixed3232
 

Functions

static SkFixed SkFixedRoundToFixed (SkFixed x)
 
static SkFixed SkFixedCeilToFixed (SkFixed x)
 
static SkFixed SkFixedFloorToFixed (SkFixed x)
 
static SkFixed SkFixedMul (SkFixed a, SkFixed b)
 

Detailed Description

Types and macros for 16.16 fixed point

Definition in file SkFixed.h.

Macro Definition Documentation

◆ SK_Fixed1

#define SK_Fixed1   (1 << 16)

Definition at line 26 of file SkFixed.h.

◆ SK_FixedHalf

#define SK_FixedHalf   (1 << 15)

Definition at line 27 of file SkFixed.h.

◆ SK_FixedMax

#define SK_FixedMax   (0x7FFFFFFF)

Definition at line 29 of file SkFixed.h.

◆ SK_FixedMin

#define SK_FixedMin   (-SK_FixedMax)

Definition at line 30 of file SkFixed.h.

◆ SK_FixedPI

#define SK_FixedPI   (0x3243F)

Definition at line 31 of file SkFixed.h.

◆ SK_FixedQuarter

#define SK_FixedQuarter   (1 << 14)

Definition at line 28 of file SkFixed.h.

◆ SK_FixedRoot2Over2

#define SK_FixedRoot2Over2   (0xB505)

Definition at line 34 of file SkFixed.h.

◆ SK_FixedSqrt2

#define SK_FixedSqrt2   (92682)

Definition at line 32 of file SkFixed.h.

◆ SK_FixedTanPIOver8

#define SK_FixedTanPIOver8   (0x6A0A)

Definition at line 33 of file SkFixed.h.

◆ SkDoubleToFixed

#define SkDoubleToFixed (   x)    ((SkFixed)((x) * SK_Fixed1))

Definition at line 56 of file SkFixed.h.

◆ SkFixed3232Max

#define SkFixed3232Max   SK_MaxS64

Definition at line 131 of file SkFixed.h.

◆ SkFixed3232Min

#define SkFixed3232Min   (-SkFixed3232Max)

Definition at line 132 of file SkFixed.h.

◆ SkFixed3232ToFixed

#define SkFixed3232ToFixed (   x)    ((SkFixed)((x) >> 16))

Definition at line 137 of file SkFixed.h.

◆ SkFixed3232ToFloat

#define SkFixed3232ToFloat (   x)    (x * (1 / (65536.0f * 65536.0f)))

Definition at line 139 of file SkFixed.h.

◆ SkFixed3232ToInt

#define SkFixed3232ToInt (   x)    ((int)((x) >> 32))

Definition at line 135 of file SkFixed.h.

◆ SkFixedAve

#define SkFixedAve (   a,
  b 
)    (((a) + (b)) >> 1)

Definition at line 90 of file SkFixed.h.

◆ SkFixedCeilToInt

#define SkFixedCeilToInt (   x)    (((x) + SK_Fixed1 - 1) >> 16)

Definition at line 77 of file SkFixed.h.

◆ SkFixedDiv

#define SkFixedDiv (   numer,
  denom 
)     SkToS32(SkTPin<int64_t>((SkLeftShift((int64_t)(numer), 16) / (denom)), SK_MinS32, SK_MaxS32))

Definition at line 93 of file SkFixed.h.

◆ SkFixedFloorToInt

#define SkFixedFloorToInt (   x)    ((x) >> 16)

Definition at line 78 of file SkFixed.h.

◆ SkFixedRoundToInt

#define SkFixedRoundToInt (   x)    (((x) + SK_FixedHalf) >> 16)

Definition at line 76 of file SkFixed.h.

◆ SkFixedToDouble

#define SkFixedToDouble (   x)    ((x) * 1.52587890625e-5)

Definition at line 55 of file SkFixed.h.

◆ SkFixedToFixed3232

#define SkFixedToFixed3232 (   x)    (SkLeftShift((SkFixed3232)(x), 16))

Definition at line 136 of file SkFixed.h.

◆ SkFixedToFloat

#define SkFixedToFloat (   x)    ((x) * 1.52587890625e-5f)

Definition at line 41 of file SkFixed.h.

◆ SkFixedToScalar

#define SkFixedToScalar (   x)    SkFixedToFloat(x)

Definition at line 124 of file SkFixed.h.

◆ SkFloatToFixed

#define SkFloatToFixed (   x)    sk_float_saturate2int((x) * SK_Fixed1)

Definition at line 42 of file SkFixed.h.

◆ SkFloatToFixed3232

#define SkFloatToFixed3232 (   x)    sk_float_saturate2int64((x) * (65536.0f * 65536.0f))

Definition at line 138 of file SkFixed.h.

◆ SkFloatToFixed_Check

#define SkFloatToFixed_Check (   x)    SkFloatToFixed(x)

Definition at line 52 of file SkFixed.h.

◆ SkIntToFixed

#define SkIntToFixed (   n)    (SkFixed)((unsigned)(n) << 16)

Converts an integer to a SkFixed, asserting that the result does not overflow a 32 bit signed integer

Definition at line 73 of file SkFixed.h.

◆ SkIntToFixed3232

#define SkIntToFixed3232 (   x)    (SkLeftShift((SkFixed3232)(x), 32))

Definition at line 134 of file SkFixed.h.

◆ SkScalarToFixed

#define SkScalarToFixed (   x)    SkFloatToFixed(x)

Definition at line 125 of file SkFixed.h.

◆ SkScalarToFixed3232

#define SkScalarToFixed3232 (   x)    SkFloatToFixed3232(x)

Definition at line 141 of file SkFixed.h.

Typedef Documentation

◆ SkFixed

typedef int32_t SkFixed

32 bit signed integer used to represent fractions values with 16 bits to the right of the decimal point

Definition at line 25 of file SkFixed.h.

◆ SkFixed3232

typedef int64_t SkFixed3232

Definition at line 129 of file SkFixed.h.

Function Documentation

◆ SkFixedCeilToFixed()

static SkFixed SkFixedCeilToFixed ( SkFixed  x)
inlinestatic

Definition at line 83 of file SkFixed.h.

83 {
84 return (SkFixed)( (uint32_t)(x + SK_Fixed1 - 1) & 0xFFFF0000 );
85}
int32_t SkFixed
Definition: SkFixed.h:25
#define SK_Fixed1
Definition: SkFixed.h:26
double x

◆ SkFixedFloorToFixed()

static SkFixed SkFixedFloorToFixed ( SkFixed  x)
inlinestatic

Definition at line 86 of file SkFixed.h.

86 {
87 return (SkFixed)( (uint32_t)x & 0xFFFF0000 );
88}

◆ SkFixedMul()

static SkFixed SkFixedMul ( SkFixed  a,
SkFixed  b 
)
inlinestatic

Definition at line 96 of file SkFixed.h.

96 {
97 return (SkFixed)((int64_t)a * b >> 16);
98}
static bool b
struct MyStruct a[10]

◆ SkFixedRoundToFixed()

static SkFixed SkFixedRoundToFixed ( SkFixed  x)
inlinestatic

Definition at line 80 of file SkFixed.h.

80 {
81 return (SkFixed)( (uint32_t)(x + SK_FixedHalf) & 0xFFFF0000 );
82}
#define SK_FixedHalf
Definition: SkFixed.h:27