blob: 165da3dcc8c59374f5431a665761c2045dde7fba [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
14// TODO(epoger): Soon, SkHashDigest will become a real class of its own,
15// and callers won't be able to assume it converts to/from a uint64_t.
16typedef uint64_t SkHashDigest;
17
18/**
19 * Static class that can generate an SkHashDigest from an SkBitmap.
20 */
21class SkBitmapHasher {
22public:
23 /**
24 * Fills in "result" with a hash of the pixels in this bitmap.
25 *
26 * If this is unable to compute the hash for some reason,
27 * it returns false.
28 *
29 * Note: depending on the bitmap config, we may need to create an
30 * intermediate SkBitmap and copy the pixels over to it... so in some
31 * cases, performance and memory usage can suffer.
32 */
33 static bool ComputeDigest(const SkBitmap& bitmap, SkHashDigest *result);
34
35private:
bungeman@google.com8c6a4f22013-04-23 18:06:23 +000036 static bool ComputeDigestInternal(const SkBitmap& bitmap, SkHashDigest *result);
epoger@google.com908f5832013-04-12 02:23:55 +000037};
38
39#endif