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

Side by Side Diff: content/public/renderer/render_font_warmup_win.cc

Issue 354023007: Use DirectWrite to populate list of avalible fonts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/public/renderer/render_font_warmup_win.h" 5 #include "content/public/renderer/render_font_warmup_win.h"
6 6
7 #include <dwrite.h> 7 #include <dwrite.h>
8 8
9 #include "base/debug/alias.h" 9 #include "base/debug/alias.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "third_party/WebKit/public/web/win/WebFontRendering.h" 11 #include "third_party/WebKit/public/web/win/WebFontRendering.h"
12 #include "third_party/skia/include/core/SkPaint.h" 12 #include "third_party/skia/include/core/SkPaint.h"
13 #include "third_party/skia/include/ports/SkFontMgr.h" 13 #include "third_party/skia/include/ports/SkFontMgr.h"
14 #include "third_party/skia/include/ports/SkTypeface_win.h" 14 #include "third_party/skia/include/ports/SkTypeface_win.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 namespace {
19
20 SkFontMgr* g_warmup_fontmgr = NULL; 18 SkFontMgr* g_warmup_fontmgr = NULL;
scottmg 2014/06/26 20:13:38 I don't think it's a great idea to make another of
eae 2014/06/26 20:58:24 That makes sense. Any idea where this code should
scottmg 2014/06/26 21:05:17 Yeah, I think I wouldn't bother sharing with this
21 19
22 // Windows-only DirectWrite support. These warm up the DirectWrite paths 20 // Windows-only DirectWrite support. These warm up the DirectWrite paths
23 // before sandbox lock down to allow Skia access to the Font Manager service. 21 // before sandbox lock down to allow Skia access to the Font Manager service.
24 void CreateDirectWriteFactory(IDWriteFactory** factory) { 22 void CreateDirectWriteFactory(IDWriteFactory** factory) {
25 typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc; 23 typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc;
26 HMODULE dwrite_dll = LoadLibraryW(L"dwrite.dll"); 24 HMODULE dwrite_dll = LoadLibraryW(L"dwrite.dll");
27 // TODO(scottmg): Temporary code to track crash in http://crbug.com/387867. 25 // TODO(scottmg): Temporary code to track crash in http://crbug.com/387867.
28 if (!dwrite_dll) { 26 if (!dwrite_dll) {
29 DWORD load_library_get_last_error = GetLastError(); 27 DWORD load_library_get_last_error = GetLastError();
30 base::debug::Alias(&dwrite_dll); 28 base::debug::Alias(&dwrite_dll);
(...skipping 10 matching lines...) Expand all
41 base::debug::Alias(&dwrite_create_factory_proc); 39 base::debug::Alias(&dwrite_create_factory_proc);
42 base::debug::Alias(&get_proc_address_get_last_error); 40 base::debug::Alias(&get_proc_address_get_last_error);
43 CHECK(false); 41 CHECK(false);
44 } 42 }
45 CHECK(SUCCEEDED( 43 CHECK(SUCCEEDED(
46 dwrite_create_factory_proc(DWRITE_FACTORY_TYPE_ISOLATED, 44 dwrite_create_factory_proc(DWRITE_FACTORY_TYPE_ISOLATED,
47 __uuidof(IDWriteFactory), 45 __uuidof(IDWriteFactory),
48 reinterpret_cast<IUnknown**>(factory)))); 46 reinterpret_cast<IUnknown**>(factory))));
49 } 47 }
50 48
51 } // namespace
52
53 void DoPreSandboxWarmupForTypeface(SkTypeface* typeface) { 49 void DoPreSandboxWarmupForTypeface(SkTypeface* typeface) {
54 SkPaint paint_warmup; 50 SkPaint paint_warmup;
55 paint_warmup.setTypeface(typeface); 51 paint_warmup.setTypeface(typeface);
56 wchar_t glyph = L'S'; 52 wchar_t glyph = L'S';
57 paint_warmup.measureText(&glyph, 2); 53 paint_warmup.measureText(&glyph, 2);
58 } 54 }
59 55
60 SkFontMgr* GetPreSandboxWarmupFontMgr() { 56 SkFontMgr* GetPreSandboxWarmupFontMgr() {
61 if (!g_warmup_fontmgr) { 57 if (!g_warmup_fontmgr) {
62 IDWriteFactory* factory; 58 IDWriteFactory* factory;
63 CreateDirectWriteFactory(&factory); 59 CreateDirectWriteFactory(&factory);
64 blink::WebFontRendering::setDirectWriteFactory(factory); 60 blink::WebFontRendering::setDirectWriteFactory(factory);
65 g_warmup_fontmgr = SkFontMgr_New_DirectWrite(factory); 61 g_warmup_fontmgr = SkFontMgr_New_DirectWrite(factory);
66 } 62 }
67 return g_warmup_fontmgr; 63 return g_warmup_fontmgr;
68 } 64 }
69 65
70 } // namespace content 66 } // namespace content
OLDNEW
« content/common/font_list_win.cc ('K') | « content/public/renderer/render_font_warmup_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698