Home | History | Annotate | Download | only in core
      1 /*
      2  * Copyright (C) 2006 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef SkScalarCompare_DEFINED
     18 #define SkScalarCompare_DEFINED
     19 
     20 #include "SkFloatBits.h"
     21 #include "SkRect.h"
     22 
     23 /** Skia can spend a lot of time just comparing scalars (e.g. quickReject).
     24     When scalar==fixed, this is very fast, and when scalar==hardware-float, this
     25     is also reasonable, but if scalar==software-float, then each compare can be
     26     a function call and take real time. To account for that, we have the flag
     27     SK_SCALAR_SLOW_COMPARES.
     28 
     29     If this is defined, we have a special trick where we quickly convert floats
     30     to a 2's compliment form, and then treat them as signed 32bit integers. In
     31     this form we lose a few subtlties (e.g. NaNs always comparing false) but
     32     we gain the speed of integer compares.
     33  */
     34 
     35 #ifdef SK_SCALAR_SLOW_COMPARES
     36     typedef int32_t SkScalarCompareType;
     37     typedef SkIRect SkRectCompareType;
     38     #define SkScalarToCompareType(x)    SkScalarAs2sCompliment(x)
     39 #else
     40     typedef SkScalar SkScalarCompareType;
     41     typedef SkRect SkRectCompareType;
     42     #define SkScalarToCompareType(x)    (x)
     43 #endif
     44 
     45 #endif
     46 
     47