Bug 1853216 - Don't render layered-color glyphs via webrender if text-shadow is present. r=gfx-reviewers,lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D188346
This commit is contained in:
Jonathan Kew 2023-09-16 09:33:55 +00:00
parent 4732417d88
commit 924f066162
8 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,7 @@
<!DOCTYPE html>
<meta charset=utf-8>
<div style="font-size: 50px; color: transparent; text-shadow: 0px 0px 0 rgba(0,0,0,0.2)">
&#x1f550;
&#x1f550;
&#x1f550;
</div>

View File

@ -0,0 +1,9 @@
<!DOCTYPE html>
<meta charset=utf-8>
<div style="font-size: 50px; color: transparent; text-shadow: 0px 0px 0 rgba(0,0,0,0.2)">
<!-- all 3 of these codepoints are clock faces, just with different hand positions,
so we expect their shadows to be identical -->
&#x1f550;
&#x1f552;
&#x1f558;
</div>

View File

@ -43,3 +43,4 @@ pref(layout.css.backdrop-filter.enabled,true) == 1765862.html 1765862-ref.html
skip-if(!cocoaWidget) != 1806140.html 1806140-notref.html
fuzzy(0-1,0-240) == 1812341.html 1812341-ref.html
random-if(gtkWidget) fuzzy-if(Android,0-125,0-106) == 1845828-1.html 1845828-1-ref.html # Result on Linux depends on font configuration/hinting/etc, affecting whether subpixel positioning is used
fuzzy(0-1,0-4) == 1853216-1.html 1853216-1-ref.html

View File

@ -2313,6 +2313,7 @@ void gfxFont::Draw(const gfxTextRun* aTextRun, uint32_t aStart, uint32_t aEnd,
fontParams.obliqueSkew = SkewForSyntheticOblique();
fontParams.haveSVGGlyphs = GetFontEntry()->TryGetSVGData(this);
fontParams.haveColorGlyphs = GetFontEntry()->TryGetColorGlyphs();
fontParams.hasTextShadow = aRunParams.hasTextShadow;
fontParams.contextPaint = aRunParams.runContextPaint;
if (fontParams.haveColorGlyphs && !UseNativeColrFontSupport()) {
@ -2649,6 +2650,11 @@ bool gfxFont::RenderColorGlyph(DrawTarget* aDrawTarget, gfxContext* aContext,
layout::TextDrawTarget* aTextDrawer,
const FontDrawParams& aFontParams,
const Point& aPoint, uint32_t aGlyphId) {
if (aTextDrawer && aFontParams.hasTextShadow) {
aTextDrawer->FoundUnsupportedFeature();
return true;
}
if (const auto* paintGraph =
COLRFonts::GetGlyphPaintGraph(GetFontEntry()->GetCOLR(), aGlyphId)) {
const auto* hbShaper = GetHarfBuzzShaper();

View File

@ -2320,6 +2320,7 @@ struct MOZ_STACK_CLASS TextRunDrawParams {
bool isRTL = false;
bool paintSVGGlyphs = true;
bool allowGDI = true;
bool hasTextShadow = false;
// MRU cache of color-font palettes being used by fonts in the run. We cache
// these in the TextRunDrawParams so that we can avoid re-creating a new
@ -2364,6 +2365,7 @@ struct MOZ_STACK_CLASS FontDrawParams {
bool isVerticalFont;
bool haveSVGGlyphs;
bool haveColorGlyphs;
bool hasTextShadow; // whether we're rendering with a text-shadow
};
struct MOZ_STACK_CLASS EmphasisMarkDrawParams {

View File

@ -624,6 +624,7 @@ void gfxTextRun::Draw(const Range aRange, const gfx::Point aPt,
params.textStrokePattern = aParams.textStrokePattern;
params.drawOpts = aParams.drawOpts;
params.drawMode = aParams.drawMode;
params.hasTextShadow = aParams.hasTextShadow;
params.callbacks = aParams.callbacks;
params.runContextPaint = aParams.contextPaint;
params.paintSVGGlyphs =

View File

@ -264,6 +264,7 @@ class gfxTextRun : public gfxShapedText {
mozilla::SVGContextPaint* contextPaint = nullptr;
gfxTextRunDrawCallbacks* callbacks = nullptr;
bool allowGDI = true;
bool hasTextShadow = false;
explicit DrawParams(gfxContext* aContext) : context(aContext) {}
};

View File

@ -223,6 +223,7 @@ struct nsTextFrame::DrawTextRunParams {
gfx::FontPaletteValueSet* paletteValueSet = nullptr;
float textStrokeWidth = 0.0f;
bool drawSoftHyphen = false;
bool hasTextShadow = false;
explicit DrawTextRunParams(gfxContext* aContext) : context(aContext) {}
};
@ -6070,6 +6071,7 @@ bool nsTextFrame::PaintTextWithSelectionColors(
params.glyphRange = aParams.glyphRange;
params.fontPalette = StyleFont()->GetFontPaletteAtom();
params.paletteValueSet = PresContext()->GetFontPaletteValueSet();
params.hasTextShadow = !StyleText()->mTextShadow.IsEmpty();
PaintShadowParams shadowParams(aParams);
shadowParams.provider = aParams.provider;
@ -6656,6 +6658,7 @@ void nsTextFrame::PaintText(const PaintTextParams& aParams,
params.glyphRange = range;
params.fontPalette = StyleFont()->GetFontPaletteAtom();
params.paletteValueSet = PresContext()->GetFontPaletteValueSet();
params.hasTextShadow = !StyleText()->mTextShadow.IsEmpty();
DrawText(range, textBaselinePt, params);
}
@ -6672,6 +6675,7 @@ static void DrawTextRun(const gfxTextRun* aTextRun,
params.fontPalette = aParams.fontPalette;
params.paletteValueSet = aParams.paletteValueSet;
params.callbacks = aParams.callbacks;
params.hasTextShadow = aParams.hasTextShadow;
if (aParams.callbacks) {
aParams.callbacks->NotifyBeforeText(aParams.textColor);
params.drawMode = DrawMode::GLYPH_PATH;