From baa0be10a2904cdc79cc41431403f300949f6180 Mon Sep 17 00:00:00 2001 From: Ben Wagner Date: Sat, 12 Feb 2022 18:51:05 -0500 Subject: [PATCH] Move SkScalerContext_DW::fIsColorFont to typeface. There is no advantage to having every SkScalerContext_DW recompute and store fIsColorFont when this is a constant on the typeface. Have the typeface compute the value once and store and have the scaler contexts look it up on the typeface. Change-Id: Ib0441e4bc078da2bb9aa0cf5a97de7fe84947ce2 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/508177 Reviewed-by: Herb Derby --- src/ports/SkScalerContext_win_dw.cpp | 10 ++++------ src/ports/SkScalerContext_win_dw.h | 1 - src/ports/SkTypeface_win_dw.h | 3 +++ 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/ports/SkScalerContext_win_dw.cpp b/src/ports/SkScalerContext_win_dw.cpp index 4272754752..c198330ef7 100644 --- a/src/ports/SkScalerContext_win_dw.cpp +++ b/src/ports/SkScalerContext_win_dw.cpp @@ -262,9 +262,6 @@ SkScalerContext_DW::SkScalerContext_DW(sk_sp typefaceRef, { DWriteFontTypeface* typeface = this->getDWriteTypeface(); fGlyphCount = typeface->fDWriteFontFace->GetGlyphCount(); - fIsColorFont = typeface->fFactory2 && - typeface->fDWriteFontFace2 && - typeface->fDWriteFontFace2->IsColorFont(); // In general, all glyphs should use NATURAL_SYMMETRIC // except when bi-level rendering is requested or there are embedded @@ -744,13 +741,14 @@ void SkScalerContext_DW::generateMetrics(SkGlyph* glyph, SkArenaAlloc* alloc) { return; } - if (fIsColorFont && isColorGlyph(*glyph) && generateColorMetrics(glyph)) { + DWriteFontTypeface* typeface = this->getDWriteTypeface(); + if (typeface->fIsColorFont && isColorGlyph(*glyph) && generateColorMetrics(glyph)) { glyph->fMaskFormat = SkMask::kARGB32_Format; glyph->setPath(alloc, nullptr, false); return; } - if (fIsColorFont && isPngGlyph(*glyph) && generatePngMetrics(glyph)) { + if (typeface->fIsColorFont && isPngGlyph(*glyph) && generatePngMetrics(glyph)) { glyph->fMaskFormat = SkMask::kARGB32_Format; glyph->setPath(alloc, nullptr, false); return; @@ -1174,7 +1172,7 @@ void SkScalerContext_DW::generateImage(const SkGlyph& glyph) { } if (SkMask::kARGB32_Format == glyph.fMaskFormat) { - if (fIsColorFont) { + if (this->getDWriteTypeface()->fIsColorFont) { if (isColorGlyph(glyph)) { generateColorGlyphImage(glyph); return; diff --git a/src/ports/SkScalerContext_win_dw.h b/src/ports/SkScalerContext_win_dw.h index 8ed5cf9a52..8f1184a3ce 100644 --- a/src/ports/SkScalerContext_win_dw.h +++ b/src/ports/SkScalerContext_win_dw.h @@ -93,7 +93,6 @@ private: DWRITE_MEASURING_MODE fMeasuringMode; DWRITE_TEXT_ANTIALIAS_MODE fAntiAliasMode; DWRITE_GRID_FIT_MODE fGridFitMode; - bool fIsColorFont; }; #endif diff --git a/src/ports/SkTypeface_win_dw.h b/src/ports/SkTypeface_win_dw.h index 608966716d..a85cf6412d 100644 --- a/src/ports/SkTypeface_win_dw.h +++ b/src/ports/SkTypeface_win_dw.h @@ -90,6 +90,8 @@ private: if (fDWriteFontFace1 && fDWriteFontFace1->IsMonospacedFont()) { this->setIsFixedPitch(true); } + + fIsColorFont = fFactory2 && fDWriteFontFace2 && fDWriteFontFace2->IsColorFont(); } public: @@ -101,6 +103,7 @@ public: SkTScopedComPtr fDWriteFontFace1; SkTScopedComPtr fDWriteFontFace2; SkTScopedComPtr fDWriteFontFace4; + bool fIsColorFont; static sk_sp Make( IDWriteFactory* factory,