Chromium Code Reviews| 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 "SkTypes.h" | 8 #include "SkTypes.h" |
| 9 #if defined(SK_BUILD_FOR_WIN32) | 9 #if defined(SK_BUILD_FOR_WIN32) |
| 10 | 10 |
| (...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1060 SkTScopedComPtr<IDWriteFontFace> fontFace; | 1060 SkTScopedComPtr<IDWriteFontFace> fontFace; |
| 1061 HRNM(font->CreateFontFace(&fontFace), "Could not create font face."); | 1061 HRNM(font->CreateFontFace(&fontFace), "Could not create font face."); |
| 1062 | 1062 |
| 1063 return fFontMgr->createTypefaceFromDWriteFont(fontFace.get(), font.get(), | 1063 return fFontMgr->createTypefaceFromDWriteFont(fontFace.get(), font.get(), |
| 1064 fFontFamily.get()); | 1064 fFontFamily.get()); |
| 1065 } | 1065 } |
| 1066 | 1066 |
| 1067 //////////////////////////////////////////////////////////////////////////////// | 1067 //////////////////////////////////////////////////////////////////////////////// |
| 1068 #include "SkTypeface_win.h" | 1068 #include "SkTypeface_win.h" |
| 1069 | 1069 |
| 1070 SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory) { | 1070 SK_API SkFontMgr* SkFontMgr_New_DirectWrite(IDWriteFactory* factory, |
| 1071 IDWriteFontCollection* collection) { | |
| 1071 if (nullptr == factory) { | 1072 if (nullptr == factory) { |
| 1072 factory = sk_get_dwrite_factory(); | 1073 factory = sk_get_dwrite_factory(); |
| 1073 if (nullptr == factory) { | 1074 if (nullptr == factory) { |
| 1074 return nullptr; | 1075 return nullptr; |
| 1075 } | 1076 } |
| 1076 } | 1077 } |
| 1077 | 1078 |
| 1078 SkTScopedComPtr<IDWriteFontCollection> sysFontCollection; | 1079 SkTScopedComPtr<IDWriteFontCollection> fontCollection; |
| 1079 HRNM(factory->GetSystemFontCollection(&sysFontCollection, FALSE), | 1080 if (collection != nullptr) { |
| 1080 "Could not get system font collection."); | 1081 fontCollection.swap(SkTScopedComPtr<IDWriteFontCollection>(collection)); |
| 1082 } | |
| 1083 else { | |
| 1084 HRNM(factory->GetSystemFontCollection(&fontCollection, FALSE), | |
| 1085 "Could not get system font collection."); | |
| 1086 } | |
|
bungeman-skia
2016/01/29 20:12:29
I would write this whole block as
SkTScopedComPtr
Ilya Kulshin
2016/01/29 22:10:15
Done. While looking at it I also noticed that SkTS
| |
| 1081 | 1087 |
| 1082 WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH]; | 1088 WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH]; |
| 1083 WCHAR* localeName = nullptr; | 1089 WCHAR* localeName = nullptr; |
| 1084 int localeNameLen = 0; | 1090 int localeNameLen = 0; |
| 1085 | 1091 |
| 1086 // Dynamically load GetUserDefaultLocaleName function, as it is not availabl e on XP. | 1092 // Dynamically load GetUserDefaultLocaleName function, as it is not availabl e on XP. |
| 1087 SkGetUserDefaultLocaleNameProc getUserDefaultLocaleNameProc = nullptr; | 1093 SkGetUserDefaultLocaleNameProc getUserDefaultLocaleNameProc = nullptr; |
| 1088 HRESULT hr = SkGetGetUserDefaultLocaleNameProc(&getUserDefaultLocaleNameProc ); | 1094 HRESULT hr = SkGetGetUserDefaultLocaleNameProc(&getUserDefaultLocaleNameProc ); |
| 1089 if (nullptr == getUserDefaultLocaleNameProc) { | 1095 if (nullptr == getUserDefaultLocaleNameProc) { |
| 1090 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); | 1096 SK_TRACEHR(hr, "Could not get GetUserDefaultLocaleName."); |
| 1091 } else { | 1097 } else { |
| 1092 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N AME_MAX_LENGTH); | 1098 localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_N AME_MAX_LENGTH); |
| 1093 if (localeNameLen) { | 1099 if (localeNameLen) { |
| 1094 localeName = localeNameStorage; | 1100 localeName = localeNameStorage; |
| 1095 }; | 1101 }; |
| 1096 } | 1102 } |
| 1097 | 1103 |
| 1098 return new SkFontMgr_DirectWrite(factory, sysFontCollection.get(), localeNam e, localeNameLen); | 1104 return new SkFontMgr_DirectWrite(factory, fontCollection.get(), localeName, localeNameLen); |
| 1099 } | 1105 } |
| 1100 | 1106 |
| 1101 #include "SkFontMgr_indirect.h" | 1107 #include "SkFontMgr_indirect.h" |
| 1102 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { | 1108 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { |
| 1103 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); | 1109 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); |
| 1104 if (impl.get() == nullptr) { | 1110 if (impl.get() == nullptr) { |
| 1105 return nullptr; | 1111 return nullptr; |
| 1106 } | 1112 } |
| 1107 return new SkFontMgr_Indirect(impl.get(), proxy); | 1113 return new SkFontMgr_Indirect(impl.get(), proxy); |
| 1108 } | 1114 } |
| 1109 #endif//defined(SK_BUILD_FOR_WIN32) | 1115 #endif//defined(SK_BUILD_FOR_WIN32) |
| OLD | NEW |