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

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

Issue 231763003: Support sideloaded fonts via command line option for blink layout_tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: guard for xp Created 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/public/renderer/render_font_warmup_win.h"
6
7 #include <dwrite.h>
8
9 #include "base/logging.h"
10 #include "third_party/WebKit/public/web/win/WebFontRendering.h"
11 #include "third_party/skia/include/core/SkPaint.h"
12 #include "third_party/skia/include/ports/SkFontMgr.h"
13 #include "third_party/skia/include/ports/SkTypeface_win.h"
14
15 namespace content {
16
17 namespace {
18
19 SkFontMgr* g_warmup_fontmgr = NULL;
20
21 // Windows-only DirectWrite support. These warm up the DirectWrite paths
22 // before sandbox lock down to allow Skia access to the Font Manager service.
23 void CreateDirectWriteFactory(IDWriteFactory** factory) {
24 typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc;
25 DWriteCreateFactoryProc dwrite_create_factory_proc =
26 reinterpret_cast<DWriteCreateFactoryProc>(
27 GetProcAddress(LoadLibraryW(L"dwrite.dll"), "DWriteCreateFactory"));
28 CHECK(dwrite_create_factory_proc);
29 CHECK(SUCCEEDED(
30 dwrite_create_factory_proc(DWRITE_FACTORY_TYPE_ISOLATED,
31 __uuidof(IDWriteFactory),
32 reinterpret_cast<IUnknown**>(factory))));
33 }
34
35 } // namespace
36
37 void DoPreSandboxWarmupForTypeface(SkTypeface* typeface) {
38 SkPaint paint_warmup;
39 paint_warmup.setTypeface(typeface);
40 wchar_t glyph = L'S';
41 paint_warmup.measureText(&glyph, 2);
42 }
43
44 SkFontMgr* GetPreSandboxWarmupFontMgr() {
45 if (!g_warmup_fontmgr) {
46 IDWriteFactory* factory;
47 CreateDirectWriteFactory(&factory);
48 blink::WebFontRendering::setDirectWriteFactory(factory);
49 g_warmup_fontmgr = SkFontMgr_New_DirectWrite(factory);
50 }
51 return g_warmup_fontmgr;
52 }
53
54 } // namespace content
OLDNEW
« no previous file with comments | « content/public/renderer/render_font_warmup_win.h ('k') | content/renderer/renderer_main_platform_delegate_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698