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 <herb@google.com>
This commit is contained in:
parent
f55a0f7a48
commit
baa0be10a2
@ -262,9 +262,6 @@ SkScalerContext_DW::SkScalerContext_DW(sk_sp<DWriteFontTypeface> typefaceRef,
|
|||||||
{
|
{
|
||||||
DWriteFontTypeface* typeface = this->getDWriteTypeface();
|
DWriteFontTypeface* typeface = this->getDWriteTypeface();
|
||||||
fGlyphCount = typeface->fDWriteFontFace->GetGlyphCount();
|
fGlyphCount = typeface->fDWriteFontFace->GetGlyphCount();
|
||||||
fIsColorFont = typeface->fFactory2 &&
|
|
||||||
typeface->fDWriteFontFace2 &&
|
|
||||||
typeface->fDWriteFontFace2->IsColorFont();
|
|
||||||
|
|
||||||
// In general, all glyphs should use NATURAL_SYMMETRIC
|
// In general, all glyphs should use NATURAL_SYMMETRIC
|
||||||
// except when bi-level rendering is requested or there are embedded
|
// except when bi-level rendering is requested or there are embedded
|
||||||
@ -744,13 +741,14 @@ void SkScalerContext_DW::generateMetrics(SkGlyph* glyph, SkArenaAlloc* alloc) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fIsColorFont && isColorGlyph(*glyph) && generateColorMetrics(glyph)) {
|
DWriteFontTypeface* typeface = this->getDWriteTypeface();
|
||||||
|
if (typeface->fIsColorFont && isColorGlyph(*glyph) && generateColorMetrics(glyph)) {
|
||||||
glyph->fMaskFormat = SkMask::kARGB32_Format;
|
glyph->fMaskFormat = SkMask::kARGB32_Format;
|
||||||
glyph->setPath(alloc, nullptr, false);
|
glyph->setPath(alloc, nullptr, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fIsColorFont && isPngGlyph(*glyph) && generatePngMetrics(glyph)) {
|
if (typeface->fIsColorFont && isPngGlyph(*glyph) && generatePngMetrics(glyph)) {
|
||||||
glyph->fMaskFormat = SkMask::kARGB32_Format;
|
glyph->fMaskFormat = SkMask::kARGB32_Format;
|
||||||
glyph->setPath(alloc, nullptr, false);
|
glyph->setPath(alloc, nullptr, false);
|
||||||
return;
|
return;
|
||||||
@ -1174,7 +1172,7 @@ void SkScalerContext_DW::generateImage(const SkGlyph& glyph) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (SkMask::kARGB32_Format == glyph.fMaskFormat) {
|
if (SkMask::kARGB32_Format == glyph.fMaskFormat) {
|
||||||
if (fIsColorFont) {
|
if (this->getDWriteTypeface()->fIsColorFont) {
|
||||||
if (isColorGlyph(glyph)) {
|
if (isColorGlyph(glyph)) {
|
||||||
generateColorGlyphImage(glyph);
|
generateColorGlyphImage(glyph);
|
||||||
return;
|
return;
|
||||||
|
@ -93,7 +93,6 @@ private:
|
|||||||
DWRITE_MEASURING_MODE fMeasuringMode;
|
DWRITE_MEASURING_MODE fMeasuringMode;
|
||||||
DWRITE_TEXT_ANTIALIAS_MODE fAntiAliasMode;
|
DWRITE_TEXT_ANTIALIAS_MODE fAntiAliasMode;
|
||||||
DWRITE_GRID_FIT_MODE fGridFitMode;
|
DWRITE_GRID_FIT_MODE fGridFitMode;
|
||||||
bool fIsColorFont;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -90,6 +90,8 @@ private:
|
|||||||
if (fDWriteFontFace1 && fDWriteFontFace1->IsMonospacedFont()) {
|
if (fDWriteFontFace1 && fDWriteFontFace1->IsMonospacedFont()) {
|
||||||
this->setIsFixedPitch(true);
|
this->setIsFixedPitch(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fIsColorFont = fFactory2 && fDWriteFontFace2 && fDWriteFontFace2->IsColorFont();
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -101,6 +103,7 @@ public:
|
|||||||
SkTScopedComPtr<IDWriteFontFace1> fDWriteFontFace1;
|
SkTScopedComPtr<IDWriteFontFace1> fDWriteFontFace1;
|
||||||
SkTScopedComPtr<IDWriteFontFace2> fDWriteFontFace2;
|
SkTScopedComPtr<IDWriteFontFace2> fDWriteFontFace2;
|
||||||
SkTScopedComPtr<IDWriteFontFace4> fDWriteFontFace4;
|
SkTScopedComPtr<IDWriteFontFace4> fDWriteFontFace4;
|
||||||
|
bool fIsColorFont;
|
||||||
|
|
||||||
static sk_sp<DWriteFontTypeface> Make(
|
static sk_sp<DWriteFontTypeface> Make(
|
||||||
IDWriteFactory* factory,
|
IDWriteFactory* factory,
|
||||||
|
Loading…
Reference in New Issue
Block a user