aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--gm/gm_expectations.h1
-rw-r--r--gyp/utils.gypi2
-rw-r--r--src/utils/SkBitmapHasher.cpp64
-rw-r--r--src/utils/SkBitmapHasher.h35
-rw-r--r--tests/BitmapHasherTest.cpp40
5 files changed, 0 insertions, 142 deletions
diff --git a/gm/gm_expectations.h b/gm/gm_expectations.h
index 6767b90f51..52e711fe7f 100644
--- a/gm/gm_expectations.h
+++ b/gm/gm_expectations.h
@@ -11,7 +11,6 @@
#include "gm.h"
#include "SkBitmap.h"
-#include "SkBitmapHasher.h"
#include "SkData.h"
#include "SkJSONCPP.h"
#include "SkOSFile.h"
diff --git a/gyp/utils.gypi b/gyp/utils.gypi
index 7af1fd6f34..9a974ce532 100644
--- a/gyp/utils.gypi
+++ b/gyp/utils.gypi
@@ -35,8 +35,6 @@
'<(skia_src_path)/utils/SkBase64.cpp',
'<(skia_src_path)/utils/SkBase64.h',
- '<(skia_src_path)/utils/SkBitmapHasher.cpp',
- '<(skia_src_path)/utils/SkBitmapHasher.h',
'<(skia_src_path)/utils/SkBitmapSourceDeserializer.cpp',
'<(skia_src_path)/utils/SkBitmapSourceDeserializer.h',
'<(skia_src_path)/utils/SkBitSet.cpp',
diff --git a/src/utils/SkBitmapHasher.cpp b/src/utils/SkBitmapHasher.cpp
deleted file mode 100644
index 32ff1cb081..0000000000
--- a/src/utils/SkBitmapHasher.cpp
+++ /dev/null
@@ -1,64 +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.
- */
-
-#include "SkBitmap.h"
-#include "SkBitmapHasher.h"
-#include "SkEndian.h"
-#include "SkImageEncoder.h"
-
-#include "SkMD5.h"
-
-/**
- * Write an int32 value to a stream in little-endian order.
- */
-static void write_int32_to_buffer(uint32_t val, SkWStream* out) {
- val = SkEndian_SwapLE32(val);
- for (size_t byte = 0; byte < 4; ++byte) {
- out->write8((uint8_t)(val & 0xff));
- val = val >> 8;
- }
-}
-
-/**
- * Return the first 8 bytes of a bytearray, encoded as a little-endian uint64.
- */
-static inline uint64_t first_8_bytes_as_uint64(const uint8_t *bytearray) {
- return SkEndian_SwapLE64(*(reinterpret_cast<const uint64_t *>(bytearray)));
-}
-
-/*static*/ bool SkBitmapHasher::ComputeDigestInternal(const SkBitmap& bitmap, uint64_t *result) {
- SkMD5 out;
-
- // start with the x/y dimensions
- write_int32_to_buffer(SkToU32(bitmap.width()), &out);
- write_int32_to_buffer(SkToU32(bitmap.height()), &out);
-
- // add all the pixel data
- SkAutoTDelete<SkImageEncoder> enc(CreateARGBImageEncoder());
- if (!enc->encodeStream(&out, bitmap, SkImageEncoder::kDefaultQuality)) {
- return false;
- }
-
- SkMD5::Digest digest;
- out.finish(digest);
- *result = first_8_bytes_as_uint64(digest.data);
- return true;
-}
-
-/*static*/ bool SkBitmapHasher::ComputeDigest(const SkBitmap& bitmap, uint64_t *result) {
- if (ComputeDigestInternal(bitmap, result)) {
- return true;
- }
-
- // Hmm, that didn't work. Maybe if we create a new
- // version of the bitmap it will work better?
- SkBitmap copyBitmap;
- if (!bitmap.copyTo(&copyBitmap, kN32_SkColorType)) {
- return false;
- }
- return ComputeDigestInternal(copyBitmap, result);
-}
diff --git a/src/utils/SkBitmapHasher.h b/src/utils/SkBitmapHasher.h
deleted file mode 100644
index c8a5c0406f..0000000000
--- a/src/utils/SkBitmapHasher.h
+++ /dev/null
@@ -1,35 +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.
- */
-
-#ifndef SkBitmapHasher_DEFINED
-#define SkBitmapHasher_DEFINED
-
-#include "SkBitmap.h"
-
-/**
- * Static class that generates a uint64 hash digest from an SkBitmap.
- */
-class SkBitmapHasher {
-public:
- /**
- * Fills in "result" with a hash of the pixels in this bitmap.
- *
- * If this is unable to compute the hash for some reason,
- * it returns false.
- *
- * Note: depending on the bitmap colortype, we may need to create an
- * intermediate SkBitmap and copy the pixels over to it... so in some
- * cases, performance and memory usage can suffer.
- */
- static bool ComputeDigest(const SkBitmap& bitmap, uint64_t *result);
-
-private:
- static bool ComputeDigestInternal(const SkBitmap& bitmap, uint64_t *result);
-};
-
-#endif
diff --git a/tests/BitmapHasherTest.cpp b/tests/BitmapHasherTest.cpp
deleted file mode 100644
index 3b5170692d..0000000000
--- a/tests/BitmapHasherTest.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright 2013 Google Inc.
- *
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include "SkBitmapHasher.h"
-
-#include "SkBitmap.h"
-#include "SkColor.h"
-#include "Test.h"
-
-// Word size that is large enough to hold results of any checksum type.
-typedef uint64_t checksum_result;
-
-// Fill in bitmap with test data.
-static void CreateTestBitmap(SkBitmap* bitmap, int width, int height,
- SkColor color, skiatest::Reporter* reporter) {
- bitmap->allocN32Pixels(width, height, kOpaque_SkAlphaType);
- bitmap->eraseColor(color);
-}
-
-DEF_TEST(BitmapHasher, reporter) {
- // Test SkBitmapHasher
- SkBitmap bitmap;
- uint64_t digest;
- // initial test case
- CreateTestBitmap(&bitmap, 333, 555, SK_ColorBLUE, reporter);
- REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
- REPORTER_ASSERT(reporter, digest == 0xfb2903562766ef87ULL);
- // same pixel data but different dimensions should yield a different checksum
- CreateTestBitmap(&bitmap, 555, 333, SK_ColorBLUE, reporter);
- REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
- REPORTER_ASSERT(reporter, digest == 0xfe04023fb97d0f61ULL);
- // same dimensions but different color should yield a different checksum
- CreateTestBitmap(&bitmap, 555, 333, SK_ColorGREEN, reporter);
- REPORTER_ASSERT(reporter, SkBitmapHasher::ComputeDigest(bitmap, &digest));
- REPORTER_ASSERT(reporter, digest == 0x2423c51cad6d1edcULL);
-}