Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: src/utils/SkBitmapHasher.cpp

Issue 1704783002: Delete dead code. SkBitmapHasher has not been used since gm. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/utils/SkBitmapHasher.h ('k') | tests/BitmapHasherTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkBitmapHasher.cpp
diff --git a/src/utils/SkBitmapHasher.cpp b/src/utils/SkBitmapHasher.cpp
deleted file mode 100644
index 32ff1cb0816f664587872fa15b1f691891ec64fb..0000000000000000000000000000000000000000
--- 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);
-}
« no previous file with comments | « src/utils/SkBitmapHasher.h ('k') | tests/BitmapHasherTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698