OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrProgramDesc_DEFINED | 8 #ifndef GrProgramDesc_DEFINED |
9 #define GrProgramDesc_DEFINED | 9 #define GrProgramDesc_DEFINED |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 // Gets the number of bytes in asKey(). It will be a 4-byte aligned value. W
hen comparing two | 29 // Gets the number of bytes in asKey(). It will be a 4-byte aligned value. W
hen comparing two |
30 // keys the size of either key can be used with memcmp() since the lengths t
hemselves begin the | 30 // keys the size of either key can be used with memcmp() since the lengths t
hemselves begin the |
31 // keys and thus the memcmp will exit early if the keys are of different len
gths. | 31 // keys and thus the memcmp will exit early if the keys are of different len
gths. |
32 uint32_t keyLength() const { return *this->atOffset<uint32_t, kLengthOffset>
(); } | 32 uint32_t keyLength() const { return *this->atOffset<uint32_t, kLengthOffset>
(); } |
33 | 33 |
34 // Gets the a checksum of the key. Can be used as a hash value for a fast lo
okup in a cache. | 34 // Gets the a checksum of the key. Can be used as a hash value for a fast lo
okup in a cache. |
35 uint32_t getChecksum() const { return *this->atOffset<uint32_t, kChecksumOff
set>(); } | 35 uint32_t getChecksum() const { return *this->atOffset<uint32_t, kChecksumOff
set>(); } |
36 | 36 |
37 GrProgramDesc& operator= (const GrProgramDesc& other) { | 37 GrProgramDesc& operator= (const GrProgramDesc& other) { |
38 size_t keyLength = other.keyLength(); | 38 uint32_t keyLength = other.keyLength(); |
39 fKey.reset(keyLength); | 39 fKey.reset(keyLength); |
40 memcpy(fKey.begin(), other.fKey.begin(), keyLength); | 40 memcpy(fKey.begin(), other.fKey.begin(), keyLength); |
41 return *this; | 41 return *this; |
42 } | 42 } |
43 | 43 |
44 bool operator== (const GrProgramDesc& other) const { | 44 bool operator== (const GrProgramDesc& other) const { |
45 // The length is masked as a hint to the compiler that the address will
be 4 byte aligned. | 45 // The length is masked as a hint to the compiler that the address will
be 4 byte aligned. |
46 return 0 == memcmp(this->asKey(), other.asKey(), this->keyLength() & ~0x
3); | 46 return 0 == memcmp(this->asKey(), other.asKey(), this->keyLength() & ~0x
3); |
47 } | 47 } |
48 | 48 |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 kPreAllocSize = kHeaderOffset + kHeaderSize + | 207 kPreAllocSize = kHeaderOffset + kHeaderSize + |
208 kMaxPreallocProcessors * sizeof(uint32_t) * kIntsPerProc
essor, | 208 kMaxPreallocProcessors * sizeof(uint32_t) * kIntsPerProc
essor, |
209 }; | 209 }; |
210 | 210 |
211 SkSTArray<kPreAllocSize, uint8_t, true> fKey; | 211 SkSTArray<kPreAllocSize, uint8_t, true> fKey; |
212 | 212 |
213 friend class GrGLProgramDescBuilder; | 213 friend class GrGLProgramDescBuilder; |
214 }; | 214 }; |
215 | 215 |
216 #endif | 216 #endif |
OLD | NEW |