Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
SkAlign.h File Reference
#include "include/private/base/SkAssert.h"
#include <cstddef>

Go to the source code of this file.

Functions

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 size_t SkAlignTo (size_t x, size_t alignment)
 

Function Documentation

◆ SkAlign2()

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

Definition at line 15 of file SkAlign.h.

15{ return (x + 1) >> 1 << 1; }
double x

◆ SkAlign4()

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

Definition at line 16 of file SkAlign.h.

16{ return (x + 3) >> 2 << 2; }

◆ SkAlign8()

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

Definition at line 17 of file SkAlign.h.

17{ return (x + 7) >> 3 << 3; }

◆ SkAlignPtr()

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

Definition at line 23 of file SkAlign.h.

23 {
24 return sizeof(void*) == 8 ? SkAlign8(x) : SkAlign4(x);
25}
static constexpr T SkAlign4(T x)
Definition SkAlign.h:16
static constexpr T SkAlign8(T x)
Definition SkAlign.h:17

◆ SkAlignTo()

static constexpr size_t SkAlignTo ( size_t  x,
size_t  alignment 
)
inlinestaticconstexpr

align up to a power of 2

Definition at line 33 of file SkAlign.h.

33 {
34 // The same as alignment && SkIsPow2(value), w/o a dependency cycle.
35 SkASSERT(alignment && (alignment & (alignment - 1)) == 0);
36 return (x + alignment - 1) & ~(alignment - 1);
37}
#define SkASSERT(cond)
Definition SkAssert.h:116

◆ SkIsAlign2()

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

Definition at line 19 of file SkAlign.h.

19{ return 0 == (x & 1); }

◆ SkIsAlign4()

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

Definition at line 20 of file SkAlign.h.

20{ return 0 == (x & 3); }

◆ SkIsAlign8()

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

Definition at line 21 of file SkAlign.h.

21{ return 0 == (x & 7); }

◆ SkIsAlignPtr()

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

Definition at line 26 of file SkAlign.h.

26 {
27 return sizeof(void*) == 8 ? SkIsAlign8(x) : SkIsAlign4(x);
28}
static constexpr bool SkIsAlign8(T x)
Definition SkAlign.h:21
static constexpr bool SkIsAlign4(T x)
Definition SkAlign.h:20