OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "content/common/font_warmup_win.h" | 5 #include "content/common/font_warmup_win.h" |
6 | 6 |
7 #include <dwrite.h> | 7 #include <dwrite.h> |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/debug/alias.h" | 10 #include "base/debug/alias.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 PROC* function_ptr = &vtable[kGetSystemFontCollectionVTableIndex]; | 192 PROC* function_ptr = &vtable[kGetSystemFontCollectionVTableIndex]; |
193 void* stub_function = &StubFontCollection; | 193 void* stub_function = &StubFontCollection; |
194 base::win::ModifyCode(function_ptr, &stub_function, sizeof(PROC)); | 194 base::win::ModifyCode(function_ptr, &stub_function, sizeof(PROC)); |
195 } | 195 } |
196 | 196 |
197 // Class to fake out a DC or a Font object. Maintains a reference to a | 197 // Class to fake out a DC or a Font object. Maintains a reference to a |
198 // SkTypeFace to emulate the simple operation of a DC and Font. | 198 // SkTypeFace to emulate the simple operation of a DC and Font. |
199 class FakeGdiObject : public base::RefCountedThreadSafe<FakeGdiObject> { | 199 class FakeGdiObject : public base::RefCountedThreadSafe<FakeGdiObject> { |
200 public: | 200 public: |
201 FakeGdiObject(uint32_t magic, void* handle) | 201 FakeGdiObject(uint32_t magic, void* handle) |
202 : magic_(magic), handle_(handle) {} | 202 : handle_(handle), magic_(magic) {} |
203 ~FakeGdiObject() {} | |
204 | 203 |
205 void set_typeface(const skia::RefPtr<SkTypeface>& typeface) { | 204 void set_typeface(const skia::RefPtr<SkTypeface>& typeface) { |
206 typeface_ = typeface; | 205 typeface_ = typeface; |
207 } | 206 } |
208 | 207 |
209 skia::RefPtr<SkTypeface> typeface() { return typeface_; } | 208 skia::RefPtr<SkTypeface> typeface() { return typeface_; } |
210 void* handle() { return handle_; } | 209 void* handle() { return handle_; } |
211 uint32_t magic() { return magic_; } | 210 uint32_t magic() { return magic_; } |
212 | 211 |
213 private: | 212 private: |
214 friend class base::RefCountedThreadSafe<FakeGdiObject>; | 213 friend class base::RefCountedThreadSafe<FakeGdiObject>; |
| 214 ~FakeGdiObject() {} |
215 | 215 |
216 void* handle_; | 216 void* handle_; |
217 uint32_t magic_; | 217 uint32_t magic_; |
218 skia::RefPtr<SkTypeface> typeface_; | 218 skia::RefPtr<SkTypeface> typeface_; |
219 | 219 |
220 DISALLOW_COPY_AND_ASSIGN(FakeGdiObject); | 220 DISALLOW_COPY_AND_ASSIGN(FakeGdiObject); |
221 }; | 221 }; |
222 | 222 |
223 // This class acts as a factory for creating new fake GDI objects. It also maps | 223 // This class acts as a factory for creating new fake GDI objects. It also maps |
224 // the new instances of the FakeGdiObject class to an incrementing handle value | 224 // the new instances of the FakeGdiObject class to an incrementing handle value |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 if (!dc_obj) | 346 if (!dc_obj) |
347 return 1; | 347 return 1; |
348 | 348 |
349 if (!log_font || !enum_callback) | 349 if (!log_font || !enum_callback) |
350 return 1; | 350 return 1; |
351 | 351 |
352 skia::RefPtr<SkTypeface> typeface = GetTypefaceFromLOGFONT(log_font); | 352 skia::RefPtr<SkTypeface> typeface = GetTypefaceFromLOGFONT(log_font); |
353 if (!typeface) | 353 if (!typeface) |
354 return 1; | 354 return 1; |
355 | 355 |
356 ENUMLOGFONTEXDVW enum_log_font = {0}; | 356 ENUMLOGFONTEXDVW enum_log_font = {}; |
357 enum_log_font.elfEnumLogfontEx.elfLogFont = *log_font; | 357 enum_log_font.elfEnumLogfontEx.elfLogFont = *log_font; |
358 // TODO: Fill in the rest of the text metric structure. Not yet needed for | 358 // TODO: Fill in the rest of the text metric structure. Not yet needed for |
359 // Flash support but might be in the future. | 359 // Flash support but might be in the future. |
360 NEWTEXTMETRICEXW text_metric = {0}; | 360 NEWTEXTMETRICEXW text_metric = {}; |
361 text_metric.ntmTm.ntmFlags = NTM_PS_OPENTYPE; | 361 text_metric.ntmTm.ntmFlags = NTM_PS_OPENTYPE; |
362 | 362 |
363 return enum_callback(&enum_log_font.elfEnumLogfontEx.elfLogFont, | 363 return enum_callback(&enum_log_font.elfEnumLogfontEx.elfLogFont, |
364 reinterpret_cast<TEXTMETRIC*>(&text_metric), | 364 reinterpret_cast<TEXTMETRIC*>(&text_metric), |
365 TRUETYPE_FONTTYPE, callback_param); | 365 TRUETYPE_FONTTYPE, callback_param); |
366 } | 366 } |
367 | 367 |
368 DWORD WINAPI GetFontDataPatch(HDC dc_handle, | 368 DWORD WINAPI GetFontDataPatch(HDC dc_handle, |
369 DWORD table_tag, | 369 DWORD table_tag, |
370 DWORD table_offset, | 370 DWORD table_offset, |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 // down for the CC HUD code, so use the same one here. Note that we don't use | 509 // down for the CC HUD code, so use the same one here. Note that we don't use |
510 // a monospace as would be nice in an attempt to avoid a small startup time | 510 // a monospace as would be nice in an attempt to avoid a small startup time |
511 // regression, see http://crbug.com/463613. | 511 // regression, see http://crbug.com/463613. |
512 skia::RefPtr<SkTypeface> hud_typeface = skia::AdoptRef( | 512 skia::RefPtr<SkTypeface> hud_typeface = skia::AdoptRef( |
513 GetPreSandboxWarmupFontMgr()->legacyCreateTypeface("Times New Roman", 0)); | 513 GetPreSandboxWarmupFontMgr()->legacyCreateTypeface("Times New Roman", 0)); |
514 DoPreSandboxWarmupForTypeface(hud_typeface.get()); | 514 DoPreSandboxWarmupForTypeface(hud_typeface.get()); |
515 gfx::SetHudTypeface(hud_typeface); | 515 gfx::SetHudTypeface(hud_typeface); |
516 } | 516 } |
517 | 517 |
518 } // namespace content | 518 } // namespace content |
OLD | NEW |