00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef SkFloatingPoint_DEFINED
00018 #define SkFloatingPoint_DEFINED
00019
00020 #include "SkTypes.h"
00021
00022 #ifdef SK_CAN_USE_FLOAT
00023
00024 #include <math.h>
00025 #include <float.h>
00026 #include "SkFloatBits.h"
00027
00028
00029 static inline float sk_float_pow(float base, float exp) {
00030 return static_cast<float>(pow(static_cast<double>(base),
00031 static_cast<double>(exp)));
00032 }
00033
00034 #ifdef SK_BUILD_FOR_WINCE
00035 #define sk_float_sqrt(x) (float)::sqrt(x)
00036 #define sk_float_sin(x) (float)::sin(x)
00037 #define sk_float_cos(x) (float)::cos(x)
00038 #define sk_float_tan(x) (float)::tan(x)
00039 #define sk_float_acos(x) (float)::acos(x)
00040 #define sk_float_asin(x) (float)::asin(x)
00041 #define sk_float_atan2(y,x) (float)::atan2(y,x)
00042 #define sk_float_abs(x) (float)::fabs(x)
00043 #define sk_float_mod(x,y) (float)::fmod(x,y)
00044 #define sk_float_exp(x) (float)::exp(x)
00045 #define sk_float_log(x) (float)::log(x)
00046 #define sk_float_floor(x) (float)::floor(x)
00047 #define sk_float_ceil(x) (float)::ceil(x)
00048 #else
00049 #define sk_float_sqrt(x) sqrtf(x)
00050 #define sk_float_sin(x) sinf(x)
00051 #define sk_float_cos(x) cosf(x)
00052 #define sk_float_tan(x) tanf(x)
00053 #define sk_float_floor(x) floorf(x)
00054 #define sk_float_ceil(x) ceilf(x)
00055 #ifdef SK_BUILD_FOR_MAC
00056 #define sk_float_acos(x) static_cast<float>(acos(x))
00057 #define sk_float_asin(x) static_cast<float>(asin(x))
00058 #else
00059 #define sk_float_acos(x) acosf(x)
00060 #define sk_float_asin(x) asinf(x)
00061 #endif
00062 #define sk_float_atan2(y,x) atan2f(y,x)
00063 #define sk_float_abs(x) fabsf(x)
00064 #define sk_float_mod(x,y) fmodf(x,y)
00065 #define sk_float_exp(x) expf(x)
00066 #define sk_float_log(x) logf(x)
00067 #define sk_float_isNaN(x) _isnan(x)
00068 #endif
00069
00070 #ifdef SK_USE_FLOATBITS
00071 #define sk_float_floor2int(x) SkFloatToIntFloor(x)
00072 #define sk_float_round2int(x) SkFloatToIntRound(x)
00073 #define sk_float_ceil2int(x) SkFloatToIntCeil(x)
00074 #else
00075 #define sk_float_floor2int(x) (int)sk_float_floor(x)
00076 #define sk_float_round2int(x) (int)sk_float_floor((x) + 0.5f)
00077 #define sk_float_ceil2int(x) (int)sk_float_ceil(x)
00078 #endif
00079
00080 #endif
00081 #endif