diff options
author | Mike Reed <reed@google.com> | 2017-12-21 21:54:32 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-12-22 03:13:25 +0000 |
commit | 5c68dce7750a5525a5cfae29943716ce5c0d51b3 (patch) | |
tree | 1a3ba39a65deeb0c8b4d1c03722768a5f4830699 /src/core/SkMath.cpp | |
parent | bdc453db784bd91e5cee55004075bb195ca7a743 (diff) |
add safemath version of readbuffer->skip
Bug: skia:
Change-Id: I6a5d24569cc1bd93bd190d81e3375993da9c56f0
Reviewed-on: https://skia-review.googlesource.com/88581
Commit-Queue: Mike Reed <reed@google.com>
Reviewed-by: Herb Derby <herb@google.com>
Reviewed-by: Mike Klein <mtklein@chromium.org>
Diffstat (limited to 'src/core/SkMath.cpp')
-rw-r--r-- | src/core/SkMath.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/core/SkMath.cpp b/src/core/SkMath.cpp index 6eff790c85..58645dab8f 100644 --- a/src/core/SkMath.cpp +++ b/src/core/SkMath.cpp @@ -9,6 +9,7 @@ #include "SkFixed.h" #include "SkFloatBits.h" #include "SkFloatingPoint.h" +#include "SkSafeMath.h" #include "SkScalar.h" #define sub_shift(zeros, x, n) \ @@ -67,8 +68,6 @@ int32_t SkSqrtBits(int32_t x, int count) { return root; } -/////////////////////////////////////////////////////////////////////////////// - float SkScalarSinCos(float radians, float* cosValue) { float sinValue = sk_float_sin(radians); @@ -84,3 +83,17 @@ float SkScalarSinCos(float radians, float* cosValue) { } return sinValue; } + +/////////////////////////////////////////////////////////////////////////////////////////////////// + +size_t SkSafeMath::Add(size_t x, size_t y) { + SkSafeMath tmp; + size_t sum = tmp.add(x, y); + return tmp.ok() ? sum : SK_MaxSizeT; +} + +size_t SkSafeMath::Mul(size_t x, size_t y) { + SkSafeMath tmp; + size_t prod = tmp.mul(x, y); + return tmp.ok() ? prod : SK_MaxSizeT; +} |