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

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

Issue 849333002: use log2(scale) to compute mip level (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 5 years, 11 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 | « expectations/gm/ignored-tests.txt ('k') | include/core/SkScalar.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 SkFloatingPoint_DEFINED 10 #ifndef SkFloatingPoint_DEFINED
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 #define sk_float_acos(x) acosf(x) 84 #define sk_float_acos(x) acosf(x)
85 #define sk_float_asin(x) asinf(x) 85 #define sk_float_asin(x) asinf(x)
86 #endif 86 #endif
87 #define sk_float_atan2(y,x) atan2f(y,x) 87 #define sk_float_atan2(y,x) atan2f(y,x)
88 #define sk_float_abs(x) fabsf(x) 88 #define sk_float_abs(x) fabsf(x)
89 #define sk_float_mod(x,y) fmodf(x,y) 89 #define sk_float_mod(x,y) fmodf(x,y)
90 #define sk_float_exp(x) expf(x) 90 #define sk_float_exp(x) expf(x)
91 #define sk_float_log(x) logf(x) 91 #define sk_float_log(x) logf(x)
92 #endif 92 #endif
93 93
94 // can't find log2f on android, but maybe that just a tool bug?
95 #ifdef SK_BUILD_FOR_ANDROID
96 static inline float sk_float_log2(float x) {
97 const double inv_ln_2 = 1.44269504088896;
98 return (float)(log(x) * inv_ln_2);
99 }
100 #else
101 #define sk_float_log2(x) log2f(x)
102 #endif
103
94 #ifdef SK_BUILD_FOR_WIN 104 #ifdef SK_BUILD_FOR_WIN
95 #define sk_float_isfinite(x) _finite(x) 105 #define sk_float_isfinite(x) _finite(x)
96 #define sk_float_isnan(x) _isnan(x) 106 #define sk_float_isnan(x) _isnan(x)
97 static inline int sk_float_isinf(float x) { 107 static inline int sk_float_isinf(float x) {
98 int32_t bits = SkFloat2Bits(x); 108 int32_t bits = SkFloat2Bits(x);
99 return (bits << 1) == (0xFF << 24); 109 return (bits << 1) == (0xFF << 24);
100 } 110 }
101 #else 111 #else
102 #define sk_float_isfinite(x) isfinite(x) 112 #define sk_float_isfinite(x) isfinite(x)
103 #define sk_float_isnan(x) isnan(x) 113 #define sk_float_isnan(x) isnan(x)
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 float estimate = *SkTCast<float*>(&i); 175 float estimate = *SkTCast<float*>(&i);
166 176
167 // One step of Newton's method to refine. 177 // One step of Newton's method to refine.
168 const float estimate_sq = estimate*estimate; 178 const float estimate_sq = estimate*estimate;
169 estimate *= (1.5f-0.5f*x*estimate_sq); 179 estimate *= (1.5f-0.5f*x*estimate_sq);
170 return estimate; 180 return estimate;
171 #endif 181 #endif
172 } 182 }
173 183
174 #endif 184 #endif
OLDNEW
« no previous file with comments | « expectations/gm/ignored-tests.txt ('k') | include/core/SkScalar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698