1908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com
2908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com/*
3908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com * Copyright 2012 Google Inc.
4908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com *
5908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com * Use of this source code is governed by a BSD-style license that can be
6908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com * found in the LICENSE file.
7908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com */
8908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com
9908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com#ifndef SkBitmapHasher_DEFINED
10908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com#define SkBitmapHasher_DEFINED
11908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com
12908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com#include "SkBitmap.h"
13908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com
14908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com/**
15d4993ff3605102036f83d5834d9a022d780e5488epoger@google.com * Static class that generates a uint64 hash digest from an SkBitmap.
16908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com */
17908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.comclass SkBitmapHasher {
18908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.compublic:
19908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com    /**
20908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com     * Fills in "result" with a hash of the pixels in this bitmap.
21908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com     *
22908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com     * If this is unable to compute the hash for some reason,
23908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com     * it returns false.
24908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com     *
25c77392ed58ec78ab19fa0e3ff99fb8110854fba2reed     * Note: depending on the bitmap colortype, we may need to create an
26908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com     * intermediate SkBitmap and copy the pixels over to it... so in some
27908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com     * cases, performance and memory usage can suffer.
28908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com     */
29d4993ff3605102036f83d5834d9a022d780e5488epoger@google.com    static bool ComputeDigest(const SkBitmap& bitmap, uint64_t *result);
30908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com
31908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.comprivate:
32d4993ff3605102036f83d5834d9a022d780e5488epoger@google.com    static bool ComputeDigestInternal(const SkBitmap& bitmap, uint64_t *result);
33908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com};
34908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com
35908f5836626d792c5e33ad93f44c6a418a0cc8f5epoger@google.com#endif
36