summaryrefslogtreecommitdiffstats
path: root/ui/gfx/win/direct_write.cc
diff options
context:
space:
mode:
Diffstat (limited to 'ui/gfx/win/direct_write.cc')
-rw-r--r--ui/gfx/win/direct_write.cc32
1 files changed, 19 insertions, 13 deletions
diff --git a/ui/gfx/win/direct_write.cc b/ui/gfx/win/direct_write.cc
index 38c926a..9c8250b 100644
--- a/ui/gfx/win/direct_write.cc
+++ b/ui/gfx/win/direct_write.cc
@@ -4,8 +4,6 @@
#include "ui/gfx/win/direct_write.h"
-#include <dwrite.h>
-
#include "base/basictypes.h"
#include "base/command_line.h"
#include "base/metrics/field_trial.h"
@@ -57,12 +55,7 @@ bool ShouldUseDirectWrite() {
return group_name != "Disabled";
}
-void MaybeInitializeDirectWrite() {
- static bool tried_dwrite_initialize = false;
- if (tried_dwrite_initialize)
- return;
- tried_dwrite_initialize = true;
-
+void CreateDWriteFactory(IDWriteFactory** factory) {
if (!ShouldUseDirectWrite() ||
base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableDirectWriteForUI)) {
@@ -81,13 +74,26 @@ void MaybeInitializeDirectWrite() {
if (!dwrite_create_factory_proc)
return;
+ // Failure to create the DirectWrite factory indicates a corrupt dll.
+ base::win::ScopedComPtr<IUnknown> factory_unknown;
+ if (FAILED(dwrite_create_factory_proc(DWRITE_FACTORY_TYPE_SHARED,
+ __uuidof(IDWriteFactory),
+ factory_unknown.Receive()))) {
+ return;
+ }
+ factory_unknown.QueryInterface<IDWriteFactory>(factory);
+}
+
+void MaybeInitializeDirectWrite() {
+ static bool tried_dwrite_initialize = false;
+ if (tried_dwrite_initialize)
+ return;
+ tried_dwrite_initialize = true;
+
base::win::ScopedComPtr<IDWriteFactory> factory;
+ CreateDWriteFactory(factory.Receive());
- // 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()))))
+ if (factory == nullptr)
return;
// The skia call to create a new DirectWrite font manager instance can fail