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 27 matching lines...) Expand all Loading... |
38 | 38 |
39 /** Reset to an invalid key. */ | 39 /** Reset to an invalid key. */ |
40 void reset() { | 40 void reset() { |
41 GR_STATIC_ASSERT((uint16_t)kInvalidDomain == kInvalidDomain); | 41 GR_STATIC_ASSERT((uint16_t)kInvalidDomain == kInvalidDomain); |
42 fKey.reset(kMetaDataCnt); | 42 fKey.reset(kMetaDataCnt); |
43 fKey[kHash_MetaDataIdx] = 0; | 43 fKey[kHash_MetaDataIdx] = 0; |
44 fKey[kDomainAndSize_MetaDataIdx] = kInvalidDomain; | 44 fKey[kDomainAndSize_MetaDataIdx] = kInvalidDomain; |
45 } | 45 } |
46 | 46 |
47 bool operator==(const GrResourceKey& that) const { | 47 bool operator==(const GrResourceKey& that) const { |
| 48 SkASSERT(this->isValid() && that.isValid()); |
48 return 0 == memcmp(fKey.get(), that.fKey.get(), this->size()); | 49 return 0 == memcmp(fKey.get(), that.fKey.get(), this->size()); |
49 } | 50 } |
50 | 51 |
51 GrResourceKey& operator=(const GrResourceKey& that) { | 52 GrResourceKey& operator=(const GrResourceKey& that) { |
52 if (this != &that) { | 53 if (this != &that) { |
53 size_t bytes = that.size(); | 54 size_t bytes = that.size(); |
54 SkASSERT(SkIsAlign4(bytes)); | 55 SkASSERT(SkIsAlign4(bytes)); |
55 fKey.reset(SkToInt(bytes / sizeof(uint32_t))); | 56 fKey.reset(SkToInt(bytes / sizeof(uint32_t))); |
56 memcpy(fKey.get(), that.fKey.get(), bytes); | 57 memcpy(fKey.get(), that.fKey.get(), bytes); |
57 } | 58 } |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 int innerKeyCnt = SkToInt(innerKey.size()) >> 2; | 217 int innerKeyCnt = SkToInt(innerKey.size()) >> 2; |
217 // add the inner key to the end of the key so that op[] can be index
ed normally. | 218 // add the inner key to the end of the key so that op[] can be index
ed normally. |
218 for (int i = 0; i < innerKeyCnt; ++i) { | 219 for (int i = 0; i < innerKeyCnt; ++i) { |
219 this->operator[](extraData32Cnt + i) = innerKey.data()[i]; | 220 this->operator[](extraData32Cnt + i) = innerKey.data()[i]; |
220 } | 221 } |
221 } | 222 } |
222 }; | 223 }; |
223 }; | 224 }; |
224 | 225 |
225 #endif | 226 #endif |
OLD | NEW |