diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2020-04-09 12:19:07 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2020-04-10 15:16:34 +0200 |
commit | 894c0806328627aadd1e92c8601a5858a3ea627f (patch) | |
tree | e81b62fa021926058ae1adb6f701f622990f3898 /external | |
parent | c728c9df75344f431817d876b73ec867c7d449f6 (diff) |
prefer DirectWrite for Skia's Windows text rendering
Change-Id: Ibfb6206751126def10905bb22effbe1a947cd6d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91968
Tested-by: Jenkins
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Diffstat (limited to 'external')
-rw-r--r-- | external/skia/UnpackedTarball_skia.mk | 1 | ||||
-rw-r--r-- | external/skia/windows-text-gamma.patch.0 | 42 | ||||
-rw-r--r-- | external/skia/windows-typeface-directwrite.patch.0 | 48 |
3 files changed, 91 insertions, 0 deletions
diff --git a/external/skia/UnpackedTarball_skia.mk b/external/skia/UnpackedTarball_skia.mk index da0a2a7a0547..82fdbc433ece 100644 --- a/external/skia/UnpackedTarball_skia.mk +++ b/external/skia/UnpackedTarball_skia.mk @@ -33,6 +33,7 @@ skia_patches := \ operator-eq-bool.patch.0 \ fix-without-gl.patch.0 \ extend-rgb-to-rgba.patch.0 \ + windows-typeface-directwrite.patch.0 \ $(eval $(call gb_UnpackedTarball_set_patchlevel,skia,1)) diff --git a/external/skia/windows-text-gamma.patch.0 b/external/skia/windows-text-gamma.patch.0 index 366b67f15a65..624636b7da99 100644 --- a/external/skia/windows-text-gamma.patch.0 +++ b/external/skia/windows-text-gamma.patch.0 @@ -26,3 +26,45 @@ RGBToLcd16<false>(src, srcRB, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); } } +--- ./src/ports/SkScalerContext_win_dw.cpp ++++ ./src/ports/SkScalerContext_win_dw.cpp +@@ -1132,27 +1132,36 @@ void SkScalerContext_DW::generateImage(const SkGlyph& glyph) { + BilevelToBW(src, glyph); + } else if (!isLCD(fRec)) { + if (textureType == DWRITE_TEXTURE_ALIASED_1x1) { ++#if defined(SK_GAMMA_APPLY_TO_A8) + if (fPreBlend.isApplicable()) { + GrayscaleToA8<true>(src, glyph, fPreBlend.fG); +- } else { ++ } else ++#endif ++ { + GrayscaleToA8<false>(src, glyph, fPreBlend.fG); + } + } else { ++#if defined(SK_GAMMA_APPLY_TO_A8) + if (fPreBlend.isApplicable()) { + RGBToA8<true>(src, glyph, fPreBlend.fG); +- } else { ++ } else ++#endif ++ { + RGBToA8<false>(src, glyph, fPreBlend.fG); + } + } + } else { + SkASSERT(SkMask::kLCD16_Format == glyph.fMaskFormat); ++#if defined(SK_GAMMA_APPLY_TO_A8) + if (fPreBlend.isApplicable()) { + if (fRec.fFlags & SkScalerContext::kLCD_BGROrder_Flag) { + RGBToLcd16<true, false>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); + } else { + RGBToLcd16<true, true>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); + } +- } else { ++ } else ++#endif ++ { + if (fRec.fFlags & SkScalerContext::kLCD_BGROrder_Flag) { + RGBToLcd16<false, false>(src, glyph, fPreBlend.fR, fPreBlend.fG, fPreBlend.fB); + } else { diff --git a/external/skia/windows-typeface-directwrite.patch.0 b/external/skia/windows-typeface-directwrite.patch.0 new file mode 100644 index 000000000000..56e8209cedb4 --- /dev/null +++ b/external/skia/windows-typeface-directwrite.patch.0 @@ -0,0 +1,48 @@ +--- ./include/ports/SkTypeface_win.h ++++ ./include/ports/SkTypeface_win.h +@@ -75,5 +75,13 @@ SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWriteRenderer(sk_sp<SkRemotableFontM + */ + SK_API sk_sp<SkRemotableFontMgr> SkRemotableFontMgr_New_DirectWrite(); + ++struct IDWriteFontFace; ++struct IDWriteFont; ++struct IDWriteFontFamily; ++SK_API SkTypeface* SkCreateTypefaceDirectWrite(sk_sp<SkFontMgr> fontMgr, ++ IDWriteFontFace* fontFace, ++ IDWriteFont* font, ++ IDWriteFontFamily* fontFamily); ++ + #endif // SK_BUILD_FOR_WIN + #endif // SkTypeface_win_DEFINED +--- ./src/ports/SkFontMgr_win_dw.cpp ++++ ./src/ports/SkFontMgr_win_dw.cpp +@@ -320,6 +320,10 @@ private: + + friend class SkFontStyleSet_DirectWrite; + friend class FontFallbackRenderer; ++ friend SK_API SkTypeface* SkCreateTypefaceDirectWrite(sk_sp<SkFontMgr> fontMgr, ++ IDWriteFontFace* fontFace, ++ IDWriteFont* font, ++ IDWriteFontFamily* fontFamily); + }; + + class SkFontStyleSet_DirectWrite : public SkFontStyleSet { +@@ -1215,6 +1219,18 @@ SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWrite(IDWriteFactory* factory, + defaultFamilyName, defaultFamilyNameLen); + } + ++SkTypeface* SkCreateTypefaceDirectWrite(sk_sp<SkFontMgr> fontMgr, ++ IDWriteFontFace* fontFace, ++ IDWriteFont* font, ++ IDWriteFontFamily* fontFamily) ++{ ++ SkFontMgr_DirectWrite* mgr = dynamic_cast<SkFontMgr_DirectWrite*>(fontMgr.get()); ++ if(!mgr) ++ return nullptr; ++ sk_sp<SkTypeface> typeface = mgr->makeTypefaceFromDWriteFont(fontFace, font, fontFamily); ++ return typeface.release(); ++} ++ + #include "include/ports/SkFontMgr_indirect.h" + SK_API sk_sp<SkFontMgr> SkFontMgr_New_DirectWriteRenderer(sk_sp<SkRemotableFontMgr> proxy) { + sk_sp<SkFontMgr> impl(SkFontMgr_New_DirectWrite()); |