| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 size_t length = stream->getLength(); | 147 size_t length = stream->getLength(); |
| 148 | 148 |
| 149 const void* memory = stream->getMemoryBase(); | 149 const void* memory = stream->getMemoryBase(); |
| 150 if (NULL != memory) { | 150 if (NULL != memory) { |
| 151 return new SkMemoryStream(memory, length, true); | 151 return new SkMemoryStream(memory, length, true); |
| 152 } | 152 } |
| 153 | 153 |
| 154 SkAutoTMalloc<uint8_t> allocMemory(length); | 154 SkAutoTMalloc<uint8_t> allocMemory(length); |
| 155 stream->rewind(); | 155 stream->rewind(); |
| 156 if (length == stream->read(allocMemory.get(), length)) { | 156 if (length == stream->read(allocMemory.get(), length)) { |
| 157 return new SkMemoryStream(allocMemory.detach(), length); | 157 SkAutoTUnref<SkMemoryStream> copyStream(new SkMemoryStream()); |
| 158 copyStream->setMemoryOwned(allocMemory.detach(), length); |
| 159 return copyStream.detach(); |
| 158 } | 160 } |
| 159 | 161 |
| 160 stream->rewind(); | 162 stream->rewind(); |
| 161 stream->ref(); | 163 stream->ref(); |
| 162 } else { | 164 } else { |
| 163 SkAutoTUnref<SkFontConfigInterface> fci(RefFCI()); | 165 SkAutoTUnref<SkFontConfigInterface> fci(RefFCI()); |
| 164 if (NULL == fci.get()) { | 166 if (NULL == fci.get()) { |
| 165 return NULL; | 167 return NULL; |
| 166 } | 168 } |
| 167 stream = fci->openStream(this->getIdentity()); | 169 stream = fci->openStream(this->getIdentity()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 188 : 0; | 190 : 0; |
| 189 } | 191 } |
| 190 | 192 |
| 191 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc, | 193 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc, |
| 192 bool* isLocalStream) const { | 194 bool* isLocalStream) const { |
| 193 desc->setFamilyName(this->getFamilyName()); | 195 desc->setFamilyName(this->getFamilyName()); |
| 194 *isLocalStream = SkToBool(this->getLocalStream()); | 196 *isLocalStream = SkToBool(this->getLocalStream()); |
| 195 } | 197 } |
| 196 | 198 |
| 197 /////////////////////////////////////////////////////////////////////////////// | 199 /////////////////////////////////////////////////////////////////////////////// |
| OLD | NEW |