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 "SkDWrite.h" | 8 #include "SkDWrite.h" |
| 9 #include "SkHRESULT.h" | 9 #include "SkHRESULT.h" |
| 10 #include "SkOnce.h" | 10 #include "SkOnce.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 } | 34 } |
| 35 | 35 |
| 36 HRVM(dWriteCreateFactoryProc(DWRITE_FACTORY_TYPE_SHARED, | 36 HRVM(dWriteCreateFactoryProc(DWRITE_FACTORY_TYPE_SHARED, |
| 37 __uuidof(IDWriteFactory), | 37 __uuidof(IDWriteFactory), |
| 38 reinterpret_cast<IUnknown**>(factory)), | 38 reinterpret_cast<IUnknown**>(factory)), |
| 39 "Could not create DirectWrite factory."); | 39 "Could not create DirectWrite factory."); |
| 40 atexit(release_dwrite_factory); | 40 atexit(release_dwrite_factory); |
| 41 } | 41 } |
| 42 | 42 |
| 43 | 43 |
| 44 SK_DECLARE_STATIC_ONCE(once); | |
|
bungeman-skia
2015/01/12 19:36:37
'once' seems like a rather generic thing to put at
| |
| 44 IDWriteFactory* sk_get_dwrite_factory() { | 45 IDWriteFactory* sk_get_dwrite_factory() { |
| 45 SK_DECLARE_STATIC_ONCE(once); | |
| 46 SkOnce(&once, create_dwrite_factory, &gDWriteFactory); | 46 SkOnce(&once, create_dwrite_factory, &gDWriteFactory); |
| 47 | |
| 48 return gDWriteFactory; | 47 return gDWriteFactory; |
| 49 } | 48 } |
| 50 | 49 |
| 51 //////////////////////////////////////////////////////////////////////////////// | 50 //////////////////////////////////////////////////////////////////////////////// |
| 52 // String conversion | 51 // String conversion |
| 53 | 52 |
| 54 /** Converts a utf8 string to a WCHAR string. */ | 53 /** Converts a utf8 string to a WCHAR string. */ |
| 55 HRESULT sk_cstring_to_wchar(const char* skname, SkSMallocWCHAR* name) { | 54 HRESULT sk_cstring_to_wchar(const char* skname, SkSMallocWCHAR* name) { |
| 56 int wlen = MultiByteToWideChar(CP_UTF8, 0, skname, -1, NULL, 0); | 55 int wlen = MultiByteToWideChar(CP_UTF8, 0, skname, -1, NULL, 0); |
| 57 if (0 == wlen) { | 56 if (0 == wlen) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 ); | 115 ); |
| 117 if (!*proc) { | 116 if (!*proc) { |
| 118 HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); | 117 HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); |
| 119 if (!IS_ERROR(hr)) { | 118 if (!IS_ERROR(hr)) { |
| 120 hr = ERROR_PROC_NOT_FOUND; | 119 hr = ERROR_PROC_NOT_FOUND; |
| 121 } | 120 } |
| 122 return hr; | 121 return hr; |
| 123 } | 122 } |
| 124 return S_OK; | 123 return S_OK; |
| 125 } | 124 } |
| OLD | NEW |