blob: d3a6fc5f80450fc73cf54189cf92864c1820ab7c [file] [log] [blame]
reed@android.com8a1c16f2008-12-17 15:59:43 +00001/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef SkFloatingPoint_DEFINED
18#define SkFloatingPoint_DEFINED
19
20#include "SkTypes.h"
21
22#ifdef SK_CAN_USE_FLOAT
23
24#include <math.h>
25#include <float.h>
26#include "SkFloatBits.h"
27
28#ifdef SK_BUILD_FOR_WINCE
29 #define sk_float_sqrt(x) (float)::sqrt(x)
30 #define sk_float_sin(x) (float)::sin(x)
31 #define sk_float_cos(x) (float)::cos(x)
32 #define sk_float_tan(x) (float)::tan(x)
33 #define sk_float_acos(x) (float)::acos(x)
34 #define sk_float_asin(x) (float)::asin(x)
35 #define sk_float_atan2(y,x) (float)::atan2(y,x)
36 #define sk_float_abs(x) (float)::fabs(x)
37 #define sk_float_mod(x,y) (float)::fmod(x,y)
38 #define sk_float_exp(x) (float)::exp(x)
39 #define sk_float_log(x) (float)::log(x)
40 #define sk_float_floor(x) (float)::floor(x)
41 #define sk_float_ceil(x) (float)::ceil(x)
42#else
43 #define sk_float_sqrt(x) sqrtf(x)
44 #define sk_float_sin(x) sinf(x)
45 #define sk_float_cos(x) cosf(x)
46 #define sk_float_tan(x) tanf(x)
47 #define sk_float_floor(x) floorf(x)
48 #define sk_float_ceil(x) ceilf(x)
49#ifdef SK_BUILD_FOR_MAC
50 #define sk_float_acos(x) acos(x)
51 #define sk_float_asin(x) asin(x)
52#else
53 #define sk_float_acos(x) acosf(x)
54 #define sk_float_asin(x) asinf(x)
55#endif
56 #define sk_float_atan2(y,x) atan2f(y,x)
57 #define sk_float_abs(x) fabsf(x)
58 #define sk_float_mod(x,y) fmodf(x,y)
59 #define sk_float_exp(x) expf(x)
60 #define sk_float_log(x) logf(x)
61 #define sk_float_isNaN(x) _isnan(x)
62#endif
63
64#ifdef SK_USE_FLOATBITS
65 #define sk_float_floor2int(x) SkFloatToIntFloor(x)
66 #define sk_float_round2int(x) SkFloatToIntRound(x)
67 #define sk_float_ceil2int(x) SkFloatToIntCeil(x)
68#else
69 #define sk_float_floor2int(x) (int)sk_float_floor(x)
70 #define sk_float_round2int(x) (int)sk_float_floor((x) + 0.5f)
71 #define sk_float_ceil2int(x) (int)sk_float_ceil(x)
72#endif
73
74#endif
75#endif