| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 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 "SkDWrite.h" | 8 #include "SkDWrite.h" |
| 9 #include "SkDWriteFontFileStream.h" | 9 #include "SkDWriteFontFileStream.h" |
| 10 #include "SkFontMgr.h" | 10 #include "SkFontMgr.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 IDWriteFontFileStream** fontFileStream); | 35 IDWriteFontFileStream** fontFileStream); |
| 36 | 36 |
| 37 static HRESULT Create(SkStream* stream, StreamFontFileLoader** streamFontFil
eLoader) { | 37 static HRESULT Create(SkStream* stream, StreamFontFileLoader** streamFontFil
eLoader) { |
| 38 *streamFontFileLoader = new StreamFontFileLoader(stream); | 38 *streamFontFileLoader = new StreamFontFileLoader(stream); |
| 39 if (NULL == streamFontFileLoader) { | 39 if (NULL == streamFontFileLoader) { |
| 40 return E_OUTOFMEMORY; | 40 return E_OUTOFMEMORY; |
| 41 } | 41 } |
| 42 return S_OK; | 42 return S_OK; |
| 43 } | 43 } |
| 44 | 44 |
| 45 SkAutoTUnref<SkStream> fStream; | 45 SkAutoTDelete<SkStream> fStream; |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 StreamFontFileLoader(SkStream* stream) : fRefCount(1), fStream(SkRef(stream)
) { } | 48 StreamFontFileLoader(SkStream* stream) : fRefCount(1), fStream(stream) { } |
| 49 virtual ~StreamFontFileLoader() { } | 49 virtual ~StreamFontFileLoader() { } |
| 50 | 50 |
| 51 ULONG fRefCount; | 51 ULONG fRefCount; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 HRESULT StreamFontFileLoader::QueryInterface(REFIID iid, void** ppvObject) { | 54 HRESULT StreamFontFileLoader::QueryInterface(REFIID iid, void** ppvObject) { |
| 55 if (iid == IID_IUnknown || iid == __uuidof(IDWriteFontFileLoader)) { | 55 if (iid == IID_IUnknown || iid == __uuidof(IDWriteFontFileLoader)) { |
| 56 *ppvObject = this; | 56 *ppvObject = this; |
| 57 AddRef(); | 57 AddRef(); |
| 58 return S_OK; | 58 return S_OK; |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 autoUnregisterFontFileLoader.d
etatch(), | 573 autoUnregisterFontFileLoader.d
etatch(), |
| 574 autoUnregisterFontCollectionLo
ader.detatch()); | 574 autoUnregisterFontCollectionLo
ader.detatch()); |
| 575 } | 575 } |
| 576 } | 576 } |
| 577 } | 577 } |
| 578 | 578 |
| 579 return NULL; | 579 return NULL; |
| 580 } | 580 } |
| 581 | 581 |
| 582 SkTypeface* SkFontMgr_DirectWrite::onCreateFromData(SkData* data, int ttcIndex)
const { | 582 SkTypeface* SkFontMgr_DirectWrite::onCreateFromData(SkData* data, int ttcIndex)
const { |
| 583 SkAutoTUnref<SkStream> stream(SkNEW_ARGS(SkMemoryStream, (data))); | 583 return this->createFromStream(SkNEW_ARGS(SkMemoryStream, (data)), ttcIndex); |
| 584 return this->createFromStream(stream, ttcIndex); | |
| 585 } | 584 } |
| 586 | 585 |
| 587 SkTypeface* SkFontMgr_DirectWrite::onCreateFromFile(const char path[], int ttcIn
dex) const { | 586 SkTypeface* SkFontMgr_DirectWrite::onCreateFromFile(const char path[], int ttcIn
dex) const { |
| 588 SkAutoTUnref<SkStream> stream(SkStream::NewFromFile(path)); | 587 return this->createFromStream(SkStream::NewFromFile(path), ttcIndex); |
| 589 return this->createFromStream(stream, ttcIndex); | |
| 590 } | 588 } |
| 591 | 589 |
| 592 HRESULT SkFontMgr_DirectWrite::getByFamilyName(const WCHAR wideFamilyName[], | 590 HRESULT SkFontMgr_DirectWrite::getByFamilyName(const WCHAR wideFamilyName[], |
| 593 IDWriteFontFamily** fontFamily) c
onst { | 591 IDWriteFontFamily** fontFamily) c
onst { |
| 594 UINT32 index; | 592 UINT32 index; |
| 595 BOOL exists; | 593 BOOL exists; |
| 596 HR(fFontCollection->FindFamilyName(wideFamilyName, &index, &exists)); | 594 HR(fFontCollection->FindFamilyName(wideFamilyName, &index, &exists)); |
| 597 | 595 |
| 598 if (exists) { | 596 if (exists) { |
| 599 HR(fFontCollection->GetFontFamily(index, fontFamily)); | 597 HR(fFontCollection->GetFontFamily(index, fontFamily)); |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 765 } | 763 } |
| 766 | 764 |
| 767 #include "SkFontMgr_indirect.h" | 765 #include "SkFontMgr_indirect.h" |
| 768 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { | 766 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { |
| 769 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); | 767 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); |
| 770 if (impl.get() == NULL) { | 768 if (impl.get() == NULL) { |
| 771 return NULL; | 769 return NULL; |
| 772 } | 770 } |
| 773 return SkNEW_ARGS(SkFontMgr_Indirect, (impl.get(), proxy)); | 771 return SkNEW_ARGS(SkFontMgr_Indirect, (impl.get(), proxy)); |
| 774 } | 772 } |
| OLD | NEW |