aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/private/SkFixed.h
diff options
context:
space:
mode:
authorGravatar liyuqian <liyuqian@google.com>2016-10-20 11:23:09 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-10-20 11:23:10 -0700
commit3f490cc642202c8ab3d51a8ffbd1782c63b9e6a0 (patch)
tree763edb05d5466380f7669d812b4b829996272717 /include/private/SkFixed.h
parentc0d550143e813c57aa445f47f788aaf5c8cc2cd7 (diff)
Make SkFixedRound/Ceil/FloorToFixed as inline func
The macros that we were using will return unsigned int32 instead of signed int32 because of the last 0xFFFF0000 mask. That may bring problems if we right shift that result. Special thanks to mtklein@google.com for helping me find out this issue. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2433233003 Review-Url: https://chromiumcodereview.appspot.com/2433233003
Diffstat (limited to 'include/private/SkFixed.h')
-rw-r--r--include/private/SkFixed.h12
1 files changed, 9 insertions, 3 deletions
diff --git a/include/private/SkFixed.h b/include/private/SkFixed.h
index be3bb5d604..cdde093007 100644
--- a/include/private/SkFixed.h
+++ b/include/private/SkFixed.h
@@ -69,9 +69,15 @@ typedef int32_t SkFixed;
#define SkFixedCeilToInt(x) (((x) + SK_Fixed1 - 1) >> 16)
#define SkFixedFloorToInt(x) ((x) >> 16)
-#define SkFixedRoundToFixed(x) (((x) + SK_FixedHalf) & 0xFFFF0000)
-#define SkFixedCeilToFixed(x) (((x) + SK_Fixed1 - 1) & 0xFFFF0000)
-#define SkFixedFloorToFixed(x) ((x) & 0xFFFF0000)
+static inline SkFixed SkFixedRoundToFixed(SkFixed x) {
+ return (x + SK_FixedHalf) & 0xFFFF0000;
+}
+static inline SkFixed SkFixedCeilToFixed(SkFixed x) {
+ return (x + SK_Fixed1 - 1) & 0xFFFF0000;
+}
+static inline SkFixed SkFixedFloorToFixed(SkFixed x) {
+ return x & 0xFFFF0000;
+}
#define SkFixedAbs(x) SkAbs32(x)
#define SkFixedAve(a, b) (((a) + (b)) >> 1)