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

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

Issue 2153343002: Implement support for loading font files from outside system directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test patchset to run try job Created 4 years, 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_DWRITE_FONT_PROXY_WIN_H_ 5 #ifndef CONTENT_CHILD_DWRITE_FONT_PROXY_DWRITE_FONT_PROXY_WIN_H_
6 #define CONTENT_CHILD_DWRITE_FONT_PROXY_DWRITE_FONT_PROXY_WIN_H_ 6 #define CONTENT_CHILD_DWRITE_FONT_PROXY_DWRITE_FONT_PROXY_WIN_H_
7 7
8 #include <dwrite.h> 8 #include <dwrite.h>
9 #include <wrl.h> 9 #include <wrl.h>
10 10
11 #include <deque>
11 #include <map> 12 #include <map>
12 #include <vector> 13 #include <vector>
13 14
14 #include "base/callback.h" 15 #include "base/callback.h"
15 #include "base/files/memory_mapped_file.h" 16 #include "base/files/memory_mapped_file.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/strings/string16.h" 18 #include "base/strings/string16.h"
18 #include "content/common/content_export.h" 19 #include "content/common/content_export.h"
19 20
20 namespace IPC { 21 namespace IPC {
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 FontFileEnumerator(); 158 FontFileEnumerator();
158 ~FontFileEnumerator() override; 159 ~FontFileEnumerator() override;
159 160
160 // IDWriteFontFileEnumerator: 161 // IDWriteFontFileEnumerator:
161 HRESULT STDMETHODCALLTYPE GetCurrentFontFile(IDWriteFontFile** file) override; 162 HRESULT STDMETHODCALLTYPE GetCurrentFontFile(IDWriteFontFile** file) override;
162 HRESULT STDMETHODCALLTYPE MoveNext(BOOL* has_current_file) override; 163 HRESULT STDMETHODCALLTYPE MoveNext(BOOL* has_current_file) override;
163 164
164 HRESULT STDMETHODCALLTYPE 165 HRESULT STDMETHODCALLTYPE
165 RuntimeClassInitialize(IDWriteFactory* factory, 166 RuntimeClassInitialize(IDWriteFactory* factory,
166 IDWriteFontFileLoader* loader, 167 IDWriteFontFileLoader* loader,
167 std::vector<base::string16>* file_names); 168 std::vector<HANDLE>* files);
168 169
169 private: 170 private:
170 Microsoft::WRL::ComPtr<IDWriteFactory> factory_; 171 Microsoft::WRL::ComPtr<IDWriteFactory> factory_;
171 Microsoft::WRL::ComPtr<IDWriteFontFileLoader> loader_; 172 Microsoft::WRL::ComPtr<IDWriteFontFileLoader> loader_;
172 std::vector<base::string16> file_names_; 173 std::vector<HANDLE> files_;
173 std::vector<Microsoft::WRL::ComPtr<IDWriteFontFileStream>> file_streams_;
174 UINT32 next_file_ = 0; 174 UINT32 next_file_ = 0;
175 UINT32 current_file_ = UINT_MAX; 175 UINT32 current_file_ = UINT_MAX;
176 176
177 DISALLOW_ASSIGN(FontFileEnumerator); 177 DISALLOW_ASSIGN(FontFileEnumerator);
178 }; 178 };
179 179
180 // Implements the DirectWrite font file stream interface that maps the file to 180 // Implements the DirectWrite font file stream interface that maps the file to
181 // be loaded as a memory mapped file, and subsequently returns pointers into 181 // be loaded as a memory mapped file, and subsequently returns pointers into
182 // the mapped memory block. 182 // the mapped memory block.
183 class CONTENT_EXPORT FontFileStream 183 class CONTENT_EXPORT FontFileStream
184 : public Microsoft::WRL::RuntimeClass< 184 : public Microsoft::WRL::RuntimeClass<
185 Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, 185 Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>,
186 IDWriteFontFileStream> { 186 IDWriteFontFileStream> {
187 public: 187 public:
188 FontFileStream(); 188 FontFileStream();
189 ~FontFileStream() override; 189 ~FontFileStream() override;
190 190
191 // IDWriteFontFileStream: 191 // IDWriteFontFileStream:
192 HRESULT STDMETHODCALLTYPE GetFileSize(UINT64* file_size) override; 192 HRESULT STDMETHODCALLTYPE GetFileSize(UINT64* file_size) override;
193 HRESULT STDMETHODCALLTYPE GetLastWriteTime(UINT64* last_write_time) override; 193 HRESULT STDMETHODCALLTYPE GetLastWriteTime(UINT64* last_write_time) override;
194 HRESULT STDMETHODCALLTYPE ReadFileFragment(const void** fragment_start, 194 HRESULT STDMETHODCALLTYPE ReadFileFragment(const void** fragment_start,
195 UINT64 file_offset, 195 UINT64 file_offset,
196 UINT64 fragment_size, 196 UINT64 fragment_size,
197 void** fragment_context) override; 197 void** fragment_context) override;
198 void STDMETHODCALLTYPE ReleaseFileFragment(void* fragment_context) override {} 198 void STDMETHODCALLTYPE ReleaseFileFragment(void* fragment_context) override {}
199 199
200 HRESULT STDMETHODCALLTYPE 200 HRESULT STDMETHODCALLTYPE RuntimeClassInitialize(HANDLE handle);
201 RuntimeClassInitialize(const base::string16& file_name);
202 201
203 private: 202 private:
204 base::MemoryMappedFile data_; 203 base::MemoryMappedFile data_;
205 204
206 DISALLOW_ASSIGN(FontFileStream); 205 DISALLOW_ASSIGN(FontFileStream);
207 }; 206 };
208 207
209 } // namespace content 208 } // namespace content
210 #endif // CONTENT_CHILD_DWRITE_FONT_PROXY_DWRITE_FONT_PROXY_WIN_H_ 209 #endif // CONTENT_CHILD_DWRITE_FONT_PROXY_DWRITE_FONT_PROXY_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698