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

Unified Diff: content/renderer/renderer_main_platform_delegate_win.cc

Issue 217813008: Use skia warmup for DirectWrite (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add new factory function to blink and use it 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/renderer_main_platform_delegate_win.cc
diff --git a/content/renderer/renderer_main_platform_delegate_win.cc b/content/renderer/renderer_main_platform_delegate_win.cc
index f907a192e027f880fff3bb591d0256ce0ab10c57..56d81ee47774c580d99c7937e9df6240040c3a35 100644
--- a/content/renderer/renderer_main_platform_delegate_win.cc
+++ b/content/renderer/renderer_main_platform_delegate_win.cc
@@ -20,6 +20,7 @@
#include "skia/ext/vector_platform_device_emf_win.h"
#include "third_party/WebKit/public/web/win/WebFontRendering.h"
#include "third_party/icu/source/i18n/unicode/timezone.h"
+#include "third_party/skia/include/ports/SkFontMgr.h"
#include "third_party/skia/include/ports/SkTypeface_win.h"
#ifdef ENABLE_VTUNE_JIT_INTERFACE
@@ -53,47 +54,30 @@ void SkiaPreCacheFontCharacters(const LOGFONT& logfont,
// Windows-only DirectWrite support. These warm up the DirectWrite paths
// before sandbox lock down to allow Skia access to the Font Manager service.
-bool CreateDirectWriteFactory(IDWriteFactory** factory) {
+void CreateDirectWriteFactory(IDWriteFactory** factory) {
typedef decltype(DWriteCreateFactory)* DWriteCreateFactoryProc;
DWriteCreateFactoryProc dwrite_create_factory_proc =
reinterpret_cast<DWriteCreateFactoryProc>(
GetProcAddress(LoadLibraryW(L"dwrite.dll"), "DWriteCreateFactory"));
- if (!dwrite_create_factory_proc)
- return false;
+ CHECK(dwrite_create_factory_proc);
CHECK(SUCCEEDED(
- dwrite_create_factory_proc(DWRITE_FACTORY_TYPE_SHARED,
+ dwrite_create_factory_proc(DWRITE_FACTORY_TYPE_ISOLATED,
__uuidof(IDWriteFactory),
reinterpret_cast<IUnknown**>(factory))));
- return true;
}
void WarmupDirectWrite() {
- base::win::ScopedComPtr<IDWriteFactory> factory;
- if (!CreateDirectWriteFactory(factory.Receive()))
- return;
-
- base::win::ScopedComPtr<IDWriteFontCollection> font_collection;
- CHECK(SUCCEEDED(
- factory->GetSystemFontCollection(font_collection.Receive(), FALSE)));
- base::win::ScopedComPtr<IDWriteFontFamily> font_family;
-
- UINT32 index;
- BOOL exists;
- CHECK(SUCCEEDED(
- font_collection->FindFamilyName(L"Times New Roman", &index, &exists)));
- CHECK(exists);
- CHECK(
- SUCCEEDED(font_collection->GetFontFamily(index, font_family.Receive())));
- base::win::ScopedComPtr<IDWriteFont> font;
- base::win::ScopedComPtr<IDWriteFontFace> font_face;
- CHECK(SUCCEEDED(font_family->GetFirstMatchingFont(DWRITE_FONT_WEIGHT_NORMAL,
- DWRITE_FONT_STRETCH_NORMAL,
- DWRITE_FONT_STYLE_NORMAL,
- font.Receive())));
- CHECK(SUCCEEDED(font->CreateFontFace(font_face.Receive())));
- DWRITE_GLYPH_METRICS gm;
- UINT16 glyph = L'S';
- CHECK(SUCCEEDED(font_face->GetDesignGlyphMetrics(&glyph, 1, &gm)));
+ // The objects used here are intentionally not freed as we want the Skia
+ // code to use these objects after warmup.
+ IDWriteFactory* factory;
+ CreateDirectWriteFactory(&factory);
+ blink::WebFontRendering::setDirectWriteFactory(factory);
+ SkFontMgr* fontmgr = SkFontMgr_New_DirectWrite(factory);
+ SkTypeface* typeface = fontmgr->legacyCreateTypeface("Times New Roman", 0);
+ SkPaint paint_warmup;
+ paint_warmup.setTypeface(typeface);
+ wchar_t glyph = L'S';
+ paint_warmup.measureText(&glyph, 2);
}
} // namespace
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698