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

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

Issue 213153006: Fix size of rotated text with FreeType. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « gyp/utils.gyp ('k') | src/ports/SkFontHost_FreeType.cpp » ('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
11 #define SkFloatingPoint_DEFINED 11 #define SkFloatingPoint_DEFINED
12 12
13 #include "SkTypes.h" 13 #include "SkTypes.h"
14 14
15 #include <math.h> 15 #include <math.h>
16 #include <float.h> 16 #include <float.h>
17
18 // For _POSIX_VERSION
19 #if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
20 #include <unistd.h>
21 #endif
22
17 #include "SkFloatBits.h" 23 #include "SkFloatBits.h"
18 24
19 // C++98 cmath std::pow seems to be the earliest portable way to get float pow. 25 // C++98 cmath std::pow seems to be the earliest portable way to get float pow.
20 // However, on Linux including cmath undefines isfinite. 26 // However, on Linux including cmath undefines isfinite.
21 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14608 27 // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14608
22 static inline float sk_float_pow(float base, float exp) { 28 static inline float sk_float_pow(float base, float exp) {
23 return powf(base, exp); 29 return powf(base, exp);
24 } 30 }
25 31
26 static inline float sk_float_copysign(float x, float y) { 32 static inline float sk_float_copysign(float x, float y) {
33 // c++11 contains a 'float copysign(float, float)' function in <cmath>.
34 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
35 return copysign(x, y);
36
37 // Posix has demanded 'float copysignf(float, float)' (from C99) since Issue 6.
38 #elif defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L
39 return copysignf(x, y);
40
41 // Visual studio prior to 13 only has 'double _copysign(double, double)'.
42 #elif defined(_MSC_VER)
43 return _copysign(x, y);
44
45 // Otherwise convert to bits and extract sign.
46 #else
27 int32_t xbits = SkFloat2Bits(x); 47 int32_t xbits = SkFloat2Bits(x);
28 int32_t ybits = SkFloat2Bits(y); 48 int32_t ybits = SkFloat2Bits(y);
29 return SkBits2Float((xbits & 0x7FFFFFFF) | (ybits & 0x80000000)); 49 return SkBits2Float((xbits & 0x7FFFFFFF) | (ybits & 0x80000000));
50 #endif
30 } 51 }
31 52
32 #ifdef SK_BUILD_FOR_WINCE 53 #ifdef SK_BUILD_FOR_WINCE
33 #define sk_float_sqrt(x) (float)::sqrt(x) 54 #define sk_float_sqrt(x) (float)::sqrt(x)
34 #define sk_float_sin(x) (float)::sin(x) 55 #define sk_float_sin(x) (float)::sin(x)
35 #define sk_float_cos(x) (float)::cos(x) 56 #define sk_float_cos(x) (float)::cos(x)
36 #define sk_float_tan(x) (float)::tan(x) 57 #define sk_float_tan(x) (float)::tan(x)
37 #define sk_float_acos(x) (float)::acos(x) 58 #define sk_float_acos(x) (float)::acos(x)
38 #define sk_float_asin(x) (float)::asin(x) 59 #define sk_float_asin(x) (float)::asin(x)
39 #define sk_float_atan2(y,x) (float)::atan2(y,x) 60 #define sk_float_atan2(y,x) (float)::atan2(y,x)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 float estimate = *SkTCast<float*>(&i); 152 float estimate = *SkTCast<float*>(&i);
132 153
133 // One step of Newton's method to refine. 154 // One step of Newton's method to refine.
134 const float estimate_sq = estimate*estimate; 155 const float estimate_sq = estimate*estimate;
135 estimate *= (1.5f-0.5f*x*estimate_sq); 156 estimate *= (1.5f-0.5f*x*estimate_sq);
136 return estimate; 157 return estimate;
137 #endif 158 #endif
138 } 159 }
139 160
140 #endif 161 #endif
OLDNEW
« no previous file with comments | « gyp/utils.gyp ('k') | src/ports/SkFontHost_FreeType.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698