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

Side by Side Diff: content/child/dwrite_font_proxy/font_fallback_win.h

Issue 1906633003: Implement fallback cache (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@blinkfontfallback
Patch Set: Add some checks and comments Created 4 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
« no previous file with comments | « no previous file | content/child/dwrite_font_proxy/font_fallback_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_CHILD_DWRITE_FONT_PROXY_FONT_FALLBACK_WIN_H_ 5 #ifndef CONTENT_CHILD_DWRITE_FONT_PROXY_FONT_FALLBACK_WIN_H_
6 #define CONTENT_CHILD_DWRITE_FONT_PROXY_FONT_FALLBACK_WIN_H_ 6 #define CONTENT_CHILD_DWRITE_FONT_PROXY_FONT_FALLBACK_WIN_H_
7 7
8 #include <dwrite.h> 8 #include <dwrite.h>
9 #include <dwrite_2.h> 9 #include <dwrite_2.h>
10 #include <wrl.h> 10 #include <wrl.h>
11 11
12 #include <list>
13 #include <map>
14
12 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h" 15 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h"
13 #include "content/common/content_export.h" 16 #include "content/common/content_export.h"
14 #include "ipc/ipc_sender.h" 17 #include "ipc/ipc_sender.h"
15 18
16 namespace content { 19 namespace content {
17 20
18 // Implements an IDWriteFontFallback that uses IPC to proxy the fallback calls 21 // Implements an IDWriteFontFallback that uses IPC to proxy the fallback calls
19 // to the system fallback in the browser process. 22 // to the system fallback in the browser process.
20 class CONTENT_EXPORT FontFallback 23 class CONTENT_EXPORT FontFallback
21 : public Microsoft::WRL::RuntimeClass< 24 : public Microsoft::WRL::RuntimeClass<
(...skipping 15 matching lines...) Expand all
37 IDWriteFont** mapped_font, 40 IDWriteFont** mapped_font,
38 FLOAT* scale) override; 41 FLOAT* scale) override;
39 42
40 HRESULT STDMETHODCALLTYPE 43 HRESULT STDMETHODCALLTYPE
41 RuntimeClassInitialize(DWriteFontCollectionProxy* collection, 44 RuntimeClassInitialize(DWriteFontCollectionProxy* collection,
42 IPC::Sender* sender_override); 45 IPC::Sender* sender_override);
43 46
44 protected: 47 protected:
45 ~FontFallback() override; 48 ~FontFallback() override;
46 49
50 bool GetCachedFont(const base::string16& text,
51 const wchar_t* base_family_name,
52 DWRITE_FONT_WEIGHT base_weight,
53 DWRITE_FONT_STYLE base_style,
54 DWRITE_FONT_STRETCH base_stretch,
55 IDWriteFont** mapped_font,
56 uint32_t* mapped_length);
57
58 void AddCachedFamily(Microsoft::WRL::ComPtr<IDWriteFontFamily> family,
59 const wchar_t* base_family_name);
60
47 private: 61 private:
48 IPC::Sender* sender_override_; 62 IPC::Sender* sender_override_;
49 Microsoft::WRL::ComPtr<DWriteFontCollectionProxy> collection_; 63 Microsoft::WRL::ComPtr<DWriteFontCollectionProxy> collection_;
50 64
65 // |fallback_family_cache_| keeps a mapping from base family name to a list
66 // of font families that matched a character on a previous call. The list is
67 // capped in size and maintained in MRU order. This gives us a good chance of
68 // returning a suitable fallback font without having to do an IPC.
69 std::map<base::string16, std::list<Microsoft::WRL::ComPtr<IDWriteFontFamily>>>
70 fallback_family_cache_;
71
51 DISALLOW_ASSIGN(FontFallback); 72 DISALLOW_ASSIGN(FontFallback);
52 }; 73 };
53 74
54 } // namespace content 75 } // namespace content
55 76
56 #endif // CONTENT_CHILD_DWRITE_FONT_PROXY_FONT_FALLBACK_WIN_H_ 77 #endif // CONTENT_CHILD_DWRITE_FONT_PROXY_FONT_FALLBACK_WIN_H_
OLDNEW
« no previous file with comments | « no previous file | content/child/dwrite_font_proxy/font_fallback_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698