OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
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 | 8 |
9 #ifndef SkDescriptor_DEFINED | 9 #ifndef SkDescriptor_DEFINED |
10 #define SkDescriptor_DEFINED | 10 #define SkDescriptor_DEFINED |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 } | 78 } |
79 return nullptr; | 79 return nullptr; |
80 } | 80 } |
81 | 81 |
82 SkDescriptor* copy() const { | 82 SkDescriptor* copy() const { |
83 SkDescriptor* desc = SkDescriptor::Alloc(fLength); | 83 SkDescriptor* desc = SkDescriptor::Alloc(fLength); |
84 memcpy(desc, this, fLength); | 84 memcpy(desc, this, fLength); |
85 return desc; | 85 return desc; |
86 } | 86 } |
87 | 87 |
88 bool equals(const SkDescriptor& other) const { | 88 bool operator==(const SkDescriptor& other) const { |
89 // probe to see if we have a good checksum algo | 89 // probe to see if we have a good checksum algo |
90 // SkASSERT(a.fChecksum != b.fChecksum || memcmp(&a, &b, a.fLength) == 0)
; | 90 // SkASSERT(a.fChecksum != b.fChecksum || memcmp(&a, &b, a.fLength) == 0)
; |
91 | 91 |
92 // the first value we should look at is the checksum, so this loop | 92 // the first value we should look at is the checksum, so this loop |
93 // should terminate early if they descriptors are different. | 93 // should terminate early if they descriptors are different. |
94 // NOTE: if we wrote a sentinel value at the end of each, we chould | 94 // NOTE: if we wrote a sentinel value at the end of each, we chould |
95 // remove the aa < stop test in the loop... | 95 // remove the aa < stop test in the loop... |
96 const uint32_t* aa = (const uint32_t*)this; | 96 const uint32_t* aa = (const uint32_t*)this; |
97 const uint32_t* bb = (const uint32_t*)&other; | 97 const uint32_t* bb = (const uint32_t*)&other; |
98 const uint32_t* stop = (const uint32_t*)((const char*)aa + fLength); | 98 const uint32_t* stop = (const uint32_t*)((const char*)aa + fLength); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 + sizeof(SkDescriptor::Entry) + sizeof(void*)
// for typeface | 166 + sizeof(SkDescriptor::Entry) + sizeof(void*)
// for typeface |
167 + 32 // slop for occational small extras | 167 + 32 // slop for occational small extras |
168 }; | 168 }; |
169 SkDescriptor* fDesc; | 169 SkDescriptor* fDesc; |
170 uint32_t fStorage[(kStorageSize + 3) >> 2]; | 170 uint32_t fStorage[(kStorageSize + 3) >> 2]; |
171 }; | 171 }; |
172 #define SkAutoDescriptor(...) SK_REQUIRE_LOCAL_VAR(SkAutoDescriptor) | 172 #define SkAutoDescriptor(...) SK_REQUIRE_LOCAL_VAR(SkAutoDescriptor) |
173 | 173 |
174 | 174 |
175 #endif | 175 #endif |
OLD | NEW |