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

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

Issue 119353003: Revert "Revert "begin to remove SkLONGLONG and wean Skia off of Sk64"" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « include/core/Sk64.h ('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 /* 2 /*
3 * Copyright 2006 The Android Open Source Project 3 * Copyright 2006 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 SkFixed_DEFINED 10 #ifndef SkFixed_DEFINED
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 // DEPRECATED 80 // DEPRECATED
81 #define SkFixedFloor(x) SkFixedFloorToInt(x) 81 #define SkFixedFloor(x) SkFixedFloorToInt(x)
82 #define SkFixedCeil(x) SkFixedCeilToInt(x) 82 #define SkFixedCeil(x) SkFixedCeilToInt(x)
83 #define SkFixedRound(x) SkFixedRoundToInt(x) 83 #define SkFixedRound(x) SkFixedRoundToInt(x)
84 84
85 #define SkFixedAbs(x) SkAbs32(x) 85 #define SkFixedAbs(x) SkAbs32(x)
86 #define SkFixedAve(a, b) (((a) + (b)) >> 1) 86 #define SkFixedAve(a, b) (((a) + (b)) >> 1)
87 87
88 SkFixed SkFixedMul_portable(SkFixed, SkFixed); 88 SkFixed SkFixedMul_portable(SkFixed, SkFixed);
89 inline SkFixed SkFixedSquare_portable(SkFixed value)
90 {
91 uint32_t a = SkAbs32(value);
92 uint32_t ah = a >> 16;
93 uint32_t al = a & 0xFFFF;
94 SkFixed result = ah * a + al * ah + (al * al >> 16);
95 if (result >= 0)
96 return result;
97 else // Overflow.
98 return SK_FixedMax;
99 }
100 89
101 #define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16) 90 #define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16)
102 91
103 /////////////////////////////////////////////////////////////////////////////// 92 ///////////////////////////////////////////////////////////////////////////////
104 // TODO: move fixed sin/cos into SkCosineMapper, as that is the only caller 93 // TODO: move fixed sin/cos into SkCosineMapper, as that is the only caller
105 // or rewrite SkCosineMapper to not use it at all 94 // or rewrite SkCosineMapper to not use it at all
106 95
107 SkFixed SkFixedSinCos(SkFixed radians, SkFixed* cosValueOrNull); 96 SkFixed SkFixedSinCos(SkFixed radians, SkFixed* cosValueOrNull);
108 #define SkFixedSin(radians) SkFixedSinCos(radians, NULL) 97 #define SkFixedSin(radians) SkFixedSinCos(radians, NULL)
109 static inline SkFixed SkFixedCos(SkFixed radians) { 98 static inline SkFixed SkFixedCos(SkFixed radians) {
110 SkFixed cosValue; 99 SkFixed cosValue;
111 (void)SkFixedSinCos(radians, &cosValue); 100 (void)SkFixedSinCos(radians, &cosValue);
112 return cosValue; 101 return cosValue;
113 } 102 }
114 103
115 //////////////////////////////////////////////////////////////////////////////// ////////////////////// 104 //////////////////////////////////////////////////////////////////////////////// //////////////////////
116 // Now look for ASM overrides for our portable versions (should consider putting this in its own file) 105 // Now look for ASM overrides for our portable versions (should consider putting this in its own file)
117 106
118 #ifdef SkLONGLONG 107 #ifdef SkLONGLONG
119 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) 108 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b)
120 { 109 {
121 return (SkFixed)((SkLONGLONG)a * b >> 16); 110 return (SkFixed)((int64_t)a * b >> 16);
122 }
123 inline SkFixed SkFixedSquare_longlong(SkFixed value)
124 {
125 return (SkFixed)((SkLONGLONG)value * value >> 16);
126 } 111 }
127 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b) 112 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b)
128 #define SkFixedSquare(a) SkFixedSquare_longlong(a)
129 #endif 113 #endif
130 114
131 #if defined(SK_CPU_ARM) 115 #if defined(SK_CPU_ARM)
132 /* This guy does not handle NaN or other obscurities, but is faster than 116 /* This guy does not handle NaN or other obscurities, but is faster than
133 than (int)(x*65536) 117 than (int)(x*65536)
134 */ 118 */
135 inline SkFixed SkFloatToFixed_arm(float x) 119 inline SkFixed SkFloatToFixed_arm(float x)
136 { 120 {
137 int32_t y, z; 121 int32_t y, z;
138 asm("movs %1, %3, lsl #1 \n" 122 asm("movs %1, %3, lsl #1 \n"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 162
179 #define SkIntToFixed48(x) ((SkFixed48)(x) << 48) 163 #define SkIntToFixed48(x) ((SkFixed48)(x) << 48)
180 #define SkFixed48ToInt(x) ((int)((x) >> 48)) 164 #define SkFixed48ToInt(x) ((int)((x) >> 48))
181 #define SkFixedToFixed48(x) ((SkFixed48)(x) << 32) 165 #define SkFixedToFixed48(x) ((SkFixed48)(x) << 32)
182 #define SkFixed48ToFixed(x) ((SkFixed)((x) >> 32)) 166 #define SkFixed48ToFixed(x) ((SkFixed)((x) >> 32))
183 #define SkFloatToFixed48(x) ((SkFixed48)((x) * (65536.0f * 65536.0f * 65536. 0f))) 167 #define SkFloatToFixed48(x) ((SkFixed48)((x) * (65536.0f * 65536.0f * 65536. 0f)))
184 168
185 #define SkScalarToFixed48(x) SkFloatToFixed48(x) 169 #define SkScalarToFixed48(x) SkFloatToFixed48(x)
186 170
187 #endif 171 #endif
OLDNEW
« no previous file with comments | « include/core/Sk64.h ('k') | include/core/SkPostConfig.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698