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

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

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

mercurial