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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 259 |
260 class SkFontMgr_DirectWrite : public SkFontMgr { | 260 class SkFontMgr_DirectWrite : public SkFontMgr { |
261 public: | 261 public: |
262 /** localeNameLength must include the null terminator. */ | 262 /** localeNameLength must include the null terminator. */ |
263 SkFontMgr_DirectWrite(IDWriteFactory* factory, IDWriteFontCollection* fontCo
llection, | 263 SkFontMgr_DirectWrite(IDWriteFactory* factory, IDWriteFontCollection* fontCo
llection, |
264 WCHAR* localeName, int localeNameLength) | 264 WCHAR* localeName, int localeNameLength) |
265 : fFactory(SkRefComPtr(factory)) | 265 : fFactory(SkRefComPtr(factory)) |
266 , fFontCollection(SkRefComPtr(fontCollection)) | 266 , fFontCollection(SkRefComPtr(fontCollection)) |
267 , fLocaleName(localeNameLength) | 267 , fLocaleName(localeNameLength) |
268 { | 268 { |
269 #ifdef SK_HAS_DWRITE_2_H | 269 #if SK_HAS_DWRITE_2_H |
270 if (!SUCCEEDED(fFactory->QueryInterface(&fFactory2))) { | 270 if (!SUCCEEDED(fFactory->QueryInterface(&fFactory2))) { |
271 // IUnknown::QueryInterface states that if it fails, punk will be se
t to NULL. | 271 // IUnknown::QueryInterface states that if it fails, punk will be se
t to NULL. |
272 // http://blogs.msdn.com/b/oldnewthing/archive/2004/03/26/96777.aspx | 272 // http://blogs.msdn.com/b/oldnewthing/archive/2004/03/26/96777.aspx |
273 SK_ALWAYSBREAK(NULL == fFactory2.get()); | 273 SK_ALWAYSBREAK(NULL == fFactory2.get()); |
274 } | 274 } |
275 #endif | 275 #endif |
276 memcpy(fLocaleName.get(), localeName, localeNameLength * sizeof(WCHAR)); | 276 memcpy(fLocaleName.get(), localeName, localeNameLength * sizeof(WCHAR)); |
277 } | 277 } |
278 | 278 |
279 protected: | 279 protected: |
(...skipping 17 matching lines...) Expand all Loading... |
297 private: | 297 private: |
298 HRESULT getByFamilyName(const WCHAR familyName[], IDWriteFontFamily** fontFa
mily) const; | 298 HRESULT getByFamilyName(const WCHAR familyName[], IDWriteFontFamily** fontFa
mily) const; |
299 HRESULT getDefaultFontFamily(IDWriteFontFamily** fontFamily) const; | 299 HRESULT getDefaultFontFamily(IDWriteFontFamily** fontFamily) const; |
300 | 300 |
301 /** Creates a typeface using a typeface cache. */ | 301 /** Creates a typeface using a typeface cache. */ |
302 SkTypeface* createTypefaceFromDWriteFont(IDWriteFontFace* fontFace, | 302 SkTypeface* createTypefaceFromDWriteFont(IDWriteFontFace* fontFace, |
303 IDWriteFont* font, | 303 IDWriteFont* font, |
304 IDWriteFontFamily* fontFamily) cons
t; | 304 IDWriteFontFamily* fontFamily) cons
t; |
305 | 305 |
306 SkTScopedComPtr<IDWriteFactory> fFactory; | 306 SkTScopedComPtr<IDWriteFactory> fFactory; |
307 #ifdef SK_HAS_DWRITE_2_H | 307 #if SK_HAS_DWRITE_2_H |
308 SkTScopedComPtr<IDWriteFactory2> fFactory2; | 308 SkTScopedComPtr<IDWriteFactory2> fFactory2; |
309 #endif | 309 #endif |
310 SkTScopedComPtr<IDWriteFontCollection> fFontCollection; | 310 SkTScopedComPtr<IDWriteFontCollection> fFontCollection; |
311 SkSMallocWCHAR fLocaleName; | 311 SkSMallocWCHAR fLocaleName; |
312 mutable SkMutex fTFCacheMutex; | 312 mutable SkMutex fTFCacheMutex; |
313 mutable SkTypefaceCache fTFCache; | 313 mutable SkTypefaceCache fTFCache; |
314 | 314 |
315 friend class SkFontStyleSet_DirectWrite; | 315 friend class SkFontStyleSet_DirectWrite; |
316 friend class FontFallbackRenderer; | 316 friend class FontFallbackRenderer; |
317 }; | 317 }; |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1112 } | 1112 } |
1113 | 1113 |
1114 #include "SkFontMgr_indirect.h" | 1114 #include "SkFontMgr_indirect.h" |
1115 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { | 1115 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { |
1116 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); | 1116 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); |
1117 if (impl.get() == NULL) { | 1117 if (impl.get() == NULL) { |
1118 return NULL; | 1118 return NULL; |
1119 } | 1119 } |
1120 return SkNEW_ARGS(SkFontMgr_Indirect, (impl.get(), proxy)); | 1120 return SkNEW_ARGS(SkFontMgr_Indirect, (impl.get(), proxy)); |
1121 } | 1121 } |
OLD | NEW |