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

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

Issue 1737363002: fix undefined signed shifts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: try again on nan Created 4 years, 10 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 | « include/core/SkTypes.h ('k') | src/gpu/effects/GrMatrixConvolutionEffect.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 /* 2 /*
3 * Copyright 2008 The Android Open Source Project 3 * Copyright 2008 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #ifndef SkFloatBits_DEFINED 10 #ifndef SkFloatBits_DEFINED
(...skipping 14 matching lines...) Expand all
25 } 25 }
26 26
27 /** Convert a 2s compliment int to a sign-bit (i.e. int interpreted as float). 27 /** Convert a 2s compliment int to a sign-bit (i.e. int interpreted as float).
28 This undoes the result of SkSignBitTo2sCompliment(). 28 This undoes the result of SkSignBitTo2sCompliment().
29 */ 29 */
30 static inline int32_t Sk2sComplimentToSignBit(int32_t x) { 30 static inline int32_t Sk2sComplimentToSignBit(int32_t x) {
31 int sign = x >> 31; 31 int sign = x >> 31;
32 // make x positive 32 // make x positive
33 x = (x ^ sign) - sign; 33 x = (x ^ sign) - sign;
34 // set the sign bit as needed 34 // set the sign bit as needed
35 x |= sign << 31; 35 x |= SkLeftShift(sign, 31);
36 return x; 36 return x;
37 } 37 }
38 38
39 /** Given the bit representation of a float, return its value cast to an int. 39 /** Given the bit representation of a float, return its value cast to an int.
40 If the value is out of range, or NaN, return return +/- SK_MaxS32 40 If the value is out of range, or NaN, return return +/- SK_MaxS32
41 */ 41 */
42 int32_t SkFloatBits_toIntCast(int32_t floatBits); 42 int32_t SkFloatBits_toIntCast(int32_t floatBits);
43 43
44 /** Given the bit representation of a float, return its floor as an int. 44 /** Given the bit representation of a float, return its floor as an int.
45 If the value is out of range, or NaN, return return +/- SK_MaxS32 45 If the value is out of range, or NaN, return return +/- SK_MaxS32
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 static inline int32_t SkFloatToIntCeil(float x) { 123 static inline int32_t SkFloatToIntCeil(float x) {
124 return SkFloatBits_toIntCeil(SkFloat2Bits(x)); 124 return SkFloatBits_toIntCeil(SkFloat2Bits(x));
125 } 125 }
126 126
127 // Scalar wrappers for float-bit routines 127 // Scalar wrappers for float-bit routines
128 128
129 #define SkScalarAs2sCompliment(x) SkFloatAs2sCompliment(x) 129 #define SkScalarAs2sCompliment(x) SkFloatAs2sCompliment(x)
130 #define Sk2sComplimentAsScalar(x) Sk2sComplimentAsFloat(x) 130 #define Sk2sComplimentAsScalar(x) Sk2sComplimentAsFloat(x)
131 131
132 #endif 132 #endif
OLDNEW
« no previous file with comments | « include/core/SkTypes.h ('k') | src/gpu/effects/GrMatrixConvolutionEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698