diff options
author | Mike Reed <reed@google.com> | 2017-12-13 08:22:13 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-13 13:41:32 +0000 |
commit | c8226728541fdd6434a7f1b97678246202b0edc5 (patch) | |
tree | 3443b3f2f2fb5408b3abe999390470ef0c35eff0 /src/core/SkMathPriv.h | |
parent | 526c39f41f62f9ab82ebbeb30cc8762bb0eaa417 (diff) |
impl SkSerial picture procs
The picture serialization code is a bit of a mess, with duplicated functions for streams and buffers.
Could not see how to fix that and land this at the same time, but I will try to circle back and
simplify if possible afterwards.
Bug: skia:
Change-Id: I9053fdc476c60f483df013d021e248258181c199
Reviewed-on: https://skia-review.googlesource.com/83943
Reviewed-by: Florin Malita <fmalita@chromium.org>
Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/core/SkMathPriv.h')
-rw-r--r-- | src/core/SkMathPriv.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/core/SkMathPriv.h b/src/core/SkMathPriv.h index ddb231507f..6c33e36747 100644 --- a/src/core/SkMathPriv.h +++ b/src/core/SkMathPriv.h @@ -49,6 +49,21 @@ static inline unsigned SkClampUMax(unsigned value, unsigned max) { return value; } +// If a signed int holds min_int (e.g. 0x80000000) it is undefined what happens when +// we negate it (even though we *know* we're 2's complement and we'll get the same +// value back). So we create this helper function that casts to size_t (unsigned) first, +// to avoid the complaint. +static inline size_t sk_negate_to_size_t(int32_t value) { +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable : 4146) // Thanks MSVC, we know what we're negating an unsigned +#endif + return -static_cast<size_t>(value); +#if defined(_MSC_VER) +#pragma warning(pop) +#endif +} + /////////////////////////////////////////////////////////////////////////////// /** Return a*b/255, truncating away any fractional bits. Only valid if both |