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

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

Issue 1018523008: Revert of replace SkFixedDiv impl with native 64bit math (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 | « bench/MathBench.cpp ('k') | no next file » | 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 static inline int32_t SkFixedDiv(int32_t numer, int32_t denom) { 81 #define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16)
82 int64_t tmp = ((int64_t)numer << 16) / denom;
83 return (int32_t)tmp;
84 }
85 82
86 //////////////////////////////////////////////////////////////////////////////// ////////////////////// 83 //////////////////////////////////////////////////////////////////////////////// //////////////////////
87 // 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)
88 85
89 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) { 86 inline SkFixed SkFixedMul_longlong(SkFixed a, SkFixed b) {
90 return (SkFixed)((int64_t)a * b >> 16); 87 return (SkFixed)((int64_t)a * b >> 16);
91 } 88 }
92 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b) 89 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b)
93 90
94 91
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 #define Sk48Dot16FloorToInt(x) static_cast<int>((x) >> 16) 151 #define Sk48Dot16FloorToInt(x) static_cast<int>((x) >> 16)
155 152
156 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) { 153 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) {
157 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))
158 } 155 }
159 #define SkFloatTo48Dot16(x) (static_cast<Sk48Dot16>((x) * (1 << 16))) 156 #define SkFloatTo48Dot16(x) (static_cast<Sk48Dot16>((x) * (1 << 16)))
160 157
161 #define SkScalarTo48Dot16(x) SkFloatTo48Dot16(x) 158 #define SkScalarTo48Dot16(x) SkFloatTo48Dot16(x)
162 159
163 #endif 160 #endif
OLDNEW
« no previous file with comments | « bench/MathBench.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698