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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 uint32_t index = family_index; | 234 uint32_t index = family_index; |
235 // CreateCustomFontCollection ends up calling | 235 // CreateCustomFontCollection ends up calling |
236 // DWriteFontCollectionProxy::CreateEnumeratorFromKey. | 236 // DWriteFontCollectionProxy::CreateEnumeratorFromKey. |
237 HRESULT hr = factory_->CreateCustomFontCollection( | 237 HRESULT hr = factory_->CreateCustomFontCollection( |
238 this /*collectionLoader*/, reinterpret_cast<const void*>(&index), | 238 this /*collectionLoader*/, reinterpret_cast<const void*>(&index), |
239 sizeof(index), containing_collection); | 239 sizeof(index), containing_collection); |
240 | 240 |
241 return SUCCEEDED(hr); | 241 return SUCCEEDED(hr); |
242 } | 242 } |
243 | 243 |
| 244 bool DWriteFontCollectionProxy::GetFontFamily(UINT32 family_index, |
| 245 const base::string16& family_name, |
| 246 IDWriteFontFamily** font_family) { |
| 247 DCHECK(font_family); |
| 248 DCHECK(!family_name.empty()); |
| 249 if (!CreateFamily(family_index)) |
| 250 return false; |
| 251 |
| 252 mswr::ComPtr<DWriteFontFamilyProxy>& family = families_[family_index]; |
| 253 if (!family->IsLoaded() || family->GetName().empty()) |
| 254 family->SetName(family_name); |
| 255 |
| 256 family.CopyTo(font_family); |
| 257 return true; |
| 258 } |
| 259 |
244 bool DWriteFontCollectionProxy::LoadFamilyNames( | 260 bool DWriteFontCollectionProxy::LoadFamilyNames( |
245 UINT32 family_index, | 261 UINT32 family_index, |
246 IDWriteLocalizedStrings** localized_strings) { | 262 IDWriteLocalizedStrings** localized_strings) { |
247 TRACE_EVENT0("dwrite", "FontProxy::LoadFamilyNames"); | 263 TRACE_EVENT0("dwrite", "FontProxy::LoadFamilyNames"); |
248 | 264 |
249 std::vector<std::pair<base::string16, base::string16>> strings; | 265 std::vector<std::pair<base::string16, base::string16>> strings; |
250 if (!GetSender()->Send( | 266 if (!GetSender()->Send( |
251 new DWriteFontProxyMsg_GetFamilyNames(family_index, &strings))) { | 267 new DWriteFontProxyMsg_GetFamilyNames(family_index, &strings))) { |
252 return false; | 268 return false; |
253 } | 269 } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 DCHECK(SUCCEEDED(hr)); | 409 DCHECK(SUCCEEDED(hr)); |
394 hr = collection->GetFontFromFontFace(font_face, font); | 410 hr = collection->GetFontFromFontFace(font_face, font); |
395 | 411 |
396 return SUCCEEDED(hr); | 412 return SUCCEEDED(hr); |
397 } | 413 } |
398 | 414 |
399 void DWriteFontFamilyProxy::SetName(const base::string16& family_name) { | 415 void DWriteFontFamilyProxy::SetName(const base::string16& family_name) { |
400 family_name_.assign(family_name); | 416 family_name_.assign(family_name); |
401 } | 417 } |
402 | 418 |
| 419 const base::string16& DWriteFontFamilyProxy::GetName() { |
| 420 return family_name_; |
| 421 } |
| 422 |
403 bool DWriteFontFamilyProxy::IsLoaded() { | 423 bool DWriteFontFamilyProxy::IsLoaded() { |
404 return family_ != nullptr; | 424 return family_ != nullptr; |
405 } | 425 } |
406 | 426 |
407 bool DWriteFontFamilyProxy::LoadFamily() { | 427 bool DWriteFontFamilyProxy::LoadFamily() { |
408 if (family_) | 428 if (family_) |
409 return true; | 429 return true; |
410 | 430 |
411 SCOPED_UMA_HISTOGRAM_TIMER("DirectWrite.Fonts.Proxy.LoadFamilyTime"); | 431 SCOPED_UMA_HISTOGRAM_TIMER("DirectWrite.Fonts.Proxy.LoadFamilyTime"); |
412 | 432 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 | 550 |
531 HRESULT FontFileStream::RuntimeClassInitialize( | 551 HRESULT FontFileStream::RuntimeClassInitialize( |
532 const base::string16& file_name) { | 552 const base::string16& file_name) { |
533 data_.Initialize(base::FilePath(file_name)); | 553 data_.Initialize(base::FilePath(file_name)); |
534 if (!data_.IsValid()) | 554 if (!data_.IsValid()) |
535 return E_FAIL; | 555 return E_FAIL; |
536 return S_OK; | 556 return S_OK; |
537 } | 557 } |
538 | 558 |
539 } // namespace content | 559 } // namespace content |
OLD | NEW |