| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2014 Google Inc. | 3 * Copyright 2014 Google Inc. |
| 4 * | 4 * |
| 5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
| 6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #ifndef GrResourceKey_DEFINED | 9 #ifndef GrResourceKey_DEFINED |
| 10 #define GrResourceKey_DEFINED | 10 #define GrResourceKey_DEFINED |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 /** Reset to an invalid key. */ | 40 /** Reset to an invalid key. */ |
| 41 void reset() { | 41 void reset() { |
| 42 GR_STATIC_ASSERT((uint16_t)kInvalidDomain == kInvalidDomain); | 42 GR_STATIC_ASSERT((uint16_t)kInvalidDomain == kInvalidDomain); |
| 43 fKey.reset(kMetaDataCnt); | 43 fKey.reset(kMetaDataCnt); |
| 44 fKey[kHash_MetaDataIdx] = 0; | 44 fKey[kHash_MetaDataIdx] = 0; |
| 45 fKey[kDomainAndSize_MetaDataIdx] = kInvalidDomain; | 45 fKey[kDomainAndSize_MetaDataIdx] = kInvalidDomain; |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool operator==(const GrResourceKey& that) const { | 48 bool operator==(const GrResourceKey& that) const { |
| 49 return 0 == memcmp(fKey.get(), that.fKey.get(), this->size()); | 49 return this->hash() == that.hash() && |
| 50 0 == memcmp(&fKey[kHash_MetaDataIdx + 1], |
| 51 &that.fKey[kHash_MetaDataIdx + 1], |
| 52 this->internalSize() - sizeof(uint32_t)); |
| 50 } | 53 } |
| 51 | 54 |
| 52 GrResourceKey& operator=(const GrResourceKey& that) { | 55 GrResourceKey& operator=(const GrResourceKey& that) { |
| 53 SkASSERT(that.isValid()); | 56 SkASSERT(that.isValid()); |
| 54 if (this != &that) { | 57 if (this != &that) { |
| 55 size_t bytes = that.size(); | 58 size_t bytes = that.size(); |
| 56 SkASSERT(SkIsAlign4(bytes)); | 59 SkASSERT(SkIsAlign4(bytes)); |
| 57 fKey.reset(SkToInt(bytes / sizeof(uint32_t))); | 60 fKey.reset(SkToInt(bytes / sizeof(uint32_t))); |
| 58 memcpy(fKey.get(), that.fKey.get(), bytes); | 61 memcpy(fKey.get(), that.fKey.get(), bytes); |
| 59 this->validate(); | 62 this->validate(); |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 fKey = that.fKey; | 299 fKey = that.fKey; |
| 297 return *this; | 300 return *this; |
| 298 } | 301 } |
| 299 | 302 |
| 300 const GrUniqueKey& key() const { return fKey; } | 303 const GrUniqueKey& key() const { return fKey; } |
| 301 | 304 |
| 302 private: | 305 private: |
| 303 GrUniqueKey fKey; | 306 GrUniqueKey fKey; |
| 304 }; | 307 }; |
| 305 #endif | 308 #endif |
| OLD | NEW |