1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/src/core/SkFDot6.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,55 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2006 The Android Open Source Project 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 + 1.12 + 1.13 +#ifndef SkFDot6_DEFINED 1.14 +#define SkFDot6_DEFINED 1.15 + 1.16 +#include "SkScalar.h" 1.17 +#include "SkMath.h" 1.18 + 1.19 +typedef int32_t SkFDot6; 1.20 + 1.21 +#define SK_FDot6One (64) 1.22 +#define SK_FDot6Half (32) 1.23 + 1.24 +#ifdef SK_DEBUG 1.25 + inline SkFDot6 SkIntToFDot6(S16CPU x) { 1.26 + SkASSERT(SkToS16(x) == x); 1.27 + return x << 6; 1.28 + } 1.29 +#else 1.30 + #define SkIntToFDot6(x) ((x) << 6) 1.31 +#endif 1.32 + 1.33 +#define SkFDot6Floor(x) ((x) >> 6) 1.34 +#define SkFDot6Ceil(x) (((x) + 63) >> 6) 1.35 +#define SkFDot6Round(x) (((x) + 32) >> 6) 1.36 + 1.37 +#define SkFixedToFDot6(x) ((x) >> 10) 1.38 + 1.39 +inline SkFixed SkFDot6ToFixed(SkFDot6 x) { 1.40 + SkASSERT((x << 10 >> 10) == x); 1.41 + 1.42 + return x << 10; 1.43 +} 1.44 + 1.45 +#define SkScalarToFDot6(x) (SkFDot6)((x) * 64) 1.46 +#define SkFDot6ToScalar(x) ((SkScalar)(x) * 0.015625f) 1.47 + 1.48 +inline SkFixed SkFDot6Div(SkFDot6 a, SkFDot6 b) { 1.49 + SkASSERT(b != 0); 1.50 + 1.51 + if (a == (int16_t)a) { 1.52 + return (a << 16) / b; 1.53 + } else { 1.54 + return SkFixedDiv(a, b); 1.55 + } 1.56 +} 1.57 + 1.58 +#endif