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

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

Issue 217733002: Support user-configurable function to create IDWriteFactory (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 9 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
« no previous file with comments | « include/ports/SkTypeface_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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"
11 #include "SkString.h" 11 #include "SkString.h"
12 12
13 #include <dwrite.h> 13 #include <dwrite.h>
14 14
15 static IDWriteFactory* gDWriteFactory = NULL; 15 static IDWriteFactory* gDWriteFactory = NULL;
16 static void (*gDWriteFactoryProc)(IDWriteFactory**) = NULL;
17
18 void SkSetDirectWriteFactoryProc(void (*proc)(IDWriteFactory**)) {
19 gDWriteFactoryProc = proc;
20 }
16 21
17 static void create_dwrite_factory(IDWriteFactory** factory) { 22 static void create_dwrite_factory(IDWriteFactory** factory) {
23 if (gDWriteFactoryProc) {
24 gDWriteFactoryProc(factory);
25 return;
26 }
27
18 typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc; 28 typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc;
19 DWriteCreateFactoryProc dWriteCreateFactoryProc = reinterpret_cast<DWriteCre ateFactoryProc>( 29 DWriteCreateFactoryProc dWriteCreateFactoryProc = reinterpret_cast<DWriteCre ateFactoryProc>(
20 GetProcAddress(LoadLibraryW(L"dwrite.dll"), "DWriteCreateFactory")); 30 GetProcAddress(LoadLibraryW(L"dwrite.dll"), "DWriteCreateFactory"));
21 31
22 if (!dWriteCreateFactoryProc) { 32 if (!dWriteCreateFactoryProc) {
23 HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); 33 HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
24 if (!IS_ERROR(hr)) { 34 if (!IS_ERROR(hr)) {
25 hr = ERROR_PROC_NOT_FOUND; 35 hr = ERROR_PROC_NOT_FOUND;
26 } 36 }
27 HRVM(hr, "Could not get DWriteCreateFactory proc."); 37 HRVM(hr, "Could not get DWriteCreateFactory proc.");
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 ); 129 );
120 if (!*proc) { 130 if (!*proc) {
121 HRESULT hr = HRESULT_FROM_WIN32(GetLastError()); 131 HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
122 if (!IS_ERROR(hr)) { 132 if (!IS_ERROR(hr)) {
123 hr = ERROR_PROC_NOT_FOUND; 133 hr = ERROR_PROC_NOT_FOUND;
124 } 134 }
125 return hr; 135 return hr;
126 } 136 }
127 return S_OK; 137 return S_OK;
128 } 138 }
OLDNEW
« no previous file with comments | « include/ports/SkTypeface_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698