#include <SkSafeMath.h>
|
static size_t | Add (size_t x, size_t y) |
|
static size_t | Mul (size_t x, size_t y) |
|
static size_t | Align4 (size_t x) |
|
Definition at line 22 of file SkSafeMath.h.
◆ SkSafeMath()
SkSafeMath::SkSafeMath |
( |
| ) |
|
|
default |
◆ add()
size_t SkSafeMath::add |
( |
size_t |
x, |
|
|
size_t |
y |
|
) |
| |
|
inline |
◆ Add()
size_t SkSafeMath::Add |
( |
size_t |
x, |
|
|
size_t |
y |
|
) |
| |
|
static |
Definition at line 10 of file SkSafeMath.cpp.
10 {
12 size_t sum = tmp.
add(
x,
y);
13 return tmp.
ok() ? sum : SIZE_MAX;
14}
size_t add(size_t x, size_t y)
◆ addInt()
Return a + b, unless this result is an overflow/underflow. In those cases, fOK will be set to false, and it is undefined what this returns.
Definition at line 43 of file SkSafeMath.h.
43 {
45 fOK = false;
48 fOK = false;
50 }
52 }
static float max(float r, float g, float b)
static float min(float r, float g, float b)
◆ Align4()
static size_t SkSafeMath::Align4 |
( |
size_t |
x | ) |
|
|
inlinestatic |
Definition at line 69 of file SkSafeMath.h.
69 {
72 }
size_t alignUp(size_t x, size_t alignment)
◆ alignUp()
size_t SkSafeMath::alignUp |
( |
size_t |
x, |
|
|
size_t |
alignment |
|
) |
| |
|
inline |
Definition at line 54 of file SkSafeMath.h.
54 {
55 SkASSERT(alignment && !(alignment & (alignment - 1)));
56 return add(
x, alignment - 1) & ~(alignment - 1);
57 }
◆ castTo()
T SkSafeMath::castTo |
( |
size_t |
value | ) |
|
|
inline |
Definition at line 59 of file SkSafeMath.h.
59 {
60 if (!SkTFitsIn<T>(
value)) {
61 fOK = false;
62 }
63 return static_cast<T>(
value);
64 }
◆ mul()
size_t SkSafeMath::mul |
( |
size_t |
x, |
|
|
size_t |
y |
|
) |
| |
|
inline |
Definition at line 29 of file SkSafeMath.h.
29 {
30 return sizeof(size_t) ==
sizeof(uint64_t) ? mul64(
x,
y) : mul32(
x,
y);
31 }
◆ Mul()
size_t SkSafeMath::Mul |
( |
size_t |
x, |
|
|
size_t |
y |
|
) |
| |
|
static |
Definition at line 16 of file SkSafeMath.cpp.
16 {
18 size_t prod = tmp.
mul(
x,
y);
19 return tmp.
ok() ? prod : SIZE_MAX;
20}
size_t mul(size_t x, size_t y)
◆ ok()
bool SkSafeMath::ok |
( |
| ) |
const |
|
inline |
◆ operator bool()
SkSafeMath::operator bool |
( |
| ) |
const |
|
inlineexplicit |
The documentation for this class was generated from the following files: