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

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

Issue 1022543003: 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 #define SkFixedDiv(numer, denom) SkDivBits(numer, denom, 16) 81 static inline int32_t SkFixedDiv(int32_t numer, int32_t denom) {
82 int64_t tmp = ((int64_t)numer << 16) / denom;
83 return (int32_t)tmp;
84 }
82 85
83 //////////////////////////////////////////////////////////////////////////////// ////////////////////// 86 //////////////////////////////////////////////////////////////////////////////// //////////////////////
84 // Now look for ASM overrides for our portable versions (should consider putting this in its own file) 87 // Now look for ASM overrides for our portable versions (should consider putting this in its own file)
85 88
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 return (SkFixed)((int64_t)a * b >> 16);
88 } 91 }
89 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b) 92 #define SkFixedMul(a,b) SkFixedMul_longlong(a,b)
90 93
91 94
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 #define Sk48Dot16FloorToInt(x) static_cast<int>((x) >> 16) 154 #define Sk48Dot16FloorToInt(x) static_cast<int>((x) >> 16)
152 155
153 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) { 156 static inline float Sk48Dot16ToScalar(Sk48Dot16 x) {
154 return static_cast<float>(x * 1.5258789e-5); // x * (1.0f / (1 << 16)) 157 return static_cast<float>(x * 1.5258789e-5); // x * (1.0f / (1 << 16))
155 } 158 }
156 #define SkFloatTo48Dot16(x) (static_cast<Sk48Dot16>((x) * (1 << 16))) 159 #define SkFloatTo48Dot16(x) (static_cast<Sk48Dot16>((x) * (1 << 16)))
157 160
158 #define SkScalarTo48Dot16(x) SkFloatTo48Dot16(x) 161 #define SkScalarTo48Dot16(x) SkFloatTo48Dot16(x)
159 162
160 #endif 163 #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