Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: include/private/SkFixed.h

Issue 2149733002: Fix SkFixedDiv macro (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tests/MathTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2006 The Android Open Source Project 2 * Copyright 2006 The Android Open Source Project
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkFixed_DEFINED 8 #ifndef SkFixed_DEFINED
9 #define SkFixed_DEFINED 9 #define SkFixed_DEFINED
10 10
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 #define SkFixedRoundToFixed(x) (((x) + SK_FixedHalf) & 0xFFFF0000) 72 #define SkFixedRoundToFixed(x) (((x) + SK_FixedHalf) & 0xFFFF0000)
73 #define SkFixedCeilToFixed(x) (((x) + SK_Fixed1 - 1) & 0xFFFF0000) 73 #define SkFixedCeilToFixed(x) (((x) + SK_Fixed1 - 1) & 0xFFFF0000)
74 #define SkFixedFloorToFixed(x) ((x) & 0xFFFF0000) 74 #define SkFixedFloorToFixed(x) ((x) & 0xFFFF0000)
75 75
76 #define SkFixedAbs(x) SkAbs32(x) 76 #define SkFixedAbs(x) SkAbs32(x)
77 #define SkFixedAve(a, b) (((a) + (b)) >> 1) 77 #define SkFixedAve(a, b) (((a) + (b)) >> 1)
78 78
79 // The divide may exceed 32 bits. Clamp to a signed 32 bit result. 79 // The divide may exceed 32 bits. Clamp to a signed 32 bit result.
80 #define SkFixedDiv(numer, denom) \ 80 #define SkFixedDiv(numer, denom) \
81 SkToS32(SkTPin<int64_t>((SkLeftShift((int64_t)numer, 16) / denom), SK_MinS32 , SK_MaxS32)) 81 SkToS32(SkTPin<int64_t>((SkLeftShift((int64_t)(numer), 16) / (denom)), SK_Mi nS32, SK_MaxS32))
82 82
83 //////////////////////////////////////////////////////////////////////////////// ////////////////////// 83 //////////////////////////////////////////////////////////////////////////////// //////////////////////
84 // Now look for ASM overrides for our portable versions (should consider putting this in its own file) 84 // Now look for ASM overrides for our portable versions (should consider putting this in its own file)
85 85
86 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) { 86 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) {
87 return (SkFixed)((int64_t)a * b >> 16); 87 return (SkFixed)((int64_t)a * b >> 16);
88 } 88 }
89 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b) 89 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b)
90 90
91 91
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 150
151 #define SkIntToFixed3232(x) (SkLeftShift((SkFixed3232)(x), 32)) 151 #define SkIntToFixed3232(x) (SkLeftShift((SkFixed3232)(x), 32))
152 #define SkFixed3232ToInt(x) ((int)((x) >> 32)) 152 #define SkFixed3232ToInt(x) ((int)((x) >> 32))
153 #define SkFixedToFixed3232(x) (SkLeftShift((SkFixed3232)(x), 16)) 153 #define SkFixedToFixed3232(x) (SkLeftShift((SkFixed3232)(x), 16))
154 #define SkFixed3232ToFixed(x) ((SkFixed)((x) >> 16)) 154 #define SkFixed3232ToFixed(x) ((SkFixed)((x) >> 16))
155 #define SkFloatToFixed3232(x) ((SkFixed3232)((x) * (65536.0f * 65536.0f))) 155 #define SkFloatToFixed3232(x) ((SkFixed3232)((x) * (65536.0f * 65536.0f)))
156 156
157 #define SkScalarToFixed3232(x) SkFloatToFixed3232(x) 157 #define SkScalarToFixed3232(x) SkFloatToFixed3232(x)
158 158
159 #endif 159 #endif
OLDNEW
« no previous file with comments | « no previous file | tests/MathTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698