Home | History | Annotate | Download | only in core
      1 
      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  */
      8 
      9 
     10 #ifndef SkScalarCompare_DEFINED
     11 #define SkScalarCompare_DEFINED
     12 
     13 #include "SkFloatBits.h"
     14 #include "SkRect.h"
     15 
     16 /** Skia can spend a lot of time just comparing scalars (e.g. quickReject).
     17     When scalar==fixed, this is very fast, and when scalar==hardware-float, this
     18     is also reasonable, but if scalar==software-float, then each compare can be
     19     a function call and take real time. To account for that, we have the flag
     20     SK_SCALAR_SLOW_COMPARES.
     21 
     22     If this is defined, we have a special trick where we quickly convert floats
     23     to a 2's compliment form, and then treat them as signed 32bit integers. In
     24     this form we lose a few subtlties (e.g. NaNs always comparing false) but
     25     we gain the speed of integer compares.
     26  */
     27 
     28 #ifdef SK_SCALAR_SLOW_COMPARES
     29     typedef int32_t SkScalarCompareType;
     30     typedef SkIRect SkRectCompareType;
     31     #define SkScalarToCompareType(x)    SkScalarAs2sCompliment(x)
     32 #else
     33     typedef SkScalar SkScalarCompareType;
     34     typedef SkRect SkRectCompareType;
     35     #define SkScalarToCompareType(x)    (x)
     36 #endif
     37 
     38 #endif
     39 
     40