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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 uint32_t index = family_index; | 238 uint32_t index = family_index; |
239 // CreateCustomFontCollection ends up calling | 239 // CreateCustomFontCollection ends up calling |
240 // DWriteFontCollectionProxy::CreateEnumeratorFromKey. | 240 // DWriteFontCollectionProxy::CreateEnumeratorFromKey. |
241 HRESULT hr = factory_->CreateCustomFontCollection( | 241 HRESULT hr = factory_->CreateCustomFontCollection( |
242 this /*collectionLoader*/, reinterpret_cast<const void*>(&index), | 242 this /*collectionLoader*/, reinterpret_cast<const void*>(&index), |
243 sizeof(index), containing_collection); | 243 sizeof(index), containing_collection); |
244 | 244 |
245 return SUCCEEDED(hr); | 245 return SUCCEEDED(hr); |
246 } | 246 } |
247 | 247 |
| 248 bool DWriteFontCollectionProxy::GetFontFamily(UINT32 family_index, |
| 249 const base::string16& family_name, |
| 250 IDWriteFontFamily** font_family) { |
| 251 DCHECK(font_family); |
| 252 DCHECK(!family_name.empty()); |
| 253 if (!CreateFamily(family_index)) |
| 254 return false; |
| 255 |
| 256 mswr::ComPtr<DWriteFontFamilyProxy>& family = families_[family_index]; |
| 257 if (!family->IsLoaded() || family->GetName().empty()) |
| 258 family->SetName(family_name); |
| 259 |
| 260 family.CopyTo(font_family); |
| 261 return true; |
| 262 } |
| 263 |
248 bool DWriteFontCollectionProxy::LoadFamilyNames( | 264 bool DWriteFontCollectionProxy::LoadFamilyNames( |
249 UINT32 family_index, | 265 UINT32 family_index, |
250 IDWriteLocalizedStrings** localized_strings) { | 266 IDWriteLocalizedStrings** localized_strings) { |
251 TRACE_EVENT0("dwrite", "FontProxy::LoadFamilyNames"); | 267 TRACE_EVENT0("dwrite", "FontProxy::LoadFamilyNames"); |
252 | 268 |
253 std::vector<std::pair<base::string16, base::string16>> strings; | 269 std::vector<std::pair<base::string16, base::string16>> strings; |
254 if (!GetSender()->Send( | 270 if (!GetSender()->Send( |
255 new DWriteFontProxyMsg_GetFamilyNames(family_index, &strings))) { | 271 new DWriteFontProxyMsg_GetFamilyNames(family_index, &strings))) { |
256 return false; | 272 return false; |
257 } | 273 } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 DCHECK(SUCCEEDED(hr)); | 413 DCHECK(SUCCEEDED(hr)); |
398 hr = collection->GetFontFromFontFace(font_face, font); | 414 hr = collection->GetFontFromFontFace(font_face, font); |
399 | 415 |
400 return SUCCEEDED(hr); | 416 return SUCCEEDED(hr); |
401 } | 417 } |
402 | 418 |
403 void DWriteFontFamilyProxy::SetName(const base::string16& family_name) { | 419 void DWriteFontFamilyProxy::SetName(const base::string16& family_name) { |
404 family_name_.assign(family_name); | 420 family_name_.assign(family_name); |
405 } | 421 } |
406 | 422 |
| 423 const base::string16& DWriteFontFamilyProxy::GetName() { |
| 424 return family_name_; |
| 425 } |
| 426 |
407 bool DWriteFontFamilyProxy::IsLoaded() { | 427 bool DWriteFontFamilyProxy::IsLoaded() { |
408 return family_ != nullptr; | 428 return family_ != nullptr; |
409 } | 429 } |
410 | 430 |
411 bool DWriteFontFamilyProxy::LoadFamily() { | 431 bool DWriteFontFamilyProxy::LoadFamily() { |
412 if (family_) | 432 if (family_) |
413 return true; | 433 return true; |
414 | 434 |
415 SCOPED_UMA_HISTOGRAM_TIMER("DirectWrite.Fonts.Proxy.LoadFamilyTime"); | 435 SCOPED_UMA_HISTOGRAM_TIMER("DirectWrite.Fonts.Proxy.LoadFamilyTime"); |
416 | 436 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 | 563 |
544 HRESULT FontFileStream::RuntimeClassInitialize( | 564 HRESULT FontFileStream::RuntimeClassInitialize( |
545 const base::string16& file_name) { | 565 const base::string16& file_name) { |
546 data_.Initialize(base::FilePath(file_name)); | 566 data_.Initialize(base::FilePath(file_name)); |
547 if (!data_.IsValid()) | 567 if (!data_.IsValid()) |
548 return E_FAIL; | 568 return E_FAIL; |
549 return S_OK; | 569 return S_OK; |
550 } | 570 } |
551 | 571 |
552 } // namespace content | 572 } // namespace content |
OLD | NEW |