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

Unified Diff: ui/gfx/win/direct_write.cc

Issue 1378353006: Implementation of dwrite font proxy and removal of dwrite font cache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More codereview fixes. Jumped the gun on previous patchset. Created 5 years, 1 month 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 | « ui/gfx/win/direct_write.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/win/direct_write.cc
diff --git a/ui/gfx/win/direct_write.cc b/ui/gfx/win/direct_write.cc
index 38c926a9bd11da661c3e66b614c177427a6bf6ae..bcdbd32ed2b674386681d9ab9008429a8a361936 100644
--- a/ui/gfx/win/direct_write.cc
+++ b/ui/gfx/win/direct_write.cc
@@ -21,6 +21,8 @@
namespace gfx {
namespace win {
+base::win::ScopedComPtr<IDWriteFactory> factory_;
+
namespace {
static bool dwrite_enabled = false;
@@ -81,13 +83,10 @@ void MaybeInitializeDirectWrite() {
if (!dwrite_create_factory_proc)
return;
- base::win::ScopedComPtr<IDWriteFactory> factory;
-
// Failure to create the DirectWrite factory indicates a corrupt dll.
if (FAILED(dwrite_create_factory_proc(
- DWRITE_FACTORY_TYPE_SHARED,
- __uuidof(IDWriteFactory),
- reinterpret_cast<IUnknown**>(factory.Receive()))))
+ DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory),
+ reinterpret_cast<IUnknown**>(factory_.Receive()))))
return;
// The skia call to create a new DirectWrite font manager instance can fail
@@ -95,17 +94,23 @@ void MaybeInitializeDirectWrite() {
// factory. The GetSystemFontCollection method in the IDWriteFactory
// interface fails with E_INVALIDARG on certain Windows 7 gold versions
// (6.1.7600.*). We should just use GDI in these cases.
- SkFontMgr* direct_write_font_mgr = SkFontMgr_New_DirectWrite(factory.get());
+ SkFontMgr* direct_write_font_mgr = SkFontMgr_New_DirectWrite(factory_.get());
if (!direct_write_font_mgr)
return;
dwrite_enabled = true;
SetDefaultSkiaFactory(direct_write_font_mgr);
- gfx::PlatformFontWin::SetDirectWriteFactory(factory.get());
+ gfx::PlatformFontWin::SetDirectWriteFactory(factory_.get());
}
bool IsDirectWriteEnabled() {
return dwrite_enabled;
}
+void GetDWriteFactory(IDWriteFactory** factory) {
+ MaybeInitializeDirectWrite();
+ base::win::ScopedComPtr<IDWriteFactory> factory_ref = factory_;
+ *factory = factory_ref.Detach();
+}
+
} // namespace win
} // namespace gfx
« no previous file with comments | « ui/gfx/win/direct_write.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698