remove SkScalarCompare type and header

BUG=
R=fmalita@chromium.org

Review URL: https://codereview.chromium.org/113193004

git-svn-id: http://skia.googlecode.com/svn/trunk@12681 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gyp/core.gypi b/gyp/core.gypi
index 11da868..086ea84 100644
--- a/gyp/core.gypi
+++ b/gyp/core.gypi
@@ -279,7 +279,6 @@
         '<(skia_include_path)/core/SkRegion.h',
         '<(skia_include_path)/core/SkRRect.h',
         '<(skia_include_path)/core/SkScalar.h',
-        '<(skia_include_path)/core/SkScalarCompare.h',
         '<(skia_include_path)/core/SkShader.h',
         '<(skia_include_path)/core/SkStream.h',
         '<(skia_include_path)/core/SkString.h',
diff --git a/gyp/public_headers.gypi b/gyp/public_headers.gypi
index 45114e8..b8c5016 100644
--- a/gyp/public_headers.gypi
+++ b/gyp/public_headers.gypi
@@ -218,7 +218,6 @@
       'core/SkStrokeRec.h',
       'core/SkImageDecoder.h',
       'core/SkTime.h',
-      'core/SkScalarCompare.h',
       'core/SkPathMeasure.h',
       'core/SkMaskFilter.h',
       'core/SkBounder.h',
diff --git a/include/core/SkCanvas.h b/include/core/SkCanvas.h
index 6c41680..5a5cc65 100644
--- a/include/core/SkCanvas.h
+++ b/include/core/SkCanvas.h
@@ -18,7 +18,6 @@
 #include "SkRefCnt.h"
 #include "SkPath.h"
 #include "SkRegion.h"
-#include "SkScalarCompare.h"
 #include "SkXfermode.h"
 
 class SkBounder;
@@ -455,14 +454,13 @@
                      not intersect the current clip)
     */
     bool quickRejectY(SkScalar top, SkScalar bottom) const {
-        SkASSERT(SkScalarToCompareType(top) <= SkScalarToCompareType(bottom));
-        const SkRectCompareType& clipR = this->getLocalClipBoundsCompareType();
+        SkASSERT(top <= bottom);
+        const SkRect& clipR = this->getLocalClipBounds();
         // In the case where the clip is empty and we are provided with a
         // negative top and positive bottom parameter then this test will return
         // false even though it will be clipped. We have chosen to exclude that
         // check as it is rare and would result double the comparisons.
-        return SkScalarToCompareType(top) >= clipR.fBottom
-            || SkScalarToCompareType(bottom) <= clipR.fTop;
+        return top >= clipR.fBottom || bottom <= clipR.fTop;
     }
 
     /** Return the bounds of the current clip (in local coordinates) in the
@@ -1100,20 +1098,20 @@
     /*  These maintain a cache of the clip bounds in local coordinates,
         (converted to 2s-compliment if floats are slow).
      */
-    mutable SkRectCompareType fLocalBoundsCompareType;
-    mutable bool              fLocalBoundsCompareTypeDirty;
+    mutable SkRect fCachedLocalClipBounds;
+    mutable bool   fCachedLocalClipBoundsDirty;
     bool fAllowSoftClip;
     bool fAllowSimplifyClip;
 
-    const SkRectCompareType& getLocalClipBoundsCompareType() const {
-        if (fLocalBoundsCompareTypeDirty) {
-            this->computeLocalClipBoundsCompareType();
-            fLocalBoundsCompareTypeDirty = false;
+    const SkRect& getLocalClipBounds() const {
+        if (fCachedLocalClipBoundsDirty) {
+            if (!this->getClipBounds(&fCachedLocalClipBounds)) {
+                fCachedLocalClipBounds.setEmpty();
+            }
+            fCachedLocalClipBoundsDirty = false;
         }
-        return fLocalBoundsCompareType;
+        return fCachedLocalClipBounds;
     }
-    void computeLocalClipBoundsCompareType() const;
-
 
     class AutoValidateClip : ::SkNoncopyable {
     public:
diff --git a/include/core/SkScalarCompare.h b/include/core/SkScalarCompare.h
deleted file mode 100644
index 5361294..0000000
--- a/include/core/SkScalarCompare.h
+++ /dev/null
@@ -1,38 +0,0 @@
-
-/*
- * 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 SkScalarCompare_DEFINED
-#define SkScalarCompare_DEFINED
-
-#include "SkFloatBits.h"
-#include "SkRect.h"
-
-/** Skia can spend a lot of time just comparing scalars (e.g. quickReject).
-    When scalar==fixed, this is very fast, and when scalar==hardware-float, this
-    is also reasonable, but if scalar==software-float, then each compare can be
-    a function call and take real time. To account for that, we have the flag
-    SK_SCALAR_SLOW_COMPARES.
-
-    If this is defined, we have a special trick where we quickly convert floats
-    to a 2's compliment form, and then treat them as signed 32bit integers. In
-    this form we lose a few subtlties (e.g. NaNs always comparing false) but
-    we gain the speed of integer compares.
- */
-
-#ifdef SK_SCALAR_SLOW_COMPARES
-    typedef int32_t SkScalarCompareType;
-    typedef SkIRect SkRectCompareType;
-    #define SkScalarToCompareType(x)    SkScalarAs2sCompliment(x)
-#else
-    typedef SkScalar SkScalarCompareType;
-    typedef SkRect SkRectCompareType;
-    #define SkScalarToCompareType(x)    (x)
-#endif
-
-#endif
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index 47d3cca..feeba75 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -19,7 +19,6 @@
 #include "SkPicture.h"
 #include "SkRasterClip.h"
 #include "SkRRect.h"
-#include "SkScalarCompare.h"
 #include "SkSurface_Base.h"
 #include "SkTemplates.h"
 #include "SkTextFormatParams.h"
@@ -485,8 +484,8 @@
 
 SkBaseDevice* SkCanvas::init(SkBaseDevice* device) {
     fBounder = NULL;
-    fLocalBoundsCompareType.setEmpty();
-    fLocalBoundsCompareTypeDirty = true;
+    fCachedLocalClipBounds.setEmpty();
+    fCachedLocalClipBoundsDirty = true;
     fAllowSoftClip = true;
     fAllowSimplifyClip = false;
     fDeviceCMDirty = false;
@@ -897,7 +896,7 @@
     SkASSERT(fMCStack.count() != 0);
 
     fDeviceCMDirty = true;
-    fLocalBoundsCompareTypeDirty = true;
+    fCachedLocalClipBoundsDirty = true;
 
     if (SkCanvas::kClip_SaveFlag & fMCRec->fFlags) {
         fClipStack.restore();
@@ -1056,37 +1055,37 @@
 
 bool SkCanvas::translate(SkScalar dx, SkScalar dy) {
     fDeviceCMDirty = true;
-    fLocalBoundsCompareTypeDirty = true;
+    fCachedLocalClipBoundsDirty = true;
     return fMCRec->fMatrix->preTranslate(dx, dy);
 }
 
 bool SkCanvas::scale(SkScalar sx, SkScalar sy) {
     fDeviceCMDirty = true;
-    fLocalBoundsCompareTypeDirty = true;
+    fCachedLocalClipBoundsDirty = true;
     return fMCRec->fMatrix->preScale(sx, sy);
 }
 
 bool SkCanvas::rotate(SkScalar degrees) {
     fDeviceCMDirty = true;
-    fLocalBoundsCompareTypeDirty = true;
+    fCachedLocalClipBoundsDirty = true;
     return fMCRec->fMatrix->preRotate(degrees);
 }
 
 bool SkCanvas::skew(SkScalar sx, SkScalar sy) {
     fDeviceCMDirty = true;
-    fLocalBoundsCompareTypeDirty = true;
+    fCachedLocalClipBoundsDirty = true;
     return fMCRec->fMatrix->preSkew(sx, sy);
 }
 
 bool SkCanvas::concat(const SkMatrix& matrix) {
     fDeviceCMDirty = true;
-    fLocalBoundsCompareTypeDirty = true;
+    fCachedLocalClipBoundsDirty = true;
     return fMCRec->fMatrix->preConcat(matrix);
 }
 
 void SkCanvas::setMatrix(const SkMatrix& matrix) {
     fDeviceCMDirty = true;
-    fLocalBoundsCompareTypeDirty = true;
+    fCachedLocalClipBoundsDirty = true;
     *fMCRec->fMatrix = matrix;
 }
 
@@ -1110,7 +1109,7 @@
 
         if (this->quickReject(rect)) {
             fDeviceCMDirty = true;
-            fLocalBoundsCompareTypeDirty = true;
+            fCachedLocalClipBoundsDirty = true;
 
             fClipStack.clipEmpty();
             return fMCRec->fRasterClip->setEmpty();
@@ -1121,7 +1120,7 @@
     AutoValidateClip avc(this);
 
     fDeviceCMDirty = true;
-    fLocalBoundsCompareTypeDirty = true;
+    fCachedLocalClipBoundsDirty = true;
     doAA &= fAllowSoftClip;
 
     if (fMCRec->fMatrix->rectStaysRect()) {
@@ -1206,7 +1205,7 @@
 
         if (this->quickReject(path.getBounds())) {
             fDeviceCMDirty = true;
-            fLocalBoundsCompareTypeDirty = true;
+            fCachedLocalClipBoundsDirty = true;
 
             fClipStack.clipEmpty();
             return fMCRec->fRasterClip->setEmpty();
@@ -1217,7 +1216,7 @@
     AutoValidateClip avc(this);
 
     fDeviceCMDirty = true;
-    fLocalBoundsCompareTypeDirty = true;
+    fCachedLocalClipBoundsDirty = true;
     doAA &= fAllowSoftClip;
 
     SkPath devPath;
@@ -1350,7 +1349,7 @@
     AutoValidateClip avc(this);
 
     fDeviceCMDirty = true;
-    fLocalBoundsCompareTypeDirty = true;
+    fCachedLocalClipBoundsDirty = true;
 
     // todo: signal fClipStack that we have a region, and therefore (I guess)
     // we have to ignore it, and use the region directly?
@@ -1423,19 +1422,6 @@
 
 ///////////////////////////////////////////////////////////////////////////////
 
-void SkCanvas::computeLocalClipBoundsCompareType() const {
-    SkRect r;
-
-    if (!this->getClipBounds(&r)) {
-        fLocalBoundsCompareType.setEmpty();
-    } else {
-        fLocalBoundsCompareType.set(SkScalarToCompareType(r.fLeft),
-                                    SkScalarToCompareType(r.fTop),
-                                    SkScalarToCompareType(r.fRight),
-                                    SkScalarToCompareType(r.fBottom));
-    }
-}
-
 bool SkCanvas::quickReject(const SkRect& rect) const {
 
     if (!rect.isFinite())
@@ -1452,17 +1438,14 @@
         dst.roundOut(&idst);
         return !SkIRect::Intersects(idst, fMCRec->fRasterClip->getBounds());
     } else {
-        const SkRectCompareType& clipR = this->getLocalClipBoundsCompareType();
+        const SkRect& clipR = this->getLocalClipBounds();
 
         // for speed, do the most likely reject compares first
-        SkScalarCompareType userT = SkScalarToCompareType(rect.fTop);
-        SkScalarCompareType userB = SkScalarToCompareType(rect.fBottom);
-        if (userT >= clipR.fBottom || userB <= clipR.fTop) {
+        // TODO: should we use | instead, or compare all 4 at once?
+        if (rect.fTop >= clipR.fBottom || rect.fBottom <= clipR.fTop) {
             return true;
         }
-        SkScalarCompareType userL = SkScalarToCompareType(rect.fLeft);
-        SkScalarCompareType userR = SkScalarToCompareType(rect.fRight);
-        if (userL >= clipR.fRight || userR <= clipR.fLeft) {
+        if (rect.fLeft >= clipR.fRight || rect.fRight <= clipR.fLeft) {
             return true;
         }
         return false;
diff --git a/src/core/SkMatrix.cpp b/src/core/SkMatrix.cpp
index 474f272..d9c2677 100644
--- a/src/core/SkMatrix.cpp
+++ b/src/core/SkMatrix.cpp
@@ -9,7 +9,6 @@
 #include "Sk64.h"
 #include "SkFloatBits.h"
 #include "SkOnce.h"
-#include "SkScalarCompare.h"
 #include "SkString.h"
 
 #ifdef SK_SCALAR_IS_FLOAT
@@ -251,7 +250,7 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 void SkMatrix::setTranslate(SkScalar dx, SkScalar dy) {
-    if (SkScalarToCompareType(dx) || SkScalarToCompareType(dy)) {
+    if (dx || dy) {
         fMat[kMTransX] = dx;
         fMat[kMTransY] = dy;
 
@@ -273,7 +272,7 @@
         return this->preConcat(m);
     }
 
-    if (SkScalarToCompareType(dx) || SkScalarToCompareType(dy)) {
+    if (dx || dy) {
         fMat[kMTransX] += SkScalarMul(fMat[kMScaleX], dx) +
                           SkScalarMul(fMat[kMSkewX], dy);
         fMat[kMTransY] += SkScalarMul(fMat[kMSkewY], dx) +
@@ -291,7 +290,7 @@
         return this->postConcat(m);
     }
 
-    if (SkScalarToCompareType(dx) || SkScalarToCompareType(dy)) {
+    if (dx || dy) {
         fMat[kMTransX] += dx;
         fMat[kMTransY] += dy;
         this->setTypeMask(kUnknown_Mask | kOnlyPerspectiveValid_Mask);