Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1006)

Unified Diff: src/ports/SkFontHost_win_dw.cpp

Issue 23380002: Update DirectWrite code so that it is loadable on XP. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkFontHost_win_dw.cpp
===================================================================
--- src/ports/SkFontHost_win_dw.cpp (revision 10846)
+++ src/ports/SkFontHost_win_dw.cpp (working copy)
@@ -97,12 +97,6 @@
SkTDArray<uint8_t> fBits;
};
-typedef HRESULT (WINAPI *DWriteCreateFactoryProc)(
- __in DWRITE_FACTORY_TYPE factoryType,
- __in REFIID iid,
- __out IUnknown **factory
-);
-
static HRESULT get_dwrite_factory(IDWriteFactory** factory) {
static IDWriteFactory* gDWriteFactory = NULL;
@@ -111,6 +105,7 @@
return S_OK;
}
+ typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc;
DWriteCreateFactoryProc dWriteCreateFactoryProc =
reinterpret_cast<DWriteCreateFactoryProc>(
GetProcAddress(LoadLibraryW(L"dwrite.dll"), "DWriteCreateFactory")
@@ -1847,6 +1842,13 @@
#endif
+typedef decltype(GetUserDefaultLocaleName)* GetUserDefaultLocaleNameProc;
+static GetUserDefaultLocaleNameProc GetGetUserDefaultLocaleNameProc() {
+ return reinterpret_cast<GetUserDefaultLocaleNameProc>(
+ GetProcAddress(LoadLibraryW(L"Kernel32.dll"), "GetUserDefaultLocaleName")
+ );
+}
+
SkFontMgr* SkFontMgr::Factory() {
IDWriteFactory* factory;
HRNM(get_dwrite_factory(&factory), "Could not get factory.");
@@ -1857,10 +1859,18 @@
WCHAR localeNameStorage[LOCALE_NAME_MAX_LENGTH];
WCHAR* localeName = NULL;
- int localeNameLen = GetUserDefaultLocaleName(localeNameStorage, LOCALE_NAME_MAX_LENGTH);
- if (localeNameLen) {
- localeName = localeNameStorage;
- };
+ int localeNameLen = 0;
+ // Dynamically load GetUserDefaultLocaleName function, as it is not available on XP.
+ GetUserDefaultLocaleNameProc getUserDefaultLocaleNameProc = GetGetUserDefaultLocaleNameProc();
+ if (NULL == getUserDefaultLocaleNameProc) {
+ SkDebugf("Could not get GetUserDefaultLocaleName.");
+ } else {
+ localeNameLen = getUserDefaultLocaleNameProc(localeNameStorage, LOCALE_NAME_MAX_LENGTH);
+ if (localeNameLen) {
+ localeName = localeNameStorage;
+ };
+ }
+
return SkNEW_ARGS(SkFontMgr_DirectWrite, (sysFontCollection.get(), localeName, localeNameLen));
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698