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 ResourceType resourceType() const { return fKey[kTypeAndSize_MetaDataIdx] &
0xffff; } | 40 ResourceType resourceType() const { return fKey[kTypeAndSize_MetaDataIdx] &
0xffff; } |
41 | 41 |
42 uint32_t hash() const { return fKey[kHash_MetaDataIdx]; } | 42 uint32_t hash() const { return fKey[kHash_MetaDataIdx]; } |
43 | 43 |
44 size_t size() const { return SkToInt(fKey[kTypeAndSize_MetaDataIdx] >> 16);
} | 44 size_t size() const { return SkToInt(fKey[kTypeAndSize_MetaDataIdx] >> 16);
} |
45 | 45 |
46 const uint32_t* data() const { return &fKey[kMetaDataCnt]; } | 46 const uint32_t* data() const { return &fKey[kMetaDataCnt]; } |
47 | 47 |
48 GrScratchKey& operator=(const GrScratchKey& that) { | 48 GrScratchKey& operator=(const GrScratchKey& that) { |
49 size_t size = that.size(); | 49 size_t bytes = that.size(); |
50 fKey.reset(SkToInt(size)); | 50 fKey.reset(SkToInt(bytes / sizeof(uint32_t))); |
51 memcpy(fKey.get(), that.fKey.get(), size); | 51 memcpy(fKey.get(), that.fKey.get(), bytes); |
52 return *this; | 52 return *this; |
53 } | 53 } |
54 | 54 |
55 bool operator==(const GrScratchKey& that) const { | 55 bool operator==(const GrScratchKey& that) const { |
56 return 0 == memcmp(fKey.get(), that.fKey.get(), this->size()); | 56 return 0 == memcmp(fKey.get(), that.fKey.get(), this->size()); |
57 } | 57 } |
58 bool operator!=(const GrScratchKey& that) const { return !(*this == that); } | 58 bool operator!=(const GrScratchKey& that) const { return !(*this == that); } |
59 | 59 |
60 /** Used to initialize scratch key. */ | 60 /** Used to initialize scratch key. */ |
61 class Builder { | 61 class Builder { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 memcpy(k + kCacheIDKeyOffset, key.fData8, sizeof(GrCacheID::Key)); | 150 memcpy(k + kCacheIDKeyOffset, key.fData8, sizeof(GrCacheID::Key)); |
151 memcpy(k + kCacheIDDomainOffset, &domain, sizeof(GrCacheID::Domain)); | 151 memcpy(k + kCacheIDDomainOffset, &domain, sizeof(GrCacheID::Domain)); |
152 memcpy(k + kResourceFlagsOffset, &flags, sizeof(ResourceFlags)); | 152 memcpy(k + kResourceFlagsOffset, &flags, sizeof(ResourceFlags)); |
153 memset(k + kPadOffset, 0, kPadSize); | 153 memset(k + kPadOffset, 0, kPadSize); |
154 fKey.setKeyData(keyData.fKey32); | 154 fKey.setKeyData(keyData.fKey32); |
155 } | 155 } |
156 GrBinHashKey<kKeySize> fKey; | 156 GrBinHashKey<kKeySize> fKey; |
157 }; | 157 }; |
158 | 158 |
159 #endif | 159 #endif |
OLD | NEW |