aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkBitmapHasher.h
blob: d52a6d739c1ba52746bdc2587bf0751de05754ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

/*
 * 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 config, 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