Re-land r9059 with empty cityhash.gyp, instead of deleted cityhash.gyp

R=rmistry@google.com

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



git-svn-id: http://skia.googlecode.com/svn/trunk@9064 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/DEPS b/DEPS
index 4a26a46..c2e5de9 100644
--- a/DEPS
+++ b/DEPS
@@ -9,7 +9,6 @@
 #
 deps = {
   "third_party/externals/angle" : "http://angleproject.googlecode.com/svn/trunk@1268",
-  "third_party/externals/cityhash" : "http://cityhash.googlecode.com/svn/trunk@11",
   "third_party/externals/freetype" : "https://android.googlesource.com/platform/external/freetype.git",
   "third_party/externals/gyp" : "http://gyp.googlecode.com/svn/trunk@1563",
   "third_party/externals/libjpeg" : "http://src.chromium.org/svn/trunk/src/third_party/libjpeg@125399",
diff --git a/bench/ChecksumBench.cpp b/bench/ChecksumBench.cpp
index 5491f05..d2497d7 100644
--- a/bench/ChecksumBench.cpp
+++ b/bench/ChecksumBench.cpp
@@ -7,7 +7,6 @@
 #include "SkBenchmark.h"
 #include "SkCanvas.h"
 #include "SkChecksum.h"
-#include "SkCityHash.h"
 #include "SkMD5.h"
 #include "SkRandom.h"
 #include "SkSHA1.h"
@@ -16,9 +15,7 @@
 enum ChecksumType {
     kChecksum_ChecksumType,
     kMD5_ChecksumType,
-    kSHA1_ChecksumType,
-    kCityHash32,
-    kCityHash64
+    kSHA1_ChecksumType
 };
 
 class ComputeChecksumBench : public SkBenchmark {
@@ -45,8 +42,6 @@
             case kChecksum_ChecksumType: return "compute_checksum";
             case kMD5_ChecksumType: return "compute_md5";
             case kSHA1_ChecksumType: return "compute_sha1";
-            case kCityHash32: return "compute_cityhash32";
-            case kCityHash64: return "compute_cityhash64";
             default: SK_CRASH(); return "";
         }
     }
@@ -75,18 +70,6 @@
                     sha1.finish(digest);
                 }
             } break;
-            case kCityHash32: {
-                for (int i = 0; i < N; i++) {
-                    volatile uint32_t result = SkCityHash::Compute32(reinterpret_cast<char*>(fData), sizeof(fData));
-                    sk_ignore_unused_variable(result);
-                }
-            } break;
-            case kCityHash64: {
-                for (int i = 0; i < N; i++) {
-                    volatile uint64_t result = SkCityHash::Compute64(reinterpret_cast<char*>(fData), sizeof(fData));
-                    sk_ignore_unused_variable(result);
-                }
-            } break;
         }
 
     }
@@ -100,11 +83,7 @@
 static SkBenchmark* Fact0(void* p) { return new ComputeChecksumBench(p, kChecksum_ChecksumType); }
 static SkBenchmark* Fact1(void* p) { return new ComputeChecksumBench(p, kMD5_ChecksumType); }
 static SkBenchmark* Fact2(void* p) { return new ComputeChecksumBench(p, kSHA1_ChecksumType); }
-static SkBenchmark* Fact3(void* p) { return new ComputeChecksumBench(p, kCityHash32); }
-static SkBenchmark* Fact4(void* p) { return new ComputeChecksumBench(p, kCityHash64); }
 
 static BenchRegistry gReg0(Fact0);
 static BenchRegistry gReg1(Fact1);
 static BenchRegistry gReg2(Fact2);
-static BenchRegistry gReg3(Fact3);
-static BenchRegistry gReg4(Fact4);
diff --git a/gm/gm_expectations.cpp b/gm/gm_expectations.cpp
index 16e655e..72fb0e6 100644
--- a/gm/gm_expectations.cpp
+++ b/gm/gm_expectations.cpp
@@ -16,18 +16,10 @@
 const static char kJsonKey_ActualResults_FailureIgnored[]= "failure-ignored";
 const static char kJsonKey_ActualResults_NoComparison[]  = "no-comparison";
 const static char kJsonKey_ActualResults_Succeeded[]     = "succeeded";
