| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 Google Inc. | 2 * Copyright 2014 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkTypes.h" | 8 #include "SkTypes.h" |
| 9 #if defined(SK_BUILD_FOR_WIN32) | 9 #if defined(SK_BUILD_FOR_WIN32) |
| 10 | 10 |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 same = (iunkA.get() == iunkB.get()); | 346 same = (iunkA.get() == iunkB.get()); |
| 347 return S_OK; | 347 return S_OK; |
| 348 } | 348 } |
| 349 | 349 |
| 350 struct ProtoDWriteTypeface { | 350 struct ProtoDWriteTypeface { |
| 351 IDWriteFontFace* fDWriteFontFace; | 351 IDWriteFontFace* fDWriteFontFace; |
| 352 IDWriteFont* fDWriteFont; | 352 IDWriteFont* fDWriteFont; |
| 353 IDWriteFontFamily* fDWriteFontFamily; | 353 IDWriteFontFamily* fDWriteFontFamily; |
| 354 }; | 354 }; |
| 355 | 355 |
| 356 static bool FindByDWriteFont(SkTypeface* cached, const SkFontStyle&, void* ctx)
{ | 356 static bool FindByDWriteFont(SkTypeface* cached, void* ctx) { |
| 357 DWriteFontTypeface* cshFace = reinterpret_cast<DWriteFontTypeface*>(cached); | 357 DWriteFontTypeface* cshFace = reinterpret_cast<DWriteFontTypeface*>(cached); |
| 358 ProtoDWriteTypeface* ctxFace = reinterpret_cast<ProtoDWriteTypeface*>(ctx); | 358 ProtoDWriteTypeface* ctxFace = reinterpret_cast<ProtoDWriteTypeface*>(ctx); |
| 359 bool same; | 359 bool same; |
| 360 | 360 |
| 361 //Check to see if the two fonts are identical. | 361 //Check to see if the two fonts are identical. |
| 362 HRB(are_same(cshFace->fDWriteFont.get(), ctxFace->fDWriteFont, same)); | 362 HRB(are_same(cshFace->fDWriteFont.get(), ctxFace->fDWriteFont, same)); |
| 363 if (same) { | 363 if (same) { |
| 364 return true; | 364 return true; |
| 365 } | 365 } |
| 366 | 366 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 SkTypeface* SkFontMgr_DirectWrite::createTypefaceFromDWriteFont( | 450 SkTypeface* SkFontMgr_DirectWrite::createTypefaceFromDWriteFont( |
| 451 IDWriteFontFace* fontFace, | 451 IDWriteFontFace* fontFace, |
| 452 IDWriteFont* font, | 452 IDWriteFont* font, |
| 453 IDWriteFontFamily* fontFamily) const { | 453 IDWriteFontFamily* fontFamily) const { |
| 454 SkAutoMutexAcquire ama(fTFCacheMutex); | 454 SkAutoMutexAcquire ama(fTFCacheMutex); |
| 455 ProtoDWriteTypeface spec = { fontFace, font, fontFamily }; | 455 ProtoDWriteTypeface spec = { fontFace, font, fontFamily }; |
| 456 SkTypeface* face = fTFCache.findByProcAndRef(FindByDWriteFont, &spec); | 456 SkTypeface* face = fTFCache.findByProcAndRef(FindByDWriteFont, &spec); |
| 457 if (nullptr == face) { | 457 if (nullptr == face) { |
| 458 face = DWriteFontTypeface::Create(fFactory.get(), fontFace, font, fontFa
mily); | 458 face = DWriteFontTypeface::Create(fFactory.get(), fontFace, font, fontFa
mily); |
| 459 if (face) { | 459 if (face) { |
| 460 fTFCache.add(face, get_style(font)); | 460 fTFCache.add(face); |
| 461 } | 461 } |
| 462 } | 462 } |
| 463 return face; | 463 return face; |
| 464 } | 464 } |
| 465 | 465 |
| 466 int SkFontMgr_DirectWrite::onCountFamilies() const { | 466 int SkFontMgr_DirectWrite::onCountFamilies() const { |
| 467 return fFontCollection->GetFontFamilyCount(); | 467 return fFontCollection->GetFontFamilyCount(); |
| 468 } | 468 } |
| 469 | 469 |
| 470 void SkFontMgr_DirectWrite::onGetFamilyName(int index, SkString* familyName) con
st { | 470 void SkFontMgr_DirectWrite::onGetFamilyName(int index, SkString* familyName) con
st { |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 | 1100 |
| 1101 #include "SkFontMgr_indirect.h" | 1101 #include "SkFontMgr_indirect.h" |
| 1102 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { | 1102 SK_API SkFontMgr* SkFontMgr_New_DirectWriteRenderer(SkRemotableFontMgr* proxy) { |
| 1103 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); | 1103 SkAutoTUnref<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); |
| 1104 if (impl.get() == nullptr) { | 1104 if (impl.get() == nullptr) { |
| 1105 return nullptr; | 1105 return nullptr; |
| 1106 } | 1106 } |
| 1107 return new SkFontMgr_Indirect(impl.get(), proxy); | 1107 return new SkFontMgr_Indirect(impl.get(), proxy); |
| 1108 } | 1108 } |
| 1109 #endif//defined(SK_BUILD_FOR_WIN32) | 1109 #endif//defined(SK_BUILD_FOR_WIN32) |
| OLD | NEW |