00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef SkFDot6_DEFINED
00018 #define SkFDot6_DEFINED
00019
00020 #include "SkMath.h"
00021
00022 typedef int32_t SkFDot6;
00023
00024 #define SK_FDot61 (64)
00025 #define SK_FDot6Half (32)
00026
00027 #ifdef SK_DEBUG
00028 inline SkFDot6 SkIntToFDot6(S16CPU x)
00029 {
00030 SkASSERT(SkToS16(x) == x);
00031 return x << 6;
00032 }
00033 #else
00034 #define SkIntToFDot6(x) ((x) << 6)
00035 #endif
00036
00037 #define SkFDot6Floor(x) ((x) >> 6)
00038 #define SkFDot6Ceil(x) (((x) + 63) >> 6)
00039 #define SkFDot6Round(x) (((x) + 32) >> 6)
00040
00041 #define SkFixedToFDot6(x) ((x) >> 10)
00042
00043 inline SkFixed SkFDot6ToFixed(SkFDot6 x)
00044 {
00045 SkASSERT((x << 10 >> 10) == x);
00046
00047 return x << 10;
00048 }
00049
00050 #ifdef SK_SCALAR_IS_FLOAT
00051 #define SkScalarToFDot6(x) (SkFDot6)((x) * 64)
00052 #else
00053 #define SkScalarToFDot6(x) ((x) >> 10)
00054 #endif
00055
00056 inline SkFixed SkFDot6Div(SkFDot6 a, SkFDot6 b)
00057 {
00058 SkASSERT(b != 0);
00059
00060 if (a == (int16_t)a)
00061 return (a << 16) / b;
00062 else
00063 return SkFixedDiv(a, b);
00064 }
00065
00066 #endif
00067