gfx/skia/trunk/src/core/SkFDot6.h

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1
michael@0 2 /*
michael@0 3 * Copyright 2006 The Android Open Source Project
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #ifndef SkFDot6_DEFINED
michael@0 11 #define SkFDot6_DEFINED
michael@0 12
michael@0 13 #include "SkScalar.h"
michael@0 14 #include "SkMath.h"
michael@0 15
michael@0 16 typedef int32_t SkFDot6;
michael@0 17
michael@0 18 #define SK_FDot6One (64)
michael@0 19 #define SK_FDot6Half (32)
michael@0 20
michael@0 21 #ifdef SK_DEBUG
michael@0 22 inline SkFDot6 SkIntToFDot6(S16CPU x) {
michael@0 23 SkASSERT(SkToS16(x) == x);
michael@0 24 return x << 6;
michael@0 25 }
michael@0 26 #else
michael@0 27 #define SkIntToFDot6(x) ((x) << 6)
michael@0 28 #endif
michael@0 29
michael@0 30 #define SkFDot6Floor(x) ((x) >> 6)
michael@0 31 #define SkFDot6Ceil(x) (((x) + 63) >> 6)
michael@0 32 #define SkFDot6Round(x) (((x) + 32) >> 6)
michael@0 33
michael@0 34 #define SkFixedToFDot6(x) ((x) >> 10)
michael@0 35
michael@0 36 inline SkFixed SkFDot6ToFixed(SkFDot6 x) {
michael@0 37 SkASSERT((x << 10 >> 10) == x);
michael@0 38
michael@0 39 return x << 10;
michael@0 40 }
michael@0 41
michael@0 42 #define SkScalarToFDot6(x) (SkFDot6)((x) * 64)
michael@0 43 #define SkFDot6ToScalar(x) ((SkScalar)(x) * 0.015625f)
michael@0 44
michael@0 45 inline SkFixed SkFDot6Div(SkFDot6 a, SkFDot6 b) {
michael@0 46 SkASSERT(b != 0);
michael@0 47
michael@0 48 if (a == (int16_t)a) {
michael@0 49 return (a << 16) / b;
michael@0 50 } else {
michael@0 51 return SkFixedDiv(a, b);
michael@0 52 }
michael@0 53 }
michael@0 54
michael@0 55 #endif

mercurial