| 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 "SkFontDescriptor.h" | 9 #include "SkFontDescriptor.h" |
| 10 #include "SkFontHost.h" | 10 #include "SkFontHost.h" |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 } | 240 } |
| 241 | 241 |
| 242 return SkFontHost::CreateTypeface(NULL, familyName, style); | 242 return SkFontHost::CreateTypeface(NULL, familyName, style); |
| 243 } | 243 } |
| 244 | 244 |
| 245 /////////////////////////////////////////////////////////////////////////////// | 245 /////////////////////////////////////////////////////////////////////////////// |
| 246 | 246 |
| 247 static SkStream* open_stream(const FontConfigTypeface* face, int* ttcIndex) { | 247 static SkStream* open_stream(const FontConfigTypeface* face, int* ttcIndex) { |
| 248 SkStream* stream = face->getLocalStream(); | 248 SkStream* stream = face->getLocalStream(); |
| 249 if (stream) { | 249 if (stream) { |
| 250 // TODO: fix issue 1176. |
| 251 // As of now open_stream will return a stream and unwind it, but the |
| 252 // SkStream is not thread safe, and if two threads use the stream they |
| 253 // may collide and print preview for example could still fail, |
| 254 // or there could be some failures in rendering if this stream is used |
| 255 // there. |
| 256 stream->rewind(); |
| 250 stream->ref(); | 257 stream->ref(); |
| 251 // should have been provided by CreateFromStream() | 258 // should have been provided by CreateFromStream() |
| 252 *ttcIndex = 0; | 259 *ttcIndex = 0; |
| 253 } else { | 260 } else { |
| 254 SkAutoTUnref<SkFontConfigInterface> fci(RefFCI()); | 261 SkAutoTUnref<SkFontConfigInterface> fci(RefFCI()); |
| 255 if (NULL == fci.get()) { | 262 if (NULL == fci.get()) { |
| 256 return NULL; | 263 return NULL; |
| 257 } | 264 } |
| 258 stream = fci->openStream(face->getIdentity()); | 265 stream = fci->openStream(face->getIdentity()); |
| 259 *ttcIndex = face->getIdentity().fTTCIndex; | 266 *ttcIndex = face->getIdentity().fTTCIndex; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 return stream.get() | 316 return stream.get() |
| 310 ? SkFontStream::GetTableData(stream, ttcIndex, | 317 ? SkFontStream::GetTableData(stream, ttcIndex, |
| 311 tag, offset, length, data) | 318 tag, offset, length, data) |
| 312 : 0; | 319 : 0; |
| 313 } | 320 } |
| 314 | 321 |
| 315 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc) const { | 322 void FontConfigTypeface::onGetFontDescriptor(SkFontDescriptor* desc) const { |
| 316 desc->setStyle(this->style()); | 323 desc->setStyle(this->style()); |
| 317 desc->setFamilyName(this->getFamilyName()); | 324 desc->setFamilyName(this->getFamilyName()); |
| 318 } | 325 } |
| OLD | NEW |