aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkBitmapHasher.h
blob: dc8685bddb07eff7017aaac714ac60b4c778886e (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
36
37
38
39
40
41
42

/*
 * 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"
#include "SkBitmapTransformer.h"

// TODO(epoger): Soon, SkHashDigest will become a real class of its own,
// and callers won't be able to assume it converts to/from a uint64_t.
typedef uint64_t SkHashDigest;

/**
 * Static class that can generate an SkHashDigest 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, SkHashDigest *result);

private:
    static bool ComputeDigestInternal(const SkBitmap& bitmap,
                                      const SkBitmapTransformer& transformer,
                                      SkHashDigest *result);
};

#endif