OLD | NEW |
1 | |
2 /* | 1 /* |
3 * Copyright 2010 Google Inc. | 2 * Copyright 2010 Google Inc. |
4 * | 3 * |
5 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 5 * found in the LICENSE file. |
7 */ | 6 */ |
8 | 7 |
9 | |
10 | |
11 #ifndef GrKey_DEFINED | 8 #ifndef GrKey_DEFINED |
12 #define GrKey_DEFINED | 9 #define GrKey_DEFINED |
13 | 10 |
14 #include "GrRefCnt.h" | 11 class GrKey : public SkRefCnt { |
15 | |
16 class GrKey : public GrRefCnt { | |
17 public: | 12 public: |
18 SK_DECLARE_INST_COUNT(GrKey) | 13 SK_DECLARE_INST_COUNT(GrKey) |
19 | 14 |
20 typedef intptr_t Hash; | 15 typedef intptr_t Hash; |
21 | 16 |
22 explicit GrKey(Hash hash) : fHash(hash) {} | 17 explicit GrKey(Hash hash) : fHash(hash) {} |
23 | 18 |
24 intptr_t getHash() const { return fHash; } | 19 intptr_t getHash() const { return fHash; } |
25 | 20 |
26 bool operator<(const GrKey& rh) const { | 21 bool operator<(const GrKey& rh) const { |
27 return fHash < rh.fHash || (fHash == rh.fHash && this->lt(rh)); | 22 return fHash < rh.fHash || (fHash == rh.fHash && this->lt(rh)); |
28 } | 23 } |
29 bool operator==(const GrKey& rh) const { | 24 bool operator==(const GrKey& rh) const { |
30 return fHash == rh.fHash && this->eq(rh); | 25 return fHash == rh.fHash && this->eq(rh); |
31 } | 26 } |
32 | 27 |
33 protected: | 28 protected: |
34 virtual bool lt(const GrKey& rh) const = 0; | 29 virtual bool lt(const GrKey& rh) const = 0; |
35 virtual bool eq(const GrKey& rh) const = 0; | 30 virtual bool eq(const GrKey& rh) const = 0; |
36 | 31 |
37 private: | 32 private: |
38 const Hash fHash; | 33 const Hash fHash; |
39 | 34 |
40 typedef GrRefCnt INHERITED; | 35 typedef SkRefCnt INHERITED; |
41 }; | 36 }; |
42 | 37 |
43 #endif | 38 #endif |
OLD | NEW |