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

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

Issue 1000933003: Remove SkLONGLONG. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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 | « gyp/common_conditions.gypi ('k') | include/core/SkPostConfig.h » ('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 #define SkFixedCeilToInt(x) (((x) + SK_Fixed1 - 1) >> 16) 71 #define SkFixedCeilToInt(x) (((x) + SK_Fixed1 - 1) >> 16)
72 #define SkFixedFloorToInt(x) ((x) >> 16) 72 #define SkFixedFloorToInt(x) ((x) >> 16)
73 73
74 #define SkFixedRoundToFixed(x) (((x) + SK_FixedHalf) & 0xFFFF0000) 74 #define SkFixedRoundToFixed(x) (((x) + SK_FixedHalf) & 0xFFFF0000)
75 #define SkFixedCeilToFixed(x) (((x) + SK_Fixed1 - 1) & 0xFFFF0000) 75 #define SkFixedCeilToFixed(x) (((x) + SK_Fixed1 - 1) & 0xFFFF0000)
76 #define SkFixedFloorToFixed(x) ((x) & 0xFFFF0000) 76 #define SkFixedFloorToFixed(x) ((x) & 0xFFFF0000)
77 77
78 #define SkFixedAbs(x) SkAbs32(x) 78 #define SkFixedAbs(x) SkAbs32(x)
79 #define SkFixedAve(a, b) (((a) + (b)) >> 1) 79 #define SkFixedAve(a, b) (((a) + (b)) >> 1)
80 80
81 SkFixed SkFixedMul_portable(SkFixed, SkFixed);
82
83 #define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16) 81 #define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16)
84 82
85 //////////////////////////////////////////////////////////////////////////////// ////////////////////// 83 //////////////////////////////////////////////////////////////////////////////// //////////////////////
86 // 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)
87 85
88 #ifdef SkLONGLONG 86 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) {
89 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) 87 return (SkFixed)((int64_t)a * b >> 16);
90 { 88 }
91 return (SkFixed)((int64_t)a * b >> 16); 89 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b)
92 } 90
93 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b)
94 #endif
95 91
96 #if defined(SK_CPU_ARM32) 92 #if defined(SK_CPU_ARM32)
97 /* This guy does not handle NaN or other obscurities, but is faster than 93 /* This guy does not handle NaN or other obscurities, but is faster than
98 than (int)(x*65536). When built on Android with -Os, needs forcing 94 than (int)(x*65536). When built on Android with -Os, needs forcing
99 to inline or we lose the speed benefit. 95 to inline or we lose the speed benefit.
100 */ 96 */
101 SK_ALWAYS_INLINE SkFixed SkFloatToFixed_arm(float x) 97 SK_ALWAYS_INLINE SkFixed SkFloatToFixed_arm(float x)
102 { 98 {
103 int32_t y, z; 99 int32_t y, z;
104 asm("movs %1, %3, lsl #1 \n" 100 asm("movs %1, %3, lsl #1 \n"
(...skipping 22 matching lines...) Expand all
127 ); 123 );
128 return x; 124 return x;
129 } 125 }
130 #undef SkFixedMul 126 #undef SkFixedMul
131 #define SkFixedMul(x, y) SkFixedMul_arm(x, y) 127 #define SkFixedMul(x, y) SkFixedMul_arm(x, y)
132 128
133 #undef SkFloatToFixed 129 #undef SkFloatToFixed
134 #define SkFloatToFixed(x) SkFloatToFixed_arm(x) 130 #define SkFloatToFixed(x) SkFloatToFixed_arm(x)
135 #endif 131 #endif
136 132
137 #ifndef SkFixedMul
138 #define SkFixedMul(x, y) SkFixedMul_portable(x, y)
139 #endif
140
141 /////////////////////////////////////////////////////////////////////////////// 133 ///////////////////////////////////////////////////////////////////////////////
142 134
143 typedef int64_t SkFixed3232; // 32.32 135 typedef int64_t SkFixed3232; // 32.32
144 136
145 #define SkIntToFixed3232(x) ((SkFixed3232)(x) << 32) 137 #define SkIntToFixed3232(x) ((SkFixed3232)(x) << 32)
146 #define SkFixed3232ToInt(x) ((int)((x) >> 32)) 138 #define SkFixed3232ToInt(x) ((int)((x) >> 32))
147 #define SkFixedToFixed3232(x) ((SkFixed3232)(x) << 16) 139 #define SkFixedToFixed3232(x) ((SkFixed3232)(x) << 16)
148 #define SkFixed3232ToFixed(x) ((SkFixed)((x) >> 16)) 140 #define SkFixed3232ToFixed(x) ((SkFixed)((x) >> 16))
149 #define SkFloatToFixed3232(x) ((SkFixed3232)((x) * (65536.0f * 65536.0f))) 141 #define SkFloatToFixed3232(x) ((SkFixed3232)((x) * (65536.0f * 65536.0f)))
150 142
151 #define SkScalarToFixed3232(x) SkFloatToFixed3232(x) 143 #define SkScalarToFixed3232(x) SkFloatToFixed3232(x)
152 144
153 /////////////////////////////////////////////////////////////////////////////// 145 ///////////////////////////////////////////////////////////////////////////////
154 146
155 // 64bits wide, with a 16bit bias. Useful when accumulating lots of 16.16 so 147 // 64bits wide, with a 16bit bias. Useful when accumulating lots of 16.16 so
156 // we don't overflow along the way 148 // we don't overflow along the way
157 typedef int64_t Sk48Dot16; 149 typedef int64_t Sk48Dot16;
158 150
159 #define Sk48Dot16FloorToInt(x) static_cast<int>((x) >> 16) 151 #define Sk48Dot16FloorToInt(x) static_cast<int>((x) >> 16)
160 152
161 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) { 153 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) {
162 return static_cast<float>(x * 1.5258789e-5); // x * (1.0f / (1 << 16)) 154 return static_cast<float>(x * 1.5258789e-5); // x * (1.0f / (1 << 16))
163 } 155 }
164 #define SkFloatTo48Dot16(x) (static_cast<Sk48Dot16>((x) * (1 << 16))) 156 #define SkFloatTo48Dot16(x) (static_cast<Sk48Dot16>((x) * (1 << 16)))
165 157
166 #define SkScalarTo48Dot16(x) SkFloatTo48Dot16(x) 158 #define SkScalarTo48Dot16(x) SkFloatTo48Dot16(x)
167 159
168 #endif 160 #endif
OLDNEW
« no previous file with comments | « gyp/common_conditions.gypi ('k') | include/core/SkPostConfig.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698