chromium/third_party/skia/include/core/SkScalar.h

/*
 * Copyright 2006 The Android Open Source Project
 *
 * Use of this source code is governed by a BSD-style license that can be
 * found in the LICENSE file.
 */

#ifndef SkScalar_DEFINED
#define SkScalar_DEFINED

#include "include/private/base/SkAssert.h"
#include "include/private/base/SkFloatingPoint.h"

#include <cmath>

SkScalar;

#define SK_Scalar1
#define SK_ScalarHalf
#define SK_ScalarSqrt2
#define SK_ScalarPI
#define SK_ScalarTanPIOver8
#define SK_ScalarRoot2Over2
#define SK_ScalarMax
#define SK_ScalarMin
#define SK_ScalarInfinity
#define SK_ScalarNegativeInfinity
#define SK_ScalarNaN

#define SkScalarFloorToScalar(x)
#define SkScalarCeilToScalar(x)
#define SkScalarRoundToScalar(x)
#define SkScalarTruncToScalar(x)

#define SkScalarFloorToInt(x)
#define SkScalarCeilToInt(x)
#define SkScalarRoundToInt(x)

#define SkScalarAbs(x)
#define SkScalarCopySign(x, y)
#define SkScalarMod(x, y)
#define SkScalarSqrt(x)
#define SkScalarPow(b, e)

#define SkScalarSin(radians)
#define SkScalarCos(radians)
#define SkScalarTan(radians)
#define SkScalarASin(val)
#define SkScalarACos(val)
#define SkScalarATan2(y, x)
#define SkScalarExp(x)
#define SkScalarLog(x)
#define SkScalarLog2(x)

//////////////////////////////////////////////////////////////////////////////////////////////////

#define SkIntToScalar(x)
#define SkIntToFloat(x)
#define SkScalarTruncToInt(x)

#define SkScalarToFloat(x)
#define SkFloatToScalar(x)
#define SkScalarToDouble(x)
#define SkDoubleToScalar(x)

/** Returns the fractional part of the scalar. */
static inline SkScalar SkScalarFraction(SkScalar x) {}

static inline SkScalar SkScalarSquare(SkScalar x) {}

#define SkScalarInvert(x)
#define SkScalarAve(a, b)
#define SkScalarHalf(a)

#define SkDegreesToRadians(degrees)
#define SkRadiansToDegrees(radians)

static inline bool SkScalarIsInt(SkScalar x) {}

/**
 *  Returns -1 || 0 || 1 depending on the sign of value:
 *  -1 if x < 0
 *   0 if x == 0
 *   1 if x > 0
 */
static inline int SkScalarSignAsInt(SkScalar x) {}

// Scalar result version of above
static inline SkScalar SkScalarSignAsScalar(SkScalar x) {}

#define SK_ScalarNearlyZero

static inline bool SkScalarNearlyZero(SkScalar x,
                                      SkScalar tolerance = SK_ScalarNearlyZero) {}

static inline bool SkScalarNearlyEqual(SkScalar x, SkScalar y,
                                       SkScalar tolerance = SK_ScalarNearlyZero) {}

#define SK_ScalarSinCosNearlyZero

static inline float SkScalarSinSnapToZero(SkScalar radians) {}

static inline float SkScalarCosSnapToZero(SkScalar radians) {}

/** Linearly interpolate between A and B, based on t.
    If t is 0, return A
    If t is 1, return B
    else interpolate.
    t must be [0..SK_Scalar1]
*/
static inline SkScalar SkScalarInterp(SkScalar A, SkScalar B, SkScalar t) {}

/** Interpolate along the function described by (keys[length], values[length])
    for the passed searchKey. SearchKeys outside the range keys[0]-keys[Length]
    clamp to the min or max value. This function assumes the number of pairs
    (length) will be small and a linear search is used.

    Repeated keys are allowed for discontinuous functions (so long as keys is
    monotonically increasing). If key is the value of a repeated scalar in
    keys the first one will be used.
*/
SkScalar SkScalarInterpFunc(SkScalar searchKey, const SkScalar keys[],
                            const SkScalar values[], int length);

/*
 *  Helper to compare an array of scalars.
 */
static inline bool SkScalarsEqual(const SkScalar a[], const SkScalar b[], int n) {}

#endif