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

Unified Diff: content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc

Issue 1682813004: Revert of Add plumbing in blink to allow overriding the default font collection. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 | content/child/font_warmup_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc
diff --git a/content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc b/content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc
index f71e0d81143fc7c8720a7f7da927338aca506e40..9ffd8dd36c62bbfaab2b5b5bfe8ae63897a9a1ba 100644
--- a/content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc
+++ b/content/child/dwrite_font_proxy/dwrite_font_proxy_init_win.cc
@@ -14,9 +14,7 @@
#include "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h"
#include "content/child/font_warmup_win.h"
#include "skia/ext/fontmgr_default_win.h"
-#include "skia/ext/refptr.h"
#include "third_party/WebKit/public/web/win/WebFontRendering.h"
-#include "third_party/skia/include/ports/SkFontMgr.h"
#include "third_party/skia/include/ports/SkTypeface_win.h"
namespace mswr = Microsoft::WRL;
@@ -60,6 +58,24 @@
reinterpret_cast<IUnknown**>(factory))));
}
+HRESULT STDMETHODCALLTYPE StubFontCollection(IDWriteFactory* factory,
+ IDWriteFontCollection** col,
+ BOOL checkUpdates) {
+ DCHECK(g_font_collection);
+ g_font_collection.CopyTo(col);
+ return S_OK;
+}
+
+// Copied from content/common/font_warmup_win.cc
+void PatchDWriteFactory(IDWriteFactory* factory) {
+ const unsigned int kGetSystemFontCollectionVTableIndex = 3;
+
+ PROC* vtable = *reinterpret_cast<PROC**>(factory);
+ PROC* function_ptr = &vtable[kGetSystemFontCollectionVTableIndex];
+ void* stub_function = &StubFontCollection;
+ base::win::ModifyCode(function_ptr, &stub_function, sizeof(PROC));
+}
+
// Needed as a function for Bind()
IPC::Sender* GetSenderOverride() {
return g_sender_override;
@@ -83,14 +99,11 @@
}
}
- skia::RefPtr<SkFontMgr> skia_font_manager = skia::AdoptRef(
- SkFontMgr_New_DirectWrite(factory.Get(), g_font_collection.Get()));
- blink::WebFontRendering::setSkiaFontManager(skia_font_manager.get());
+ PatchDWriteFactory(factory.Get());
- // Add an extra ref for SetDefaultSkiaFactory, which keeps a ref but doesn't
- // addref.
- skia_font_manager->ref();
- SetDefaultSkiaFactory(skia_font_manager.get());
+ blink::WebFontRendering::setDirectWriteFactory(factory.Get());
+ SkFontMgr* skia_font_manager = SkFontMgr_New_DirectWrite(factory.Get());
+ SetDefaultSkiaFactory(skia_font_manager);
}
void UninitializeDWriteFontProxy() {
« no previous file with comments | « no previous file | content/child/font_warmup_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698