Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 74 // Gets the family at the specified index with the expected name. This can be | 75 // Gets the family at the specified index with the expected name. This can be |
| 75 // used to avoid an IPC call when both the index and family name are known. | 76 // used to avoid an IPC call when both the index and family name are known. |
| 76 bool GetFontFamily(UINT32 family_index, | 77 bool GetFontFamily(UINT32 family_index, |
| 77 const base::string16& family_name, | 78 const base::string16& family_name, |
| 78 IDWriteFontFamily** font_family); | 79 IDWriteFontFamily** font_family); |
| 79 | 80 |
| 80 bool LoadFamilyNames(UINT32 family_index, IDWriteLocalizedStrings** strings); | 81 bool LoadFamilyNames(UINT32 family_index, IDWriteLocalizedStrings** strings); |
| 81 | 82 |
| 82 bool CreateFamily(UINT32 family_index); | 83 bool CreateFamily(UINT32 family_index); |
| 83 | 84 |
| 85 size_t CreateFontFileReference(base::string16 file_path); | |
|
ananta
2016/07/20 01:34:59
Newline between functions. Please use different na
Ilya Kulshin
2016/07/21 04:17:37
Removed this code due to a refactor.
| |
| 86 size_t CreateFontFileReference(HANDLE file_handle); | |
| 87 | |
| 84 private: | 88 private: |
| 89 class FontFileReference { | |
|
ananta
2016/07/20 01:34:59
Please add some comments for this class.
Ilya Kulshin
2016/07/21 04:17:38
Removed this class due to a refactor.
| |
| 90 public: | |
| 91 enum ReferenceType { | |
| 92 INVALID, | |
| 93 PATH, | |
| 94 FILE, | |
| 95 }; | |
| 96 | |
| 97 explicit FontFileReference(base::string16 file_path); | |
|
ananta
2016/07/20 01:34:59
const reference for string16.
Ilya Kulshin
2016/07/21 04:17:37
Done.
| |
| 98 explicit FontFileReference(HANDLE file_handle); | |
| 99 | |
| 100 ReferenceType Type() const { return reference_type_; } | |
| 101 const base::string16* Path() const { | |
|
ananta
2016/07/20 01:34:59
newline
Ilya Kulshin
2016/07/21 04:17:37
Done.
| |
| 102 DCHECK_EQ(Type(), PATH); | |
| 103 return &file_path_; | |
| 104 } | |
| 105 const base::File* File() const { | |
|
ananta
2016/07/20 01:34:59
newline
Ilya Kulshin
2016/07/21 04:17:38
Done.
| |
| 106 DCHECK_EQ(Type(), FILE); | |
| 107 return &file_; | |
| 108 } | |
| 109 | |
| 110 private: | |
| 111 ReferenceType reference_type_; | |
| 112 base::string16 file_path_; | |
| 113 base::File file_; | |
| 114 }; | |
| 115 | |
| 85 IPC::Sender* GetSender(); | 116 IPC::Sender* GetSender(); |
| 86 | 117 |
| 87 Microsoft::WRL::ComPtr<IDWriteFactory> factory_; | 118 Microsoft::WRL::ComPtr<IDWriteFactory> factory_; |
| 88 std::vector<Microsoft::WRL::ComPtr<DWriteFontFamilyProxy>> families_; | 119 std::vector<Microsoft::WRL::ComPtr<DWriteFontFamilyProxy>> families_; |
| 89 std::map<base::string16, UINT32> family_names_; | 120 std::map<base::string16, UINT32> family_names_; |
| 90 UINT32 family_count_ = UINT_MAX; | 121 UINT32 family_count_ = UINT_MAX; |
| 91 IPC::Sender* sender_override_; | 122 IPC::Sender* sender_override_; |
| 92 | 123 |
| 124 std::deque<FontFileReference> font_files_; | |
| 125 | |
| 93 DISALLOW_ASSIGN(DWriteFontCollectionProxy); | 126 DISALLOW_ASSIGN(DWriteFontCollectionProxy); |
| 94 }; | 127 }; |
| 95 | 128 |
| 96 // Implements the DirectWrite font family interface. This class is just a | 129 // Implements the DirectWrite font family interface. This class is just a |
| 97 // stub, until something calls a method that requires actual font data. At that | 130 // stub, until something calls a method that requires actual font data. At that |
| 98 // point this will load the font files into a custom collection and | 131 // point this will load the font files into a custom collection and |
| 99 // subsequently calls will be proxied to the resulting DirectWrite object. | 132 // subsequently calls will be proxied to the resulting DirectWrite object. |
| 100 class CONTENT_EXPORT DWriteFontFamilyProxy | 133 class CONTENT_EXPORT DWriteFontFamilyProxy |
| 101 : public Microsoft::WRL::RuntimeClass< | 134 : public Microsoft::WRL::RuntimeClass< |
| 102 Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, | 135 Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 157 FontFileEnumerator(); | 190 FontFileEnumerator(); |
| 158 ~FontFileEnumerator() override; | 191 ~FontFileEnumerator() override; |
| 159 | 192 |
| 160 // IDWriteFontFileEnumerator: | 193 // IDWriteFontFileEnumerator: |
| 161 HRESULT STDMETHODCALLTYPE GetCurrentFontFile(IDWriteFontFile** file) override; | 194 HRESULT STDMETHODCALLTYPE GetCurrentFontFile(IDWriteFontFile** file) override; |
| 162 HRESULT STDMETHODCALLTYPE MoveNext(BOOL* has_current_file) override; | 195 HRESULT STDMETHODCALLTYPE MoveNext(BOOL* has_current_file) override; |
| 163 | 196 |
| 164 HRESULT STDMETHODCALLTYPE | 197 HRESULT STDMETHODCALLTYPE |
| 165 RuntimeClassInitialize(IDWriteFactory* factory, | 198 RuntimeClassInitialize(IDWriteFactory* factory, |
| 166 IDWriteFontFileLoader* loader, | 199 IDWriteFontFileLoader* loader, |
| 167 std::vector<base::string16>* file_names); | 200 std::vector<size_t>* file_references); |
| 168 | 201 |
| 169 private: | 202 private: |
| 170 Microsoft::WRL::ComPtr<IDWriteFactory> factory_; | 203 Microsoft::WRL::ComPtr<IDWriteFactory> factory_; |
| 171 Microsoft::WRL::ComPtr<IDWriteFontFileLoader> loader_; | 204 Microsoft::WRL::ComPtr<IDWriteFontFileLoader> loader_; |
| 172 std::vector<base::string16> file_names_; | 205 std::vector<size_t> file_references_; |
|
nasko
2016/07/20 16:40:03
Since this is Windows specific code, why not use H
Ilya Kulshin
2016/07/21 04:17:38
Done.
| |
| 173 std::vector<Microsoft::WRL::ComPtr<IDWriteFontFileStream>> file_streams_; | |
| 174 UINT32 next_file_ = 0; | 206 UINT32 next_file_ = 0; |
| 175 UINT32 current_file_ = UINT_MAX; | 207 UINT32 current_file_ = UINT_MAX; |
| 176 | 208 |
| 177 DISALLOW_ASSIGN(FontFileEnumerator); | 209 DISALLOW_ASSIGN(FontFileEnumerator); |
| 178 }; | 210 }; |
| 179 | 211 |
| 180 // Implements the DirectWrite font file stream interface that maps the file to | 212 // 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 | 213 // be loaded as a memory mapped file, and subsequently returns pointers into |
| 182 // the mapped memory block. | 214 // the mapped memory block. |
| 183 class CONTENT_EXPORT FontFileStream | 215 class CONTENT_EXPORT FontFileStream |
| 184 : public Microsoft::WRL::RuntimeClass< | 216 : public Microsoft::WRL::RuntimeClass< |
| 185 Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, | 217 Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, |
| 186 IDWriteFontFileStream> { | 218 IDWriteFontFileStream> { |
| 187 public: | 219 public: |
| 188 FontFileStream(); | 220 FontFileStream(); |
| 189 ~FontFileStream() override; | 221 ~FontFileStream() override; |
| 190 | 222 |
| 191 // IDWriteFontFileStream: | 223 // IDWriteFontFileStream: |
| 192 HRESULT STDMETHODCALLTYPE GetFileSize(UINT64* file_size) override; | 224 HRESULT STDMETHODCALLTYPE GetFileSize(UINT64* file_size) override; |
| 193 HRESULT STDMETHODCALLTYPE GetLastWriteTime(UINT64* last_write_time) override; | 225 HRESULT STDMETHODCALLTYPE GetLastWriteTime(UINT64* last_write_time) override; |
| 194 HRESULT STDMETHODCALLTYPE ReadFileFragment(const void** fragment_start, | 226 HRESULT STDMETHODCALLTYPE ReadFileFragment(const void** fragment_start, |
| 195 UINT64 file_offset, | 227 UINT64 file_offset, |
| 196 UINT64 fragment_size, | 228 UINT64 fragment_size, |
| 197 void** fragment_context) override; | 229 void** fragment_context) override; |
| 198 void STDMETHODCALLTYPE ReleaseFileFragment(void* fragment_context) override {} | 230 void STDMETHODCALLTYPE ReleaseFileFragment(void* fragment_context) override {} |
| 199 | 231 |
| 200 HRESULT STDMETHODCALLTYPE | 232 HRESULT STDMETHODCALLTYPE |
| 201 RuntimeClassInitialize(const base::string16& file_name); | 233 RuntimeClassInitialize(const base::string16* file_name); |
| 234 HRESULT STDMETHODCALLTYPE RuntimeClassInitialize(const base::File* file); | |
| 202 | 235 |
| 203 private: | 236 private: |
| 204 base::MemoryMappedFile data_; | 237 base::MemoryMappedFile data_; |
| 205 | 238 |
| 206 DISALLOW_ASSIGN(FontFileStream); | 239 DISALLOW_ASSIGN(FontFileStream); |
| 207 }; | 240 }; |
| 208 | 241 |
| 209 } // namespace content | 242 } // namespace content |
| 210 #endif // CONTENT_CHILD_DWRITE_FONT_PROXY_DWRITE_FONT_PROXY_WIN_H_ | 243 #endif // CONTENT_CHILD_DWRITE_FONT_PROXY_DWRITE_FONT_PROXY_WIN_H_ |
| OLD | NEW |