| 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 #include "SkTypes.h" | 7 #include "SkTypes.h" |
| 8 #if defined(SK_BUILD_FOR_WIN32) | 8 #if defined(SK_BUILD_FOR_WIN32) |
| 9 | 9 |
| 10 #include "SkDWrite.h" | 10 #include "SkDWrite.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 } | 36 } |
| 37 | 37 |
| 38 HRVM(dWriteCreateFactoryProc(DWRITE_FACTORY_TYPE_SHARED, | 38 HRVM(dWriteCreateFactoryProc(DWRITE_FACTORY_TYPE_SHARED, |
| 39 __uuidof(IDWriteFactory), | 39 __uuidof(IDWriteFactory), |
| 40 reinterpret_cast<IUnknown**>(factory)), | 40 reinterpret_cast<IUnknown**>(factory)), |
| 41 "Could not create DirectWrite factory."); | 41 "Could not create DirectWrite factory."); |
| 42 atexit(release_dwrite_factory); | 42 atexit(release_dwrite_factory); |
| 43 } | 43 } |
| 44 | 44 |
| 45 | 45 |
| 46 SK_DECLARE_STATIC_ONCE(once); | |
| 47 IDWriteFactory* sk_get_dwrite_factory() { | 46 IDWriteFactory* sk_get_dwrite_factory() { |
| 48 SkOnce(&once, create_dwrite_factory, &gDWriteFactory); | 47 static SkOnce once; |
| 48 once(create_dwrite_factory, &gDWriteFactory); |
| 49 return gDWriteFactory; | 49 return gDWriteFactory; |
| 50 } | 50 } |
| 51 | 51 |
| 52 //////////////////////////////////////////////////////////////////////////////// | 52 //////////////////////////////////////////////////////////////////////////////// |
| 53 // String conversion | 53 // String conversion |
| 54 | 54 |
| 55 /** Converts a utf8 string to a WCHAR string. */ | 55 /** Converts a utf8 string to a WCHAR string. */ |
| 56 HRESULT sk_cstring_to_wchar(const char* skname, SkSMallocWCHAR* name) { | 56 HRESULT sk_cstring_to_wchar(const char* skname, SkSMallocWCHAR* name) { |
| 57 int wlen = MultiByteToWideChar(CP_UTF8, 0, skname, -1, nullptr, 0); | 57 int wlen = MultiByteToWideChar(CP_UTF8, 0, skname, -1, nullptr, 0); |
| 58 if (0 == wlen) { | 58 if (0 == wlen) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); | 119 HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); |
| 120 if (!IS_ERROR(hr)) { | 120 if (!IS_ERROR(hr)) { |
| 121 hr = ERROR_PROC_NOT_FOUND; | 121 hr = ERROR_PROC_NOT_FOUND; |
| 122 } | 122 } |
| 123 return hr; | 123 return hr; |
| 124 } | 124 } |
| 125 return S_OK; | 125 return S_OK; |
| 126 } | 126 } |
| 127 | 127 |
| 128 #endif//defined(SK_BUILD_FOR_WIN32) | 128 #endif//defined(SK_BUILD_FOR_WIN32) |
| OLD | NEW |