OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 Google Inc. | 2 * Copyright 2008 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 #include "SkFontConfigInterface.h" | 8 #include "SkFontConfigInterface.h" |
9 #include "SkFontConfigTypeface.h" | 9 #include "SkFontConfigTypeface.h" |
10 #include "SkFontDescriptor.h" | 10 #include "SkFontDescriptor.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 | 130 |
131 SkAutoTUnref<SkStream> dupStream(stream->duplicate()); | 131 SkAutoTUnref<SkStream> dupStream(stream->duplicate()); |
132 if (dupStream) { | 132 if (dupStream) { |
133 return dupStream.detach(); | 133 return dupStream.detach(); |
134 } | 134 } |
135 | 135 |
136 // TODO: update interface use, remove the following code in this block. | 136 // TODO: update interface use, remove the following code in this block. |
137 size_t length = stream->getLength(); | 137 size_t length = stream->getLength(); |
138 | 138 |
139 const void* memory = stream->getMemoryBase(); | 139 const void* memory = stream->getMemoryBase(); |
140 if (NULL != memory) { | 140 if (memory) { |
141 return new SkMemoryStream(memory, length, true); | 141 return new SkMemoryStream(memory, length, true); |
142 } | 142 } |
143 | 143 |
144 SkAutoTMalloc<uint8_t> allocMemory(length); | 144 SkAutoTMalloc<uint8_t> allocMemory(length); |
145 stream->rewind(); | 145 stream->rewind(); |
146 if (length == stream->read(allocMemory.get(), length)) { | 146 if (length == stream->read(allocMemory.get(), length)) { |
147 SkAutoTUnref<SkMemoryStream> copyStream(new SkMemoryStream()); | 147 SkAutoTUnref<SkMemoryStream> copyStream(new SkMemoryStream()); |
148 copyStream->setMemoryOwned(allocMemory.detach(), length); | 148 copyStream->setMemoryOwned(allocMemory.detach(), length); |
149 return copyStream.detach(); | 149 return copyStream.detach(); |
150 } | 150 } |
151 | 151 |
152 stream->rewind(); | 152 stream->rewind(); |
153 stream->ref(); | 153 stream->ref(); |
154 } else { | 154 } else { |
155 SkAutoTUnref<SkFontConfigInterface> fci(RefFCI()); | 155 SkAutoTUnref<SkFontConfigInterface> fci(RefFCI()); |
156 if (NULL == fci.get()) { | 156 if (NULL == fci.get()) { |
157 return NULL; | 157 return NULL; |
158 } | 158 } |
159 stream = fci->openStream(this->getIdentity()); | 159 stream = fci->openStream(this->getIdentity()); |
160 *ttcIndex = this->getIdentity().fTTCIndex; | 160 *ttcIndex = this->getIdentity().fTTCIndex; |
161 } | 161 } |
162 return stream; | 162 return stream; |
163 } | 163 } |
164 | 164 |
165 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc, | 165 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc, |
166 bool* isLocalStream) const { | 166 bool* isLocalStream) const { |
167 desc->setFamilyName(this->getFamilyName()); | 167 desc->setFamilyName(this->getFamilyName()); |
168 *isLocalStream = SkToBool(this->getLocalStream()); | 168 *isLocalStream = SkToBool(this->getLocalStream()); |
169 } | 169 } |
OLD | NEW |