| 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 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h" | 5 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 LOAD_FAMILY_SUCCESS_MATCHED_FAMILY = 1, | 35 LOAD_FAMILY_SUCCESS_MATCHED_FAMILY = 1, |
| 36 LOAD_FAMILY_ERROR_MULTIPLE_FAMILIES = 2, | 36 LOAD_FAMILY_ERROR_MULTIPLE_FAMILIES = 2, |
| 37 LOAD_FAMILY_ERROR_NO_FAMILIES = 3, | 37 LOAD_FAMILY_ERROR_NO_FAMILIES = 3, |
| 38 LOAD_FAMILY_ERROR_NO_COLLECTION = 4, | 38 LOAD_FAMILY_ERROR_NO_COLLECTION = 4, |
| 39 | 39 |
| 40 LOAD_FAMILY_MAX_VALUE | 40 LOAD_FAMILY_MAX_VALUE |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 const char kFontKeyName[] = "font_key_name"; | 43 const char kFontKeyName[] = "font_key_name"; |
| 44 | 44 |
| 45 const base::Feature kFileLoadingExperimentFeature{ | |
| 46 "DirectWriteFontFileLoadingExperiment", base::FEATURE_DISABLED_BY_DEFAULT}; | |
| 47 | |
| 48 void LogLoadFamilyResult(DirectWriteLoadFamilyResult result) { | 45 void LogLoadFamilyResult(DirectWriteLoadFamilyResult result) { |
| 49 UMA_HISTOGRAM_ENUMERATION("DirectWrite.Fonts.Proxy.LoadFamilyResult", result, | 46 UMA_HISTOGRAM_ENUMERATION("DirectWrite.Fonts.Proxy.LoadFamilyResult", result, |
| 50 LOAD_FAMILY_MAX_VALUE); | 47 LOAD_FAMILY_MAX_VALUE); |
| 51 } | 48 } |
| 52 | 49 |
| 53 } // namespace | 50 } // namespace |
| 54 | 51 |
| 55 DWriteFontCollectionProxy::DWriteFontCollectionProxy() = default; | 52 DWriteFontCollectionProxy::DWriteFontCollectionProxy() = default; |
| 56 | 53 |
| 57 DWriteFontCollectionProxy::~DWriteFontCollectionProxy() = default; | 54 DWriteFontCollectionProxy::~DWriteFontCollectionProxy() = default; |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 FontFileEnumerator::FontFileEnumerator() = default; | 477 FontFileEnumerator::FontFileEnumerator() = default; |
| 481 | 478 |
| 482 FontFileEnumerator::~FontFileEnumerator() = default; | 479 FontFileEnumerator::~FontFileEnumerator() = default; |
| 483 | 480 |
| 484 HRESULT FontFileEnumerator::GetCurrentFontFile(IDWriteFontFile** file) { | 481 HRESULT FontFileEnumerator::GetCurrentFontFile(IDWriteFontFile** file) { |
| 485 DCHECK(file); | 482 DCHECK(file); |
| 486 if (current_file_ >= file_names_.size()) { | 483 if (current_file_ >= file_names_.size()) { |
| 487 return E_FAIL; | 484 return E_FAIL; |
| 488 } | 485 } |
| 489 | 486 |
| 490 if (base::FeatureList::IsEnabled(kFileLoadingExperimentFeature)) { | 487 TRACE_EVENT0("dwrite", "FontFileEnumerator::GetCurrentFontFile"); |
| 491 TRACE_EVENT0("dwrite", | |
| 492 "FontFileEnumerator::GetCurrentFontFile (directwrite)"); | |
| 493 HRESULT hr = factory_->CreateFontFileReference( | |
| 494 file_names_[current_file_].c_str(), nullptr /* lastWriteTime*/, file); | |
| 495 DCHECK(SUCCEEDED(hr)); | |
| 496 return hr; | |
| 497 } | |
| 498 | |
| 499 TRACE_EVENT0("dwrite", "FontFileEnumerator::GetCurrentFontFile (memmap)"); | |
| 500 // CreateCustomFontFileReference ends up calling | 488 // CreateCustomFontFileReference ends up calling |
| 501 // DWriteFontCollectionProxy::CreateStreamFromKey. | 489 // DWriteFontCollectionProxy::CreateStreamFromKey. |
| 502 HRESULT hr = factory_->CreateCustomFontFileReference( | 490 HRESULT hr = factory_->CreateCustomFontFileReference( |
| 503 reinterpret_cast<const void*>(file_names_[current_file_].c_str()), | 491 reinterpret_cast<const void*>(file_names_[current_file_].c_str()), |
| 504 (file_names_[current_file_].length() + 1) * sizeof(base::char16), | 492 (file_names_[current_file_].length() + 1) * sizeof(base::char16), |
| 505 loader_.Get() /*IDWriteFontFileLoader*/, file); | 493 loader_.Get() /*IDWriteFontFileLoader*/, file); |
| 506 DCHECK(SUCCEEDED(hr)); | 494 DCHECK(SUCCEEDED(hr)); |
| 507 return hr; | 495 return hr; |
| 508 } | 496 } |
| 509 | 497 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 | 551 |
| 564 HRESULT FontFileStream::RuntimeClassInitialize( | 552 HRESULT FontFileStream::RuntimeClassInitialize( |
| 565 const base::string16& file_name) { | 553 const base::string16& file_name) { |
| 566 data_.Initialize(base::FilePath(file_name)); | 554 data_.Initialize(base::FilePath(file_name)); |
| 567 if (!data_.IsValid()) | 555 if (!data_.IsValid()) |
| 568 return E_FAIL; | 556 return E_FAIL; |
| 569 return S_OK; | 557 return S_OK; |
| 570 } | 558 } |
| 571 | 559 |
| 572 } // namespace content | 560 } // namespace content |
| OLD | NEW |