OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 The Android Open Source Project |
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 | 9 |
10 #ifndef SkDescriptor_DEFINED | 10 #ifndef SkDescriptor_DEFINED |
(...skipping 24 matching lines...) Expand all Loading... |
35 fCount = 0; | 35 fCount = 0; |
36 } | 36 } |
37 | 37 |
38 uint32_t getLength() const { return fLength; } | 38 uint32_t getLength() const { return fLength; } |
39 | 39 |
40 void* addEntry(uint32_t tag, size_t length, const void* data = NULL) { | 40 void* addEntry(uint32_t tag, size_t length, const void* data = NULL) { |
41 SkASSERT(tag); | 41 SkASSERT(tag); |
42 SkASSERT(SkAlign4(length) == length); | 42 SkASSERT(SkAlign4(length) == length); |
43 SkASSERT(this->findEntry(tag, NULL) == NULL); | 43 SkASSERT(this->findEntry(tag, NULL) == NULL); |
44 | 44 |
45 Entry* entry = (Entry*)((char*)this + fLength); | 45 Entry* entry = (Entry*)((char*)this + fLength); |
46 entry->fTag = tag; | 46 entry->fTag = tag; |
47 entry->fLen = SkToU32(length); | 47 entry->fLen = SkToU32(length); |
48 if (data) { | 48 if (data) { |
49 memcpy(entry + 1, data, length); | 49 memcpy(entry + 1, data, length); |
50 } | 50 } |
51 | 51 |
52 fCount += 1; | 52 fCount += 1; |
53 fLength += sizeof(Entry) + length; | 53 fLength = SkToU32(fLength + sizeof(Entry) + length); |
54 return (entry + 1); // return its data | 54 return (entry + 1); // return its data |
55 } | 55 } |
56 | 56 |
57 void computeChecksum() { | 57 void computeChecksum() { |
58 fChecksum = SkDescriptor::ComputeChecksum(this); | 58 fChecksum = SkDescriptor::ComputeChecksum(this); |
59 } | 59 } |
60 | 60 |
61 #ifdef SK_DEBUG | 61 #ifdef SK_DEBUG |
62 void assertChecksum() const { | 62 void assertChecksum() const { |
63 SkASSERT(SkDescriptor::ComputeChecksum(this) == fChecksum); | 63 SkASSERT(SkDescriptor::ComputeChecksum(this) == fChecksum); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 + sizeof(SkDescriptor::Entry) + sizeof(void*)
// for typeface | 156 + sizeof(SkDescriptor::Entry) + sizeof(void*)
// for typeface |
157 + 32 // slop for occational small extras | 157 + 32 // slop for occational small extras |
158 }; | 158 }; |
159 SkDescriptor* fDesc; | 159 SkDescriptor* fDesc; |
160 uint32_t fStorage[(kStorageSize + 3) >> 2]; | 160 uint32_t fStorage[(kStorageSize + 3) >> 2]; |
161 }; | 161 }; |
162 #define SkAutoDescriptor(...) SK_REQUIRE_LOCAL_VAR(SkAutoDescriptor) | 162 #define SkAutoDescriptor(...) SK_REQUIRE_LOCAL_VAR(SkAutoDescriptor) |
163 | 163 |
164 | 164 |
165 #endif | 165 #endif |
OLD | NEW |