blob: e9d6feb4531838329930e5aa43b121b9ff945274 [file] [log] [blame]
reed@google.comac10a2d2010-12-22 21:39:39 +00001/*
epoger@google.comec3ed6a2011-07-28 14:26:00 +00002 * Copyright 2010 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
reed@google.comac10a2d2010-12-22 21:39:39 +00006 */
7
reed@google.comac10a2d2010-12-22 21:39:39 +00008#ifndef GrKey_DEFINED
9#define GrKey_DEFINED
10
commit-bot@chromium.orga4de8c22013-09-09 13:38:37 +000011class GrKey : public SkRefCnt {
reed@google.comac10a2d2010-12-22 21:39:39 +000012public:
reed@google.comfa35e3d2012-06-26 20:16:17 +000013 SK_DECLARE_INST_COUNT(GrKey)
14
reed@google.comac10a2d2010-12-22 21:39:39 +000015 typedef intptr_t Hash;
16
17 explicit GrKey(Hash hash) : fHash(hash) {}
18
19 intptr_t getHash() const { return fHash; }
20
21 bool operator<(const GrKey& rh) const {
22 return fHash < rh.fHash || (fHash == rh.fHash && this->lt(rh));
23 }
24 bool operator==(const GrKey& rh) const {
25 return fHash == rh.fHash && this->eq(rh);
26 }
27
28protected:
29 virtual bool lt(const GrKey& rh) const = 0;
30 virtual bool eq(const GrKey& rh) const = 0;
31
32private:
33 const Hash fHash;
reed@google.comfa35e3d2012-06-26 20:16:17 +000034
commit-bot@chromium.orga4de8c22013-09-09 13:38:37 +000035 typedef SkRefCnt INHERITED;
reed@google.comac10a2d2010-12-22 21:39:39 +000036};
37
38#endif