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

Side by Side Diff: src/utils/win/SkDWrite.cpp

Issue 1894893002: Modernize and trim down SkOnce. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: might as well class Created 4 years, 8 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 unified diff | Download patch
OLDNEW
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
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
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)
OLDNEW
« src/core/SkTaskGroup.cpp ('K') | « src/gpu/GrProgramElement.cpp ('k') | tests/OnceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698