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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 return 0 == memcmp(fKey.get(), that.fKey.get(), this->size()); | 48 return 0 == memcmp(fKey.get(), that.fKey.get(), this->size()); |
49 } | 49 } |
50 | 50 |
51 GrResourceKey& operator=(const GrResourceKey& that) { | 51 GrResourceKey& operator=(const GrResourceKey& that) { |
52 size_t bytes = that.size(); | 52 if (this != &that) { |
53 SkASSERT(SkIsAlign4(bytes)); | 53 size_t bytes = that.size(); |
54 fKey.reset(SkToInt(bytes / sizeof(uint32_t))); | 54 SkASSERT(SkIsAlign4(bytes)); |
55 memcpy(fKey.get(), that.fKey.get(), bytes); | 55 fKey.reset(SkToInt(bytes / sizeof(uint32_t))); |
| 56 memcpy(fKey.get(), that.fKey.get(), bytes); |
| 57 } |
56 return *this; | 58 return *this; |
57 } | 59 } |
58 | 60 |
59 bool isValid() const { return kInvalidDomain != this->domain(); } | 61 bool isValid() const { return kInvalidDomain != this->domain(); } |
60 | 62 |
61 uint32_t domain() const { return fKey[kDomainAndSize_MetaDataIdx] & 0xffff;
} | 63 uint32_t domain() const { return fKey[kDomainAndSize_MetaDataIdx] & 0xffff;
} |
62 | 64 |
63 /** Used to initialize a key. */ | 65 /** Used to initialize a key. */ |
64 class Builder { | 66 class Builder { |
65 public: | 67 public: |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 int innerKeyCnt = SkToInt(innerKey.size()) >> 2; | 216 int innerKeyCnt = SkToInt(innerKey.size()) >> 2; |
215 // add the inner key to the end of the key so that op[] can be index
ed normally. | 217 // add the inner key to the end of the key so that op[] can be index
ed normally. |
216 for (int i = 0; i < innerKeyCnt; ++i) { | 218 for (int i = 0; i < innerKeyCnt; ++i) { |
217 this->operator[](extraData32Cnt + i) = innerKey.data()[i]; | 219 this->operator[](extraData32Cnt + i) = innerKey.data()[i]; |
218 } | 220 } |
219 } | 221 } |
220 }; | 222 }; |
221 }; | 223 }; |
222 | 224 |
223 #endif | 225 #endif |
OLD | NEW |