-#ifdef BITMAPHASHER_USES_TRUNCATED_MD5
 const static char kJsonKey_ActualResults_AnyStatus_BitmapHash[]  = "bitmap-64bitMD5";
-#else
-const static char kJsonKey_ActualResults_AnyStatus_BitmapHash[]  = "bitmap-cityhash";
-#endif
 
 const static char kJsonKey_ExpectedResults[] = "expected-results";
-#ifdef BITMAPHASHER_USES_TRUNCATED_MD5
 const static char kJsonKey_ExpectedResults_AllowedBitmapHashes[] = "allowed-bitmap-64bitMD5s";
-#else
-const static char kJsonKey_ExpectedResults_AllowedBitmapHashes[] = "allowed-bitmap-cityhashes";
-#endif
 const static char kJsonKey_ExpectedResults_IgnoreFailure[]           = "ignore-failure";
 
 namespace skiagm {
diff --git a/gyp/cityhash.gyp b/gyp/cityhash.gyp
index f35f1f0..461c8cc 100644
--- a/gyp/cityhash.gyp
+++ b/gyp/cityhash.gyp
@@ -1,33 +1,5 @@
+# Do-nothing gypfile, to keep the buildbots green.
+# See https://code.google.com/p/skia/issues/detail?id=1286
+# ('removing cityhash.gyp broke SOME but not ALL buildbots')
 {
-  'variables': {
-    'skia_warnings_as_errors': 0,
-  },
-  'targets': [
-    {
-      'target_name': 'cityhash',
-      'type': 'static_library',
-      'standalone_static_library': 1,
-      'include_dirs': [
-        '../include/config',
-        '../include/core',
-        '../src/utils/cityhash',
-        '../third_party/externals/cityhash/src',
-      ],
-      'sources': [
-        '../third_party/externals/cityhash/src/city.cc',
-      ],
-      'direct_dependent_settings': {
-        'include_dirs': [
-          '../third_party/externals/cityhash/src',
-        ],
-      },
-      'conditions': [
-        [ 'skia_os == "android"', {
-          'cflags!': [
-            '-Wall',
-          ],
-        }],
-      ],
-    },
-  ],
 }
diff --git a/gyp/utils.gyp b/gyp/utils.gyp
index 169bfbf..a1820c0 100644
--- a/gyp/utils.gyp
+++ b/gyp/utils.gyp
@@ -5,9 +5,6 @@
       'product_name': 'skia_utils',
       'type': 'static_library',
       'standalone_static_library': 1,
-      'dependencies': [
-        'cityhash.gyp:cityhash',
-      ],
       'include_dirs': [
         '../include/config',
         '../include/core',
@@ -64,8 +61,6 @@
         '../src/utils/SkBitSet.h',
         '../src/utils/SkBoundaryPatch.cpp',
         '../src/utils/SkCamera.cpp',
-        '../src/utils/SkCityHash.cpp',
-        '../src/utils/SkCityHash.h',
         '../src/utils/SkCubicInterval.cpp',
         '../src/utils/SkCullPoints.cpp',
         '../src/utils/SkDeferredCanvas.cpp',
@@ -195,15 +190,6 @@
           ],
           'sources!': [
             '../src/utils/SkThreadUtils_pthread_linux.cpp',
-            '../src/utils/SkCityHash.cpp',
-            '../src/utils/SkCityHash.h',
-          ],
-          'dependencies!': [
-            # CityHash is not supported on NaCl because the NaCl toolchain is
-            # missing byteswap.h which is needed by CityHash.
-            # TODO(borenet): Find a way to either provide this dependency or
-            # replace it.
-            'cityhash.gyp:cityhash',
           ],
         }],
         [ 'skia_os == "android"', {
diff --git a/src/utils/SkBitmapHasher.cpp b/src/utils/SkBitmapHasher.cpp
index 82cbe9f..5342d18 100644
--- a/src/utils/SkBitmapHasher.cpp
+++ b/src/utils/SkBitmapHasher.cpp
@@ -10,12 +10,7 @@
 #include "SkEndian.h"
 #include "SkImageEncoder.h"
 
-#ifdef BITMAPHASHER_USES_TRUNCATED_MD5
 #include "SkMD5.h"
-#else
-#include "SkCityHash.h"
-#include "SkStream.h"
-#endif
 
 /**
  * Write an int32 value to a stream in little-endian order.
@@ -37,16 +32,7 @@
 
 /*static*/ bool SkBitmapHasher::ComputeDigestInternal(const SkBitmap& bitmap,
                                                       SkHashDigest *result) {
-#ifdef BITMAPHASHER_USES_TRUNCATED_MD5
     SkMD5 out;
-#else
-    size_t pixelBufferSize = bitmap.width() * bitmap.height() * 4;
-    size_t totalBufferSize = pixelBufferSize + 2 * sizeof(uint32_t);
-
-    SkAutoMalloc bufferManager(totalBufferSize);
-    char *bufferStart = static_cast<char *>(bufferManager.get());
-    SkMemoryWStream out(bufferStart, totalBufferSize);
-#endif
 
     // start with the x/y dimensions
     write_int32_to_buffer(SkToU32(bitmap.width()), &out);
@@ -58,13 +44,9 @@
         return false;
     }
 
-#ifdef BITMAPHASHER_USES_TRUNCATED_MD5
     SkMD5::Digest digest;
     out.finish(digest);
     *result = first_8_bytes_as_uint64(digest.data);
-#else
-    *result = SkCityHash::Compute64(bufferStart, totalBufferSize);
-#endif
     return true;
 }
 
diff --git a/src/utils/SkBitmapHasher.h b/src/utils/SkBitmapHasher.h
index c99421a..165da3d 100644
--- a/src/utils/SkBitmapHasher.h
+++ b/src/utils/SkBitmapHasher.h
@@ -11,8 +11,6 @@
 
 #include "SkBitmap.h"
 
-#define BITMAPHASHER_USES_TRUNCATED_MD5
-
 // TODO(epoger): Soon, SkHashDigest will become a real class of its own,
 // and callers won't be able to assume it converts to/from a uint64_t.
 typedef uint64_t SkHashDigest;
diff --git a/src/utils/SkCityHash.cpp b/src/utils/SkCityHash.cpp
deleted file mode 100644
index a21aa89..0000000
--- a/src/utils/SkCityHash.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/**
- * Pass any calls through to the CityHash library.
- * This is the only source file that accesses the CityHash code directly.
- */
-
-#include "SkCityHash.h"
-#include "SkTypes.h"
-#include "city.h"
-
-uint32_t SkCityHash::Compute32(const char *data, size_t size) {
-    return CityHash32(data, size);
-}
-
-uint64_t SkCityHash::Compute64(const char *data, size_t size) {
-    return CityHash64(data, size);
-}
diff --git a/src/utils/SkCityHash.h b/src/utils/SkCityHash.h
deleted file mode 100644
index c69e0fb..0000000
--- a/src/utils/SkCityHash.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/**
- * Hash functions, using the CityHash algorithm.
- *
- * Results are guaranteed to be:
- *  1. consistent across revisions of the library (for a given set
- *     of bytes, the checksum generated at one revision of the Skia
- *     library will match the one generated on any other revision of
- *     the Skia library)
- *  2. consistent across platforms (for a given
- *     set of bytes, the checksum generated on one platform will
- *     match the one generated on any other platform)
- */
-
-#ifndef SkCityHash_DEFINED
-#define SkCityHash_DEFINED
-
-#include "SkTypes.h"
-
-class SkCityHash : SkNoncopyable {
-public:
-    /**
-     *  Compute a 32-bit checksum for a given data block.
-     *
-     *  @param data Memory address of the data block to be processed.
-     *  @param size Size of the data block in bytes.
-     *  @return checksum result
-     */
-    static uint32_t Compute32(const char *data, size_t size);
-
-    /**
-     *  Compute a 64-bit checksum for a given data block.
-     *
-     *  @param data Memory address of the data block to be processed.
-     *  @param size Size of the data block in bytes.
-     *  @return checksum result
-     */
-    static uint64_t Compute64(const char *data, size_t size);
-};
-
-#endif
diff --git a/src/utils/cityhash/README b/src/utils/cityhash/README
deleted file mode 100644
index d939288..0000000
--- a/src/utils/cityhash/README
+++ /dev/null
@@ -1,2 +0,0 @@
-This directory contains files needed to build third_party/externals/cityhash
-(such as the config.h file that would normally be created by autoconf)
diff --git a/src/utils/cityhash/config.h b/src/utils/cityhash/config.h
deleted file mode 100644
index bd36416..0000000
--- a/src/utils/cityhash/config.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright 2012 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-/**
- * Converts from Skia build flags to the macro definitions cityhash normally
- * gets from autoconf.
- */
-
-#include "SkTypes.h"
-
-#ifdef SK_CPU_BENDIAN
-  #define WORDS_BIGENDIAN 1
-#endif
diff --git a/tests/ChecksumTest.cpp b/tests/ChecksumTest.cpp
index 81e7ef3..ee33d32 100644
--- a/tests/ChecksumTest.cpp
+++ b/tests/ChecksumTest.cpp
@@ -8,7 +8,6 @@
 #include "Test.h"
 
 #include "SkChecksum.h"
-#include "SkCityHash.h"
 
 // Word size that is large enough to hold results of any checksum type.
 typedef uint64_t checksum_result;
@@ -25,9 +24,7 @@
         }
     private:
         enum Algorithm {
-            kSkChecksum,
-            kSkCityHash32,
-            kSkCityHash64
+            kSkChecksum
         };
 
         // Call Compute(data, size) on the appropriate checksum algorithm,
