remove remaining references to Sk64 (obsolete)
authorreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 13 Jan 2014 14:53:55 +0000 (14:53 +0000)
committerreed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Mon, 13 Jan 2014 14:53:55 +0000 (14:53 +0000)
BUG=

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

git-svn-id: http://skia.googlecode.com/svn/trunk@13042 2bbb7eff-a529-9590-31e7-b0007b416f81

24 files changed:
gyp/core.gypi
gyp/tests.gyp
include/core/SkPixelRef.h
samplecode/SampleDegenerateTwoPtRadials.cpp
samplecode/SampleEmboss.cpp
samplecode/SampleHairline.cpp
samplecode/SampleLines.cpp
samplecode/SamplePdfFileViewer.cpp
samplecode/SamplePictFile.cpp
samplecode/SamplePicture.cpp
samplecode/SamplePoints.cpp
samplecode/SampleText.cpp
samplecode/SampleXfermodesBlur.cpp
src/animator/SkTime.cpp
src/core/Sk64.cpp [deleted file]
src/core/Sk64.h [deleted file]
src/core/SkFloat.cpp
src/core/SkGeometry.cpp
src/core/SkGraphics.cpp
src/core/SkMask.cpp
src/core/SkMath.cpp
src/core/SkMatrix.cpp
src/utils/SkCullPoints.cpp
tests/Sk64Test.cpp [deleted file]

index aa5292c..56ea42a 100644 (file)
@@ -7,8 +7,6 @@
 #
 {
     'sources': [
-        '<(skia_src_path)/core/Sk64.cpp',
-        '<(skia_src_path)/core/Sk64.h',
         '<(skia_src_path)/core/ARGB32_Clamp_Bilinear_BitmapShader.h',
         '<(skia_src_path)/core/SkAAClip.cpp',
         '<(skia_src_path)/core/SkAnnotation.cpp',
index ec8ae43..bbd605e 100644 (file)
         '../tests/SerializationTest.cpp',
         '../tests/ShaderImageFilterTest.cpp',
         '../tests/ShaderOpacityTest.cpp',
-        '../tests/Sk64Test.cpp',
         '../tests/skia_test.cpp',
         '../tests/SortTest.cpp',
         '../tests/SrcOverTest.cpp',
index e0bf886..fc0feb0 100644 (file)
@@ -17,7 +17,7 @@
 #include "SkImageInfo.h"
 #include "SkTDArray.h"
 
-//#define SK_SUPPORT_LEGACY_ONLOCKPIXELS
+//#define xed
 
 #ifdef SK_DEBUG
     /**
index 92e49a7..4665425 100644 (file)
@@ -1,14 +1,13 @@
-
 /*
  * Copyright 2011 Google Inc.
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+
 #include "SampleCode.h"
 #include "SkView.h"
 #include "SkCanvas.h"
-#include "Sk64.h"
 #include "SkGradientShader.h"
 #include "SkString.h"
 
index b9bb691..dacd4bf 100644 (file)
@@ -1,15 +1,14 @@
-
 /*
  * Copyright 2011 Google Inc.
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+
 #include "SampleCode.h"
 #include "SkBlurMask.h"
 #include "SkView.h"
 #include "SkCanvas.h"
-#include "Sk64.h"
 #include "SkColorShader.h"
 #include "SkEmbossMaskFilter.h"
 #include "SkGradientShader.h"
index bb43d84..5da2639 100644 (file)
@@ -1,14 +1,13 @@
-
 /*
  * Copyright 2011 Google Inc.
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+
 #include "SampleCode.h"
 #include "SkView.h"
 #include "SkCanvas.h"
-#include "Sk64.h"
 #include "SkCornerPathEffect.h"
 #include "SkGradientShader.h"
 #include "SkGraphics.h"
index d8304d1..c6f7ad9 100644 (file)
@@ -1,14 +1,13 @@
-
 /*
  * Copyright 2011 Google Inc.
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+
 #include "SampleCode.h"
 #include "SkView.h"
 #include "SkCanvas.h"
-#include "Sk64.h"
 #include "SkCornerPathEffect.h"
 #include "SkGradientShader.h"
 #include "SkGraphics.h"
index 55c7002..6faea55 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright 2013 Google Inc.
  *
@@ -12,7 +11,6 @@
 #include "SkDumpCanvas.h"
 #include "SkView.h"
 #include "SkCanvas.h"
-#include "Sk64.h"
 #include "SkGradientShader.h"
 #include "SkGraphics.h"
 #include "SkImageDecoder.h"
index 161db7f..c6518d9 100644 (file)
@@ -1,15 +1,14 @@
-
 /*
  * Copyright 2011 Google Inc.
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+
 #include "SampleCode.h"
 #include "SkDumpCanvas.h"
 #include "SkView.h"
 #include "SkCanvas.h"
-#include "Sk64.h"
 #include "SkGradientShader.h"
 #include "SkGraphics.h"
 #include "SkImageDecoder.h"
index 767fd61..b76f36f 100644 (file)
@@ -1,17 +1,16 @@
-
 /*
  * Copyright 2011 Google Inc.
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+
 #include "SampleCode.h"
 #include "SkData.h"
 #include "SkDecodingImageGenerator.h"
 #include "SkDumpCanvas.h"
 #include "SkView.h"
 #include "SkCanvas.h"
-#include "Sk64.h"
 #include "SkGradientShader.h"
 #include "SkGraphics.h"
 #include "SkImageDecoder.h"
index ac2f625..6fb43af 100644 (file)
@@ -1,14 +1,13 @@
-
 /*
  * Copyright 2011 Google Inc.
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+
 #include "SampleCode.h"
 #include "SkView.h"
 #include "SkCanvas.h"
-#include "Sk64.h"
 #include "SkGradientShader.h"
 #include "SkGraphics.h"
 #include "SkImageDecoder.h"
index c881961..9aefd2c 100644 (file)
@@ -1,14 +1,13 @@
-
 /*
  * Copyright 2011 Google Inc.
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+
 #include "SampleCode.h"
 #include "SkView.h"
 #include "SkCanvas.h"
-#include "Sk64.h"
 #include "SkFlattenableBuffers.h"
 #include "SkGradientShader.h"
 #include "SkGraphics.h"
index a73d9f2..3b8b592 100644 (file)
@@ -1,15 +1,14 @@
-
 /*
  * Copyright 2011 Google Inc.
  *
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+
 #include "SampleCode.h"
 #include "SkView.h"
 #include "SkBlurMask.h"
 #include "SkCanvas.h"
-#include "Sk64.h"
 #include "SkCornerPathEffect.h"
 #include "SkGradientShader.h"
 #include "SkGraphics.h"
index ffd6f38..a4e035b 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright 2006 The Android Open Source Project
  *
@@ -6,7 +5,6 @@
  * found in the LICENSE file.
  */
 
-
 #include "SkTime.h"
 
 #ifdef SK_BUILD_FOR_WIN
 SkMSec gForceTickCount = (SkMSec) -1;
 #endif
 
-void SkTime::GetDateTime(DateTime* t)
-{
-    if (t)
-    {
+void SkTime::GetDateTime(DateTime* t) {
+    if (t) {
         SYSTEMTIME  syst;
 
         ::GetLocalTime(&syst);
@@ -32,11 +28,11 @@ void SkTime::GetDateTime(DateTime* t)
     }
 }
 
-SkMSec SkTime::GetMSecs()
-{
+SkMSec SkTime::GetMSecs() {
 #ifdef SK_DEBUG
-    if (gForceTickCount != (SkMSec) -1)
+    if (gForceTickCount != (SkMSec) -1) {
         return gForceTickCount;
+    }
 #endif
     return ::GetTickCount();
 }
@@ -45,10 +41,8 @@ SkMSec SkTime::GetMSecs()
 
 #include <time.h>
 
-void SkTime::GetDateTime(DateTime* t)
-{
-    if (t)
-    {
+void SkTime::GetDateTime(DateTime* t) {
+    if (t) {
         tm      syst;
         time_t  tm;
 
@@ -64,17 +58,13 @@ void SkTime::GetDateTime(DateTime* t)
     }
 }
 
-#include "Sk64.h"
-
-SkMSec SkTime::GetMSecs()
-{
+SkMSec SkTime::GetMSecs() {
     UnsignedWide    wide;
-    Sk64            s;
-
     ::Microseconds(&wide);
-    s.set(wide.hi, wide.lo);
-    s.div(1000, Sk64::kRound_DivOption);
-    return s.get32();
+
+    int64_t s = ((int64_t)wide.hi << 32) | wide.lo;
+    s = (s + 500) / 1000;   // rounded divide
+    return (SkMSec)s;
 }
 
 #endif
diff --git a/src/core/Sk64.cpp b/src/core/Sk64.cpp
deleted file mode 100644 (file)
index 552d456..0000000
+++ /dev/null
@@ -1,286 +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.
- */
-
-#include "Sk64.h"
-#include "SkMathPriv.h"
-
-#define shift_left(hi, lo)          \
-    hi = (hi << 1) | (lo >> 31);    \
-    lo <<= 1
-
-#define shift_left_bits(hi, lo, bits)           \
-    SkASSERT((unsigned)(bits) < 31);                \
-    hi = (hi << (bits)) | (lo >> (32 - (bits)));    \
-    lo <<= (bits)
-
-//////////////////////////////////////////////////////////////////////
-
-int Sk64::getClzAbs() const
-{
-    int32_t     hi = fHi;
-    uint32_t    lo = fLo;
-
-    // get abs
-    if (hi < 0)
-    {
-        hi = -hi - Sk32ToBool(lo);
-        lo = 0 - lo;
-    }
-    return hi ? SkCLZ(hi) : SkCLZ(lo) + 32;
-}
-
-void Sk64::shiftLeft(unsigned bits)
-{
-    SkASSERT(bits <= 63);
-    if (bits == 0)
-        return;
-
-    if (bits >= 32)
-    {
-        fHi = fLo << (bits - 32);
-        fLo = 0;
-    }
-    else
-    {
-        fHi = (fHi << bits) | (fLo >> (32 - bits));
-        fLo <<= bits;
-    }
-}
-
-int32_t Sk64::getShiftRight(unsigned bits) const
-{
-    SkASSERT(bits <= 63);
-
-    if (bits == 0)
-        return fLo;
-
-    if (bits >= 32)
-        return fHi >> (bits - 32);
-    else
-    {
-#ifdef SK_DEBUG
-        int32_t tmp = fHi >> bits;
-        SkASSERT(tmp == 0 || tmp == -1);
-#endif
-        return (fHi << (32 - bits)) | (fLo >> bits);
-    }
-}
-
-void Sk64::shiftRight(unsigned bits)
-{
-    SkASSERT(bits <= 63);
-    if (bits == 0)
-        return;
-
-    if (bits >= 32)
-    {
-        fLo = fHi >> (bits - 32);
-        fHi >>= 31;
-    }
-    else
-    {
-        fLo = (fHi << (32 - bits)) | (fLo >> bits);
-        fHi >>= bits;
-    }
-}
-
-void Sk64::roundRight(unsigned bits)
-{
-    SkASSERT(bits <= 63);
-    if (bits)
-    {
-        Sk64 one;
-        one.set(1);
-        one.shiftLeft(bits - 1);
-        this->add(one);
-        this->shiftRight(bits);
-    }
-}
-
-int Sk64::shiftToMake32() const
-{
-    int32_t     hi = fHi;
-    uint32_t    lo = fLo;
-
-    if (hi < 0) // make it positive
-    {
-        hi = -hi - Sk32ToBool(lo);
-        lo = 0 - lo;
-    }
-
-    if (hi == 0)
-        return lo >> 31;
-    else
-        return 33 - SkCLZ(hi);
-}
-
-void Sk64::negate()
-{
-    fHi = -fHi - Sk32ToBool(fLo);
-    fLo = 0 - fLo;
-}
-
-void Sk64::abs()
-{
-    if (fHi < 0)
-    {
-        fHi = -fHi - Sk32ToBool(fLo);
-        fLo = 0 - fLo;
-    }
-}
-
-#if 0
-SkBool Sk64::isFixed() const
-{
-    Sk64 tmp = *this;
-    tmp.roundRight(16);
-    return tmp.is32();
-}
-#endif
-
-void Sk64::sub(const Sk64& a)
-{
-    fHi = fHi - a.fHi - (fLo < a.fLo);
-    fLo = fLo - a.fLo;
-}
-
-void Sk64::rsub(const Sk64& a)
-{
-    fHi = a.fHi - fHi - (a.fLo < fLo);
-    fLo = a.fLo - fLo;
-}
-
-void Sk64::setMul(int32_t a, int32_t b)
-{
-    int sa = a >> 31;
-    int sb = b >> 31;
-    // now make them positive
-    a = (a ^ sa) - sa;
-    b = (b ^ sb) - sb;
-
-    uint32_t    ah = a >> 16;
-    uint32_t    al = a & 0xFFFF;
-    uint32_t bh = b >> 16;
-    uint32_t bl = b & 0xFFFF;
-
-    uint32_t A = ah * bh;
-    uint32_t B = ah * bl + al * bh;
-    uint32_t C = al * bl;
-
-    /*  [  A  ]
-           [  B  ]
-              [  C  ]
-    */
-    fLo = C + (B << 16);
-    fHi = A + (B >>16) + (fLo < C);
-
-    if (sa != sb)
-        this->negate();
-}
-
-void Sk64::div(int32_t denom, DivOptions option)
-{
-    SkASSERT(denom);
-
-    int32_t     hi = fHi;
-    uint32_t    lo = fLo;
-    int         sign = denom ^ hi;
-
-    denom = SkAbs32(denom);
-    if (hi < 0)
-    {
-        hi = -hi - Sk32ToBool(lo);
-        lo = 0 - lo;
-    }
-
-    if (option == kRound_DivOption) // add denom/2
-    {
-        uint32_t newLo = lo + (denom >> 1);
-        hi += (newLo < lo);
-        lo = newLo;
-    }
-
-    if (hi == 0)    // fast-case
-    {
-        if (lo < (uint32_t)denom)
-            this->set(0, 0);
-        else
-        {
-            this->set(0, lo / denom);
-            if (sign < 0)
-                this->negate();
-        }
-        return;
-    }
-
-    int bits;
-
-    {
-        int dbits = SkCLZ(denom);
-        int nbits = SkCLZ(hi);
-
-        bits = 32 + dbits - nbits;
-        SkASSERT(bits <= 63);
-        if (bits <= 0)
-        {
-            this->set(0, 0);
-            return;
-        }
-        denom <<= (dbits - 1);
-        shift_left_bits(hi, lo, nbits - 1);
-    }
-
-    int32_t     rhi = 0;
-    uint32_t    rlo = 0;
-
-    do {
-        shift_left(rhi, rlo);
-        if ((uint32_t)denom <= (uint32_t)hi)
-        {
-            hi -= denom;
-            rlo |= 1;
-        }
-        shift_left(hi, lo);
-    } while (--bits >= 0);
-    SkASSERT(rhi >= 0);
-
-    fHi = rhi;
-    fLo = rlo;
-    if (sign < 0)
-        this->negate();
-}
-
-#define shift_left_2(a, b, c)   \
-    a = (a << 2) | (b >> 30);   \
-    b = (b << 2) | (c >> 30);   \
-    c <<= 2
-
-int32_t Sk64::getSqrt() const
-{
-    SkASSERT(!this->isNeg());
-
-    uint32_t    hi = fHi;
-    uint32_t lo = fLo;
-    uint32_t    sqr = 0;
-    uint32_t root = 0;
-    int count = 31;
-
-    do {
-        root <<= 1;
-        shift_left_2(sqr, hi, lo);
-
-        uint32_t testDiv = (root << 1) + 1;
-        if (sqr >= testDiv)
-        {
-            sqr -= testDiv;
-            root++;
-        }
-    } while (--count >= 0);
-    SkASSERT((int32_t)root >= 0);
-
-    return root;
-}
diff --git a/src/core/Sk64.h b/src/core/Sk64.h
deleted file mode 100644 (file)
index c12a97c..0000000
+++ /dev/null
@@ -1,187 +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 Sk64_DEFINED
-#define Sk64_DEFINED
-
-#include "SkTypes.h"
-
-/** \class Sk64
-
-    Sk64 is a 64-bit math package that does not require long long support from the compiler.
-*/
-struct SK_API Sk64 {
-private:
-    int32_t  fHi;   //!< the high 32 bits of the number (including sign)
-    uint32_t fLo;   //!< the low 32 bits of the number
-
-public:
-    int32_t hi() const { return fHi; }
-    uint32_t lo() const { return fLo; }
-
-    int64_t as64() const { return ((int64_t)fHi << 32) | fLo; }
-    int64_t getLongLong() const { return this->as64(); }
-
-    void set64(int64_t value) {
-        fHi = (int32_t)(value >> 32);
-        fLo = (uint32_t)value;
-    }
-
-    /** Returns non-zero if the Sk64 can be represented as a signed 32 bit integer
-    */
-    SkBool is32() const { return fHi == ((int32_t)fLo >> 31); }
-
-    /** Returns non-zero if the Sk64 cannot be represented as a signed 32 bit integer
-    */
-    SkBool is64() const { return fHi != ((int32_t)fLo >> 31); }
-
-    /** Return the signed 32 bit integer equivalent. Asserts that is32() returns non-zero.
-    */
-    int32_t get32() const { SkASSERT(this->is32()); return (int32_t)fLo; }
-
-    /** Returns the square-root of the number as a signed 32 bit value. */
-    int32_t getSqrt() const;
-
-    /** Returns the number of leading zeros of the absolute value of this.
-        Will return in the range [0..64]
-    */
-    int getClzAbs() const;
-
-    /** Returns non-zero if the number is zero */
-    SkBool  isZero() const { return (fHi | fLo) == 0; }
-
-    /** Returns non-zero if the number is non-zero */
-    SkBool  nonZero() const { return fHi | fLo; }
-
-    /** Returns non-zero if the number is negative (number < 0) */
-    SkBool  isNeg() const { return (uint32_t)fHi >> 31; }
-
-    /** Returns non-zero if the number is positive (number > 0) */
-    SkBool  isPos() const { return ~(fHi >> 31) & (fHi | fLo); }
-
-    /** Returns -1,0,+1 based on the sign of the number */
-    int     getSign() const { return (fHi >> 31) | Sk32ToBool(fHi | fLo); }
-
-    /** Negate the number */
-    void    negate();
-
-    /** If the number < 0, negate the number
-    */
-    void    abs();
-
-    /** Returns the number of bits needed to shift the Sk64 to the right
-        in order to make it fit in a signed 32 bit integer.
-    */
-    int     shiftToMake32() const;
-
-    /** Set the number to zero */
-    void    setZero() { fHi = fLo = 0; }
-
-    /** Set the high and low 32 bit values of the number */
-    void    set(int32_t hi, uint32_t lo) { fHi = hi; fLo = lo; }
-
-    /** Set the number to the specified 32 bit integer */
-    void    set(int32_t a) { fHi = a >> 31; fLo = a; }
-
-    /** Set the number to the product of the two 32 bit integers */
-    void    setMul(int32_t a, int32_t b);
-
-    /** extract 32bits after shifting right by bitCount.
-        Note: itCount must be [0..63].
-        Asserts that no significant high bits were lost.
-    */
-    int32_t getShiftRight(unsigned bitCount) const;
-
-    /** Shift the number left by the specified number of bits.
-        @param bits How far to shift left, must be [0..63]
-    */
-    void    shiftLeft(unsigned bits);
-
-    /** Shift the number right by the specified number of bits.
-        @param bits How far to shift right, must be [0..63]. This
-        performs an arithmetic right-shift (sign extending).
-    */
-    void    shiftRight(unsigned bits);
-
-    /** Shift the number right by the specified number of bits, but
-        round the result.
-        @param bits How far to shift right, must be [0..63]. This
-        performs an arithmetic right-shift (sign extending).
-    */
-    void    roundRight(unsigned bits);
-
-    /** Add the specified 32 bit integer to the number */
-    void add(int32_t lo) {
-        int32_t  hi = lo >> 31; // 0 or -1
-        uint32_t sum = fLo + (uint32_t)lo;
-
-        fHi = fHi + hi + (sum < fLo);
-        fLo = sum;
-    }
-
-    /** Add the specified Sk64 to the number */
-    void add(int32_t hi, uint32_t lo) {
-        uint32_t sum = fLo + lo;
-
-        fHi = fHi + hi + (sum < fLo);
-        fLo = sum;
-    }
-
-    /** Add the specified Sk64 to the number */
-    void    add(const Sk64& other) { this->add(other.fHi, other.fLo); }
-
-    /** Subtract the specified Sk64 from the number. (*this) = (*this) - num
-    */
-    void    sub(const Sk64& num);
-
-    /** Subtract the number from the specified Sk64. (*this) = num - (*this)
-    */
-    void    rsub(const Sk64& num);
-
-    /** Multiply the number by the specified 32 bit integer
-    */
-    void    mul(int32_t);
-
-    enum DivOptions {
-        kTrunc_DivOption,   //!< truncate the result when calling div()
-        kRound_DivOption    //!< round the result when calling div()
-    };
-
-    /** Divide the number by the specified 32 bit integer, using the specified
-        divide option (either truncate or round).
-    */
-    void    div(int32_t, DivOptions);
-
-    friend bool operator==(const Sk64& a, const Sk64& b) {
-        return a.fHi == b.fHi && a.fLo == b.fLo;
-    }
-
-    friend bool operator!=(const Sk64& a, const Sk64& b) {
-        return a.fHi != b.fHi || a.fLo != b.fLo;
-    }
-
-    friend bool operator<(const Sk64& a, const Sk64& b) {
-        return a.fHi < b.fHi || (a.fHi == b.fHi && a.fLo < b.fLo);
-    }
-
-    friend bool operator<=(const Sk64& a, const Sk64& b) {
-        return a.fHi < b.fHi || (a.fHi == b.fHi && a.fLo <= b.fLo);
-    }
-
-    friend bool operator>(const Sk64& a, const Sk64& b) {
-        return a.fHi > b.fHi || (a.fHi == b.fHi && a.fLo > b.fLo);
-    }
-
-    friend bool operator>=(const Sk64& a, const Sk64& b) {
-        return a.fHi > b.fHi || (a.fHi == b.fHi && a.fLo >= b.fLo);
-    }
-
-    // Private to unittests. Parameter is (skiatest::Reporter*)
-    static void UnitTestWithReporter(void* skiatest_reporter);
-};
-
-#endif
index 42194ed..9ec0a7a 100644 (file)
@@ -156,15 +156,9 @@ int32_t SkFloat::Add(int32_t packed_a, int32_t packed_b)
     return SkFloat::SetShift(value_a + value_b, exp - EXP_BIAS);
 }
 
-#include "Sk64.h"
-
-static inline int32_t mul24(int32_t a, int32_t b)
-{
-    Sk64 tmp;
-
-    tmp.setMul(a, b);
-    tmp.roundRight(24);
-    return tmp.get32();
+static inline int32_t mul24(int32_t a, int32_t b) {
+    int64_t tmp = (sk_64_mul(a, b) + (1 << 23)) >> 24;
+    return sk_64_asS32(tmp);
 }
 
 int32_t SkFloat::Mul(int32_t packed_a, int32_t packed_b)
index 6295202..85ad399 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright 2006 The Android Open Source Project
  *
@@ -6,9 +5,7 @@
  * found in the LICENSE file.
  */
 
-
 #include "SkGeometry.h"
-#include "Sk64.h"
 #include "SkMatrix.h"
 
 bool SkXRayCrossesLine(const SkXRay& pt, const SkPoint pts[2], bool* ambiguous) {
index 634b895..95a8166 100644 (file)
@@ -9,7 +9,6 @@
 
 #include "SkGraphics.h"
 
-#include "Sk64.h"
 #include "SkBlitter.h"
 #include "SkCanvas.h"
 #include "SkFloat.h"
index 0974419..f3ae88a 100644 (file)
@@ -5,18 +5,15 @@
  * found in the LICENSE file.
  */
 
-
-#include "Sk64.h"
 #include "SkMask.h"
 
 /** returns the product if it is positive and fits in 31 bits. Otherwise this
     returns 0.
  */
 static int32_t safeMul32(int32_t a, int32_t b) {
-    Sk64 size;
-    size.setMul(a, b);
-    if (size.is32() && size.isPos()) {
-        return size.get32();
+    int64_t size = sk_64_mul(a, b);
+    if (size > 0 && sk_64_isS32(size)) {
+        return sk_64_asS32(size);
     }
     return 0;
 }
index e7c4fdc..25ac9aa 100644 (file)
@@ -8,7 +8,6 @@
 #include "SkMathPriv.h"
 #include "SkFloatBits.h"
 #include "SkFloatingPoint.h"
-#include "Sk64.h"
 #include "SkScalar.h"
 
 const uint32_t gIEEENotANumber = 0x7FFFFFFF;
@@ -47,10 +46,8 @@ int SkCLZ_portable(uint32_t x) {
 int32_t SkMulDiv(int32_t numer1, int32_t numer2, int32_t denom) {
     SkASSERT(denom);
 
-    Sk64 tmp;
-    tmp.setMul(numer1, numer2);
-    tmp.div(denom, Sk64::kTrunc_DivOption);
-    return tmp.get32();
+    int64_t tmp = sk_64_mul(numer1, numer2) / denom;
+    return sk_64_asS32(tmp);
 }
 
 SkFixed SkFixedMul_portable(SkFixed a, SkFixed b) {
index d3d1610..f32f485 100644 (file)
@@ -6,7 +6,6 @@
  */
 
 #include "SkMatrix.h"
-#include "Sk64.h"
 #include "SkFloatBits.h"
 #include "SkOnce.h"
 #include "SkString.h"
index efb94f4..76e63c7 100644 (file)
@@ -1,4 +1,3 @@
-
 /*
  * Copyright 2006 The Android Open Source Project
  *
@@ -6,20 +5,13 @@
  * found in the LICENSE file.
  */
 
-
 #include "SkCullPoints.h"
-#include "Sk64.h"
 
 static bool cross_product_is_neg(const SkIPoint& v, int dx, int dy) {
 #if 0
     return v.fX * dy - v.fY * dx < 0;
 #else
-    Sk64   tmp0, tmp1;
-
-    tmp0.setMul(v.fX, dy);
-    tmp1.setMul(dx, v.fY);
-    tmp0.sub(tmp1);
-    return tmp0.isNeg() != 0;
+    return sk_64_mul(v.fX, dy) < sk_64_mul(dx, v.fY);
 #endif
 }
 
diff --git a/tests/Sk64Test.cpp b/tests/Sk64Test.cpp
deleted file mode 100644 (file)
index d668e54..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright 2011 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "Test.h"
-#include "TestClassDef.h"
-#include "Sk64.h"
-#include "SkRandom.h"
-#include <math.h>
-
-struct BoolTable {
-    int8_t  zero, pos, neg, toBool, sign;
-};
-
-static void bool_table_test(skiatest::Reporter* reporter,
-                            const Sk64& a, const BoolTable& table)
-{
-    REPORTER_ASSERT(reporter, a.isZero() != a.nonZero());
-
-    REPORTER_ASSERT(reporter, !a.isZero() == !table.zero);
-    REPORTER_ASSERT(reporter, !a.isPos() == !table.pos);
-    REPORTER_ASSERT(reporter, !a.isNeg() == !table.neg);
-    REPORTER_ASSERT(reporter, a.getSign() == table.sign);
-}
-
-void Sk64::UnitTestWithReporter(void* reporterParam) {
-    skiatest::Reporter* reporter = (skiatest::Reporter*)reporterParam;
-
-    enum BoolTests {
-        kZero_BoolTest,
-        kPos_BoolTest,
-        kNeg_BoolTest
-    };
-    static const BoolTable gBoolTable[] = {
-        { 1, 0, 0, 0, 0 },
-        { 0, 1, 0, 1, 1 },
-        { 0, 0, 1, 1, -1 }
-    };
-
-    Sk64    a, b, c;
-
-    a.fHi = a.fLo = 0;
-    b.set(0);
-    c.setZero();
-    REPORTER_ASSERT(reporter, a == b);
-    REPORTER_ASSERT(reporter, a == c);
-    bool_table_test(reporter, a, gBoolTable[kZero_BoolTest]);
-
-    a.fHi = 0;  a.fLo = 5;
-    b.set(5);
-    REPORTER_ASSERT(reporter, a == b);
-    REPORTER_ASSERT(reporter, a.is32() && a.get32() == 5 && !a.is64());
-    bool_table_test(reporter, a, gBoolTable[kPos_BoolTest]);
-
-    a.fHi = -1; a.fLo = (uint32_t)-5;
-    b.set(-5);
-    REPORTER_ASSERT(reporter, a == b);
-    REPORTER_ASSERT(reporter, a.is32() && a.get32() == -5 && !a.is64());
-    bool_table_test(reporter, a, gBoolTable[kNeg_BoolTest]);
-
-    a.setZero();
-    b.set(6);
-    c.set(-6);
-    REPORTER_ASSERT(reporter, a != b && b != c && a != c);
-    REPORTER_ASSERT(reporter, !(a == b) && !(a == b) && !(a == b));
-    REPORTER_ASSERT(reporter, a < b && b > a && a <= b && b >= a);
-    REPORTER_ASSERT(reporter, c < a && a > c && c <= a && a >= c);
-    REPORTER_ASSERT(reporter, c < b && b > c && c <= b && b >= c);
-
-    // Now test add/sub
-
-    SkRandom    rand;
-    int         i;
-
-    for (i = 0; i < 1000; i++)
-    {
-        int aa = rand.nextS() >> 1;
-        int bb = rand.nextS() >> 1;
-        a.set(aa);
-        b.set(bb);
-        REPORTER_ASSERT(reporter, a.get32() == aa && b.get32() == bb);
-        c = a; c.add(bb);
-        REPORTER_ASSERT(reporter, c.get32() == aa + bb);
-        c = a; c.add(-bb);
-        REPORTER_ASSERT(reporter, c.get32() == aa - bb);
-        c = a; c.add(b);
-        REPORTER_ASSERT(reporter, c.get32() == aa + bb);
-        c = a; c.sub(b);
-        REPORTER_ASSERT(reporter, c.get32() == aa - bb);
-    }
-
-    for (i = 0; i < 1000; i++) {
-        a.set64(rand.next64());
-        b.set64(rand.next64());
-
-        if (!(i & 3))   // want to explicitly test these cases
-        {
-            a.fLo = 0;
-            b.fLo = 0;
-        }
-        else if (!(i & 7))  // want to explicitly test these cases
-        {
-            a.fHi = 0;
-            b.fHi = 0;
-        }
-
-        int64_t aa = a.as64();
-        int64_t bb = b.as64();
-
-        REPORTER_ASSERT(reporter, (a < b) == (aa < bb));
-        REPORTER_ASSERT(reporter, (a <= b) == (aa <= bb));
-        REPORTER_ASSERT(reporter, (a > b) == (aa > bb));
-        REPORTER_ASSERT(reporter, (a >= b) == (aa >= bb));
-        REPORTER_ASSERT(reporter, (a == b) == (aa == bb));
-        REPORTER_ASSERT(reporter, (a != b) == (aa != bb));
-
-        c = a; c.add(b);
-        REPORTER_ASSERT(reporter, c.as64() == aa + bb);
-        c = a; c.sub(b);
-        REPORTER_ASSERT(reporter, c.as64() == aa - bb);
-        c = a; c.rsub(b);
-        REPORTER_ASSERT(reporter, c.as64() == bb - aa);
-        c = a; c.negate();
-        REPORTER_ASSERT(reporter, c.as64() == -aa);
-
-        int bits = rand.nextU() & 63;
-        c = a; c.shiftLeft(bits);
-        REPORTER_ASSERT(reporter, c.as64() == (aa << bits));
-        c = a; c.shiftRight(bits);
-        REPORTER_ASSERT(reporter, c.as64() == (aa >> bits));
-        c = a; c.roundRight(bits);
-
-        int64_t tmp;
-
-        tmp = aa;
-        if (bits > 0)
-            tmp += (int64_t)1 << (bits - 1);
-        REPORTER_ASSERT(reporter, c.as64() == (tmp >> bits));
-
-        c.setMul(a.fHi, b.fHi);
-        tmp = (int64_t)a.fHi * b.fHi;
-        REPORTER_ASSERT(reporter, c.as64() == tmp);
-    }
-
-
-    for (i = 0; i < 100000; i++)
-    {
-        Sk64    wide;
-        int32_t denom = rand.nextS();
-
-        while (denom == 0)
-            denom = rand.nextS();
-        wide.setMul(rand.nextS(), rand.nextS());
-        int64_t check = wide.getLongLong();
-
-        wide.div(denom, Sk64::kTrunc_DivOption);
-        check /= denom;
-        int64_t w = wide.getLongLong();
-
-        REPORTER_ASSERT(reporter, check == w);
-
-        wide.setMul(rand.nextS(), rand.nextS());
-        wide.abs();
-        denom = wide.getSqrt();
-        int32_t ck = (int32_t)sqrt((double)wide.getLongLong());
-        int diff = denom - ck;
-        REPORTER_ASSERT(reporter, SkAbs32(diff) <= 1);
-    }
-}
-
-DEF_TEST(Sk64Test, reporter) {
-    Sk64::UnitTestWithReporter(reporter);
-}