# HG changeset patch # User Jonathan Kew # Date 1517323290 0 # Node ID d64eb03f3da5308f881dd467a8af2583f1fc07fc # Parent 71dbd105503db88efd5c94409b47c31201905169 Bug 1426146 - patch 1 - Support GLYPH_STROKE_UNDERNEATH in the gfxFont painting code. r=jwatt diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -1716,16 +1716,24 @@ private: std::reverse(mBuffer, mBuffer + mNumGlyphs); } gfx::GlyphBuffer buf; buf.mGlyphs = mBuffer; buf.mNumGlyphs = mNumGlyphs; const gfxContext::AzureState &state = mRunParams.context->CurrentState(); + + // Draw stroke first if the UNDERNEATH flag is set in drawMode. + if (mRunParams.strokeOpts && + GetStrokeMode(mRunParams.drawMode) == + (DrawMode::GLYPH_STROKE | DrawMode::GLYPH_STROKE_UNDERNEATH)) { + DrawStroke(state, buf); + } + if (mRunParams.drawMode & DrawMode::GLYPH_FILL) { if (state.pattern || mFontParams.contextPaint) { Pattern *pat; RefPtr fillPattern; if (mFontParams.contextPaint) { imgDrawingParams imgParams; fillPattern = @@ -1753,42 +1761,49 @@ private: *pat, mFontParams.drawOptions); } } else { mRunParams.dt->FillGlyphs(mFontParams.scaledFont, buf, ColorPattern(state.color), mFontParams.drawOptions); } } - if (GetStrokeMode(mRunParams.drawMode) == DrawMode::GLYPH_STROKE && - mRunParams.strokeOpts) { - Pattern *pat; - if (mRunParams.textStrokePattern) { - pat = mRunParams.textStrokePattern->GetPattern( - mRunParams.dt, state.patternTransformChanged - ? &state.patternTransform - : nullptr); - - if (pat) { - FlushStroke(buf, *pat); - } - } else { - FlushStroke(buf, - ColorPattern( - Color::FromABGR(mRunParams.textStrokeColor))); - } + + // Draw stroke if the UNDERNEATH flag is not set. + if (mRunParams.strokeOpts && + GetStrokeMode(mRunParams.drawMode) == DrawMode::GLYPH_STROKE) { + DrawStroke(state, buf); } + if (mRunParams.drawMode & DrawMode::GLYPH_PATH) { mRunParams.context->EnsurePathBuilder(); Matrix mat = mRunParams.dt->GetTransform(); mFontParams.scaledFont->CopyGlyphsToBuilder( buf, mRunParams.context->mPathBuilder, &mat); } } + void DrawStroke(const gfxContext::AzureState& aState, + gfx::GlyphBuffer& aBuffer) + { + if (mRunParams.textStrokePattern) { + Pattern* pat = mRunParams.textStrokePattern->GetPattern( + mRunParams.dt, aState.patternTransformChanged + ? &aState.patternTransform + : nullptr); + + if (pat) { + FlushStroke(aBuffer, *pat); + } + } else { + FlushStroke(aBuffer, ColorPattern( + Color::FromABGR(mRunParams.textStrokeColor))); + } + } + void FlushStroke(gfx::GlyphBuffer& aBuf, const Pattern& aPattern) { mRunParams.dt->StrokeGlyphs(mFontParams.scaledFont, aBuf, aPattern, *mRunParams.strokeOpts, mFontParams.drawOptions); }