@@ -41,10 +38,6 @@
                 REPORTER_ASSERT_MESSAGE(fReporter, SkIsAlign4(size),
                                         "test data size is not 32-bit aligned");
                 return SkChecksum::Compute(reinterpret_cast<const uint32_t *>(data), size);
-            case kSkCityHash32:
-                return SkCityHash::Compute32(data, size);
-            case kSkCityHash64:
-                return SkCityHash::Compute64(data, size);
             default:
                 SkString message("fWhichAlgorithm has unknown value ");
                 message.appendf("%d", fWhichAlgorithm);
@@ -108,31 +101,11 @@
             // Test self-consistency of checksum algorithms.
             fWhichAlgorithm = kSkChecksum;
             TestChecksumSelfConsistency(128);
-            fWhichAlgorithm = kSkCityHash32;
-            TestChecksumSelfConsistency(128);
-            fWhichAlgorithm = kSkCityHash64;
-            TestChecksumSelfConsistency(128);
 
             // Test checksum results that should be consistent across
             // versions and platforms.
             fWhichAlgorithm = kSkChecksum;
             REPORTER_ASSERT(fReporter, ComputeChecksum(NULL, 0) == 0);
-            fWhichAlgorithm = kSkCityHash32;
-            REPORTER_ASSERT(fReporter, ComputeChecksum(NULL, 0) == 0xdc56d17a);
-            REPORTER_ASSERT(fReporter, GetTestDataChecksum(4)   == 0x616e1132);
-            REPORTER_ASSERT(fReporter, GetTestDataChecksum(8)   == 0xeb0fd2d6);
-            REPORTER_ASSERT(fReporter, GetTestDataChecksum(128) == 0x5321e430);
-            REPORTER_ASSERT(fReporter, GetTestDataChecksum(132) == 0x924a10e4);
-            REPORTER_ASSERT(fReporter, GetTestDataChecksum(256) == 0xd4de9dc9);
-            REPORTER_ASSERT(fReporter, GetTestDataChecksum(260) == 0xecf0325d);
-            fWhichAlgorithm = kSkCityHash64;
-            REPORTER_ASSERT(fReporter, ComputeChecksum(NULL, 0) == 0x9ae16a3b2f90404fULL);
-            REPORTER_ASSERT(fReporter, GetTestDataChecksum(4)   == 0x82bffd898958e540ULL);
-            REPORTER_ASSERT(fReporter, GetTestDataChecksum(8)   == 0xad5a13e1e8e93b98ULL);
-            REPORTER_ASSERT(fReporter, GetTestDataChecksum(128) == 0x10b153630af1f395ULL);
-            REPORTER_ASSERT(fReporter, GetTestDataChecksum(132) == 0x7db71dc4adcc6647ULL);
-            REPORTER_ASSERT(fReporter, GetTestDataChecksum(256) == 0xeee763519b91b010ULL);
-            REPORTER_ASSERT(fReporter, GetTestDataChecksum(260) == 0x2fe19e0b2239bc23ULL);
 
             // TODO: note the weakness exposed by these collisions...
             // We need to improve the SkChecksum algorithm.