michael@0: /* michael@0: * Copyright 2010 Google Inc. michael@0: * michael@0: * Use of this source code is governed by a BSD-style license that can be michael@0: * found in the LICENSE file. michael@0: */ michael@0: michael@0: #ifndef GrKey_DEFINED michael@0: #define GrKey_DEFINED michael@0: michael@0: class GrKey : public SkRefCnt { michael@0: public: michael@0: SK_DECLARE_INST_COUNT(GrKey) michael@0: michael@0: typedef intptr_t Hash; michael@0: michael@0: explicit GrKey(Hash hash) : fHash(hash) {} michael@0: michael@0: intptr_t getHash() const { return fHash; } michael@0: michael@0: bool operator<(const GrKey& rh) const { michael@0: return fHash < rh.fHash || (fHash == rh.fHash && this->lt(rh)); michael@0: } michael@0: bool operator==(const GrKey& rh) const { michael@0: return fHash == rh.fHash && this->eq(rh); michael@0: } michael@0: michael@0: protected: michael@0: virtual bool lt(const GrKey& rh) const = 0; michael@0: virtual bool eq(const GrKey& rh) const = 0; michael@0: michael@0: private: michael@0: const Hash fHash; michael@0: michael@0: typedef SkRefCnt INHERITED; michael@0: }; michael@0: michael@0: #endif