• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  * Copyright 2010 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 
10 
11 #ifndef GrKey_DEFINED
12 #define GrKey_DEFINED
13 
14 #include "GrRefCnt.h"
15 
16 class GrKey : public GrRefCnt {
17 public:
18     typedef intptr_t Hash;
19 
GrKey(Hash hash)20     explicit GrKey(Hash hash) : fHash(hash) {}
21 
getHash()22     intptr_t getHash() const { return fHash; }
23 
24     bool operator<(const GrKey& rh) const {
25         return fHash < rh.fHash || (fHash == rh.fHash && this->lt(rh));
26     }
27     bool operator==(const GrKey& rh) const {
28         return fHash == rh.fHash && this->eq(rh);
29     }
30 
31 protected:
32     virtual bool lt(const GrKey& rh) const = 0;
33     virtual bool eq(const GrKey& rh) const = 0;
34 
35 private:
36     const Hash fHash;
37 };
38 
39 #endif
40 
41