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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 213 |
214 class Builder : public INHERITED::Builder { | 214 class Builder : public INHERITED::Builder { |
215 public: | 215 public: |
216 Builder(GrContentKey* key, Domain domain, int data32Count) | 216 Builder(GrContentKey* key, Domain domain, int data32Count) |
217 : INHERITED::Builder(key, domain, data32Count) {} | 217 : INHERITED::Builder(key, domain, data32Count) {} |
218 | 218 |
219 /** Used to build a key that wraps another key and adds additional data.
*/ | 219 /** Used to build a key that wraps another key and adds additional data.
*/ |
220 Builder(GrContentKey* key, const GrContentKey& innerKey, Domain domain, | 220 Builder(GrContentKey* key, const GrContentKey& innerKey, Domain domain, |
221 int extraData32Cnt) | 221 int extraData32Cnt) |
222 : INHERITED::Builder(key, domain, Data32CntForInnerKey(innerKey) + e
xtraData32Cnt) { | 222 : INHERITED::Builder(key, domain, Data32CntForInnerKey(innerKey) + e
xtraData32Cnt) { |
223 SkASSERT(&innerKey != key); | |
224 // add the inner key to the end of the key so that op[] can be index
ed normally. | 223 // add the inner key to the end of the key so that op[] can be index
ed normally. |
225 uint32_t* innerKeyData = &this->operator[](extraData32Cnt); | 224 uint32_t* innerKeyData = &this->operator[](extraData32Cnt); |
226 const uint32_t* srcData = innerKey.data(); | 225 const uint32_t* srcData = innerKey.data(); |
227 (*innerKeyData++) = innerKey.domain(); | 226 (*innerKeyData++) = innerKey.domain(); |
228 memcpy(innerKeyData, srcData, innerKey.dataSize()); | 227 memcpy(innerKeyData, srcData, innerKey.dataSize()); |
229 } | 228 } |
230 | 229 |
231 private: | 230 private: |
232 static int Data32CntForInnerKey(const GrContentKey& innerKey) { | 231 static int Data32CntForInnerKey(const GrContentKey& innerKey) { |
233 // key data + domain | 232 // key data + domain |
234 return SkToInt((innerKey.dataSize() >> 2) + 1); | 233 return SkToInt((innerKey.dataSize() >> 2) + 1); |
235 } | 234 } |
236 }; | 235 }; |
237 }; | 236 }; |
238 | 237 |
239 #endif | 238 #endif |
OLD | NEW |