| 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 28 matching lines...) Expand all Loading... |
| 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 SkAutoTUnref<SkStream> fStream; |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 StreamFontFileLoader(SkStream* stream) : fRefCount(1), fStream(SkRef(stream)
) { } | 48 StreamFontFileLoader(SkStream* stream) : fRefCount(1), fStream(SkRef(stream)
) { } |
| 49 virtual ~StreamFontFileLoader() { } |
| 49 | 50 |
| 50 ULONG fRefCount; | 51 ULONG fRefCount; |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 HRESULT StreamFontFileLoader::QueryInterface(REFIID iid, void** ppvObject) { | 54 HRESULT StreamFontFileLoader::QueryInterface(REFIID iid, void** ppvObject) { |
| 54 if (iid == IID_IUnknown || iid == __uuidof(IDWriteFontFileLoader)) { | 55 if (iid == IID_IUnknown || iid == __uuidof(IDWriteFontFileLoader)) { |
| 55 *ppvObject = this; | 56 *ppvObject = this; |
| 56 AddRef(); | 57 AddRef(); |
| 57 return S_OK; | 58 return S_OK; |
| 58 } else { | 59 } else { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 static HRESULT Create(IDWriteFactory* factory, IDWriteFontFileLoader* fontFi
leLoader, | 101 static HRESULT Create(IDWriteFactory* factory, IDWriteFontFileLoader* fontFi
leLoader, |
| 101 StreamFontFileEnumerator** streamFontFileEnumerator) { | 102 StreamFontFileEnumerator** streamFontFileEnumerator) { |
| 102 *streamFontFileEnumerator = new StreamFontFileEnumerator(factory, fontFi
leLoader); | 103 *streamFontFileEnumerator = new StreamFontFileEnumerator(factory, fontFi
leLoader); |
| 103 if (NULL == streamFontFileEnumerator) { | 104 if (NULL == streamFontFileEnumerator) { |
| 104 return E_OUTOFMEMORY; | 105 return E_OUTOFMEMORY; |
| 105 } | 106 } |
| 106 return S_OK; | 107 return S_OK; |
| 107 } | 108 } |
| 108 private: | 109 private: |
| 109 StreamFontFileEnumerator(IDWriteFactory* factory, IDWriteFontFileLoader* fon
tFileLoader); | 110 StreamFontFileEnumerator(IDWriteFactory* factory, IDWriteFontFileLoader* fon
tFileLoader); |
| 111 virtual ~StreamFontFileEnumerator() { } |
| 112 |
| 110 ULONG fRefCount; | 113 ULONG fRefCount; |
| 111 | 114 |
| 112 SkTScopedComPtr<IDWriteFactory> fFactory; | 115 SkTScopedComPtr<IDWriteFactory> fFactory; |
| 113 SkTScopedComPtr<IDWriteFontFile> fCurrentFile; | 116 SkTScopedComPtr<IDWriteFontFile> fCurrentFile; |
| 114 SkTScopedComPtr<IDWriteFontFileLoader> fFontFileLoader; | 117 SkTScopedComPtr<IDWriteFontFileLoader> fFontFileLoader; |
| 115 bool fHasNext; | 118 bool fHasNext; |
| 116 }; | 119 }; |
| 117 | 120 |
| 118 StreamFontFileEnumerator::StreamFontFileEnumerator(IDWriteFactory* factory, | 121 StreamFontFileEnumerator::StreamFontFileEnumerator(IDWriteFactory* factory, |
| 119 IDWriteFontFileLoader* fontFi
leLoader) | 122 IDWriteFontFileLoader* fontFi
leLoader) |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 if (NULL == streamFontCollectionLoader) { | 201 if (NULL == streamFontCollectionLoader) { |
| 199 return E_OUTOFMEMORY; | 202 return E_OUTOFMEMORY; |
| 200 } | 203 } |
| 201 return S_OK; | 204 return S_OK; |
| 202 } | 205 } |
| 203 private: | 206 private: |
| 204 StreamFontCollectionLoader(IDWriteFontFileLoader* fontFileLoader) | 207 StreamFontCollectionLoader(IDWriteFontFileLoader* fontFileLoader) |
| 205 : fRefCount(1) | 208 : fRefCount(1) |
| 206 , fFontFileLoader(SkRefComPtr(fontFileLoader)) | 209 , fFontFileLoader(SkRefComPtr(fontFileLoader)) |
| 207 { } | 210 { } |
| 211 virtual ~StreamFontCollectionLoader() { } |
| 208 | 212 |
| 209 ULONG fRefCount; | 213 ULONG fRefCount; |
| 210 SkTScopedComPtr<IDWriteFontFileLoader> fFontFileLoader; | 214 SkTScopedComPtr<IDWriteFontFileLoader> fFontFileLoader; |
| 211 }; | 215 }; |
| 212 | 216 |
| 213 HRESULT StreamFontCollectionLoader::QueryInterface(REFIID iid, void** ppvObject)
{ | 217 HRESULT StreamFontCollectionLoader::QueryInterface(REFIID iid, void** ppvObject)
{ |
| 214 if (iid == IID_IUnknown || iid == __uuidof(IDWriteFontCollectionLoader)) { | 218 if (iid == IID_IUnknown || iid == __uuidof(IDWriteFontCollectionLoader)) { |
| 215 *ppvObject = this; | 219 *ppvObject = this; |
| 216 AddRef(); | 220 AddRef(); |
| 217 return S_OK; | 221 return S_OK; |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 751 } | 755 } |
| 752 | 756 |
| 753 #include "SkFontMgr_indirect.h" | 757 #include "SkFontMgr_indirect.h" |
| 754 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { | 758 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { |
| 755 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); | 759 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); |
| 756 if (impl.get() == NULL) { | 760 if (impl.get() == NULL) { |
| 757 return NULL; | 761 return NULL; |
| 758 } | 762 } |
| 759 return SkNEW_ARGS(SkFontMgr_Indirect, (impl.get(), proxy)); | 763 return SkNEW_ARGS(SkFontMgr_Indirect, (impl.get(), proxy)); |
| 760 } | 764 } |
| OLD | NEW |