blob: c8a5c0406f4b6410528d14746bb730a0a738a6ee [file] [log] [blame]
epoger@google.com908f5832013-04-12 02:23:55 +00001
2/*
3 * Copyright 2012 Google Inc.
4 *
5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file.
7 */
8
9#ifndef SkBitmapHasher_DEFINED
10#define SkBitmapHasher_DEFINED
11
12#include "SkBitmap.h"
epoger@google.com908f5832013-04-12 02:23:55 +000013
epoger@google.com908f5832013-04-12 02:23:55 +000014/**
epoger@google.comd4993ff2013-05-24 14:33:28 +000015 * Static class that generates a uint64 hash digest from an SkBitmap.
epoger@google.com908f5832013-04-12 02:23:55 +000016 */
17class SkBitmapHasher {
18public:
19 /**
20 * Fills in "result" with a hash of the pixels in this bitmap.
21 *
22 * If this is unable to compute the hash for some reason,
23 * it returns false.
24 *
reedc77392e2014-06-02 13:07:26 -070025 * Note: depending on the bitmap colortype, we may need to create an
epoger@google.com908f5832013-04-12 02:23:55 +000026 * intermediate SkBitmap and copy the pixels over to it... so in some
27 * cases, performance and memory usage can suffer.
28 */
epoger@google.comd4993ff2013-05-24 14:33:28 +000029 static bool ComputeDigest(const SkBitmap& bitmap, uint64_t *result);
epoger@google.com908f5832013-04-12 02:23:55 +000030
31private:
epoger@google.comd4993ff2013-05-24 14:33:28 +000032 static bool ComputeDigestInternal(const SkBitmap& bitmap, uint64_t *result);
epoger@google.com908f5832013-04-12 02:23:55 +000033};
34
35#endif