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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // private so no one can create one except our factories | 129 // private so no one can create one except our factories |
130 SkDescriptor() {} | 130 SkDescriptor() {} |
131 }; | 131 }; |
132 | 132 |
133 #include "SkScalerContext.h" | 133 #include "SkScalerContext.h" |
134 | 134 |
135 class SkAutoDescriptor : SkNoncopyable { | 135 class SkAutoDescriptor : SkNoncopyable { |
136 public: | 136 public: |
137 SkAutoDescriptor() : fDesc(NULL) {} | 137 SkAutoDescriptor() : fDesc(NULL) {} |
138 SkAutoDescriptor(size_t size) : fDesc(NULL) { this->reset(size); } | 138 SkAutoDescriptor(size_t size) : fDesc(NULL) { this->reset(size); } |
| 139 SkAutoDescriptor(const SkDescriptor& desc) : fDesc(NULL) { |
| 140 size_t size = desc.getLength(); |
| 141 this->reset(size); |
| 142 memcpy(fDesc, &desc, size); |
| 143 } |
139 | 144 |
140 ~SkAutoDescriptor() { this->free(); } | 145 ~SkAutoDescriptor() { this->free(); } |
141 | 146 |
142 void reset(size_t size) { | 147 void reset(size_t size) { |
143 this->free(); | 148 this->free(); |
144 if (size <= sizeof(fStorage)) { | 149 if (size <= sizeof(fStorage)) { |
145 fDesc = (SkDescriptor*)(void*)fStorage; | 150 fDesc = (SkDescriptor*)(void*)fStorage; |
146 } else { | 151 } else { |
147 fDesc = SkDescriptor::Alloc(size); | 152 fDesc = SkDescriptor::Alloc(size); |
148 } | 153 } |
(...skipping 13 matching lines...) Expand all Loading... |
162 + sizeof(SkDescriptor::Entry) + sizeof(void*)
// for typeface | 167 + sizeof(SkDescriptor::Entry) + sizeof(void*)
// for typeface |
163 + 32 // slop for occational small extras | 168 + 32 // slop for occational small extras |
164 }; | 169 }; |
165 SkDescriptor* fDesc; | 170 SkDescriptor* fDesc; |
166 uint32_t fStorage[(kStorageSize + 3) >> 2]; | 171 uint32_t fStorage[(kStorageSize + 3) >> 2]; |
167 }; | 172 }; |
168 #define SkAutoDescriptor(...) SK_REQUIRE_LOCAL_VAR(SkAutoDescriptor) | 173 #define SkAutoDescriptor(...) SK_REQUIRE_LOCAL_VAR(SkAutoDescriptor) |
169 | 174 |
170 | 175 |
171 #endif | 176 #endif |
OLD | NEW |