From 8968724f1ad290cc0967255b2046dc92cf40172a Mon Sep 17 00:00:00 2001 From: Sebastian Hengst Date: Sat, 28 Oct 2017 16:39:59 +0200 Subject: [PATCH] Backed out changeset 4905048de8d1 (bug 1412355) for frequently failing reftest layout/reftests/writing-mode/1248248-1-orientation-break-glyphrun.html on Linux x64 debug and asan. r=backout --HG-- extra : amend_source : 61e56c97354c788bfd03aa551e911a1aff14006e --- gfx/thebes/gfxCoreTextShaper.cpp | 3 ++- gfx/thebes/gfxFT2Fonts.cpp | 2 ++ gfx/thebes/gfxFont.cpp | 22 +++++++++++++++++---- gfx/thebes/gfxFont.h | 18 ++++++++--------- gfx/thebes/gfxGraphiteShaper.cpp | 9 +++++---- gfx/thebes/gfxHarfBuzzShaper.cpp | 15 ++++---------- gfx/thebes/gfxTextRun.cpp | 1 + layout/generic/nsTextRunTransformations.cpp | 2 ++ layout/mathml/nsMathMLChar.cpp | 1 + 9 files changed, 43 insertions(+), 30 deletions(-) diff --git a/gfx/thebes/gfxCoreTextShaper.cpp b/gfx/thebes/gfxCoreTextShaper.cpp index 9a55c513c6f2..63aa5d8f8da5 100644 --- a/gfx/thebes/gfxCoreTextShaper.cpp +++ b/gfx/thebes/gfxCoreTextShaper.cpp @@ -527,7 +527,8 @@ gfxCoreTextShaper::SetGlyphsFromRun(gfxShapedText *aShapedText, while (true) { gfxTextRun::DetailedGlyph *details = detailedGlyphs.AppendElement(); details->mGlyphID = glyphs[glyphStart]; - details->mOffset.y = -positions[glyphStart].y * appUnitsPerDevUnit; + details->mXOffset = 0; + details->mYOffset = -positions[glyphStart].y * appUnitsPerDevUnit; details->mAdvance = advance; if (++glyphStart >= glyphEnd) { break; diff --git a/gfx/thebes/gfxFT2Fonts.cpp b/gfx/thebes/gfxFT2Fonts.cpp index d2ef0f293692..ec4eae3d9deb 100644 --- a/gfx/thebes/gfxFT2Fonts.cpp +++ b/gfx/thebes/gfxFT2Fonts.cpp @@ -151,6 +151,8 @@ gfxFT2Font::AddRange(const char16_t *aText, uint32_t aOffset, NS_ASSERTION(details.mGlyphID == gid, "Seriously weird glyph ID detected!"); details.mAdvance = advance; + details.mXOffset = 0; + details.mYOffset = 0; gfxShapedText::CompressedGlyph g; g.SetComplex(charGlyphs[aOffset].IsClusterStart(), true, 1); aShapedText->SetGlyphs(aOffset, g, &details); diff --git a/gfx/thebes/gfxFont.cpp b/gfx/thebes/gfxFont.cpp index f77b0c0484f9..f8d018b28bc5 100644 --- a/gfx/thebes/gfxFont.cpp +++ b/gfx/thebes/gfxFont.cpp @@ -685,6 +685,8 @@ gfxShapedText::SetMissingGlyph(uint32_t aIndex, uint32_t aChar, gfxFont *aFont) mAppUnitsPerDevUnit))); details->mAdvance = uint32_t(width * mAppUnitsPerDevUnit); } + details->mXOffset = 0; + details->mYOffset = 0; GetCharacterGlyphs()[aIndex].SetMissing(1); } @@ -705,6 +707,8 @@ gfxShapedText::FilterIfIgnorable(uint32_t aIndex, uint32_t aCh) DetailedGlyph *details = AllocateDetailedGlyphs(aIndex, 1); details->mGlyphID = aCh; details->mAdvance = 0; + details->mXOffset = 0; + details->mYOffset = 0; GetCharacterGlyphs()[aIndex].SetMissing(1); return true; } @@ -729,7 +733,7 @@ gfxShapedText::AdjustAdvancesForSyntheticBold(float aSynBoldOffset, // rare case, tested by making this the default uint32_t glyphIndex = glyphData->GetSimpleGlyph(); glyphData->SetComplex(true, true, 1); - DetailedGlyph detail = { glyphIndex, advance, gfx::Point() }; + DetailedGlyph detail = {glyphIndex, advance, 0, 0}; SetGlyphs(i, *glyphData, &detail); } } else { @@ -1937,7 +1941,14 @@ gfxFont::DrawGlyphs(const gfxShapedText* aShapedText, return false; } } else { - gfx::Point glyphPt(*aPt + details->mOffset); + gfx::Point glyphPt(*aPt); + if (aBuffer.mFontParams.isVerticalFont) { + glyphPt.x += details->mYOffset; + glyphPt.y += details->mXOffset; + } else { + glyphPt.x += details->mXOffset; + glyphPt.y += details->mYOffset; + } DrawOneGlyph(details->mGlyphID, glyphPt, aBuffer, &emittedGlyphs); } @@ -2573,8 +2584,7 @@ gfxFont::Measure(const gfxTextRun *aTextRun, uint32_t j; for (j = 0; j < glyphCount; ++j, ++details) { uint32_t glyphIndex = details->mGlyphID; - gfxPoint glyphPt(x + details->mOffset.x, - details->mOffset.y); + gfxPoint glyphPt(x + details->mXOffset, details->mYOffset); double advance = details->mAdvance; gfxRect glyphRect; if (glyphData->IsMissing() || !extents || @@ -2585,6 +2595,10 @@ gfxFont::Measure(const gfxTextRun *aTextRun, glyphRect = gfxRect(0, -metrics.mAscent, advance, metrics.mAscent + metrics.mDescent); } + if (orientation == eVertical) { + Swap(glyphRect.x, glyphRect.y); + Swap(glyphRect.width, glyphRect.height); + } if (isRTL) { glyphRect -= gfxPoint(advance, 0); } diff --git a/gfx/thebes/gfxFont.h b/gfx/thebes/gfxFont.h index 606c6ad89ac8..e43c3efb1929 100644 --- a/gfx/thebes/gfxFont.h +++ b/gfx/thebes/gfxFont.h @@ -957,17 +957,15 @@ public: * in SimpleGlyph format, we use an array of DetailedGlyphs instead. */ struct DetailedGlyph { - // The glyphID, or the Unicode character if this is a missing glyph + /** The glyphID, or the Unicode character + * if this is a missing glyph */ uint32_t mGlyphID; - // The advance of the glyph, in appunits. - // mAdvance is in the text direction (RTL or LTR), - // and will normally be non-negative (although this is not guaranteed) + /** The advance, x-offset and y-offset of the glyph, in appunits + * mAdvance is in the text direction (RTL or LTR) + * mXOffset is always from left to right + * mYOffset is always from top to bottom */ int32_t mAdvance; - // The offset from the glyph's default position, in line-relative - // coordinates (so mOffset.x is an offset in the line-right direction, - // and mOffset.y is an offset in line-downwards direction). - // These values are in floating-point appUnits. - mozilla::gfx::Point mOffset; + float mXOffset, mYOffset; }; void SetGlyphs(uint32_t aCharIndex, CompressedGlyph aGlyph, @@ -1085,7 +1083,7 @@ protected: DetailedGlyph details = { aGlyph.GetSimpleGlyph(), (int32_t) aGlyph.GetSimpleAdvance(), - mozilla::gfx::Point() + 0, 0 }; SetGlyphs(aIndex, CompressedGlyph().SetComplex(true, true, 1), &details); diff --git a/gfx/thebes/gfxGraphiteShaper.cpp b/gfx/thebes/gfxGraphiteShaper.cpp index 381bd57a5355..93f7eab4b0f6 100644 --- a/gfx/thebes/gfxGraphiteShaper.cpp +++ b/gfx/thebes/gfxGraphiteShaper.cpp @@ -339,16 +339,17 @@ gfxGraphiteShaper::SetGlyphsFromSegment(gfxShapedText *aShapedText, for (uint32_t j = c.baseGlyph; j < c.baseGlyph + c.nGlyphs; ++j) { gfxShapedText::DetailedGlyph* d = details.AppendElement(); d->mGlyphID = gids[j]; - d->mOffset.y = roundY ? NSToIntRound(-yLocs[j]) * dev2appUnits - : -yLocs[j] * dev2appUnits; + d->mYOffset = roundY ? NSToIntRound(-yLocs[j]) * dev2appUnits + : -yLocs[j] * dev2appUnits; if (j == c.baseGlyph) { + d->mXOffset = 0; d->mAdvance = appAdvance; clusterLoc = xLocs[j]; } else { float dx = rtl ? (xLocs[j] - clusterLoc) : (xLocs[j] - clusterLoc - adv); - d->mOffset.x = roundX ? NSToIntRound(dx) * dev2appUnits - : dx * dev2appUnits; + d->mXOffset = roundX ? NSToIntRound(dx) * dev2appUnits + : dx * dev2appUnits; d->mAdvance = 0; } } diff --git a/gfx/thebes/gfxHarfBuzzShaper.cpp b/gfx/thebes/gfxHarfBuzzShaper.cpp index cb9adc3f01a6..f9bb2be94c6b 100644 --- a/gfx/thebes/gfxHarfBuzzShaper.cpp +++ b/gfx/thebes/gfxHarfBuzzShaper.cpp @@ -1736,19 +1736,12 @@ gfxHarfBuzzShaper::SetGlyphsFromRun(gfxShapedText *aShapedText, detailedGlyphs.AppendElement(); details->mGlyphID = ginfo[glyphStart].codepoint; + details->mXOffset = iOffset; details->mAdvance = advance; - if (aVertical) { - details->mOffset.x = bPos - - (roundB ? appUnitsPerDevUnit * FixedToIntRound(b_offset) - : floor(hb2appUnits * b_offset + 0.5)); - details->mOffset.y = iOffset; - } else { - details->mOffset.x = iOffset; - details->mOffset.y = bPos - - (roundB ? appUnitsPerDevUnit * FixedToIntRound(b_offset) - : floor(hb2appUnits * b_offset + 0.5)); - } + details->mYOffset = bPos - + (roundB ? appUnitsPerDevUnit * FixedToIntRound(b_offset) + : floor(hb2appUnits * b_offset + 0.5)); if (b_advance != 0) { bPos -= diff --git a/gfx/thebes/gfxTextRun.cpp b/gfx/thebes/gfxTextRun.cpp index 507bb739ad77..3c6fd794a8de 100644 --- a/gfx/thebes/gfxTextRun.cpp +++ b/gfx/thebes/gfxTextRun.cpp @@ -2758,6 +2758,7 @@ gfxFontGroup::InitScriptRun(DrawTarget* aDrawTarget, gfxTextRun::DetailedGlyph detailedGlyph; detailedGlyph.mGlyphID = mainFont->GetSpaceGlyph(); detailedGlyph.mAdvance = advance; + detailedGlyph.mXOffset = detailedGlyph.mYOffset = 0; gfxShapedText::CompressedGlyph g; g.SetComplex(true, true, 1); aTextRun->SetGlyphs(aOffset + index, diff --git a/layout/generic/nsTextRunTransformations.cpp b/layout/generic/nsTextRunTransformations.cpp index 4d470eb9d12f..1237eed0fc68 100644 --- a/layout/generic/nsTextRunTransformations.cpp +++ b/layout/generic/nsTextRunTransformations.cpp @@ -161,6 +161,8 @@ MergeCharactersInTextRun(gfxTextRun* aDest, gfxTextRun* aSrc, gfxTextRun::DetailedGlyph details; details.mGlyphID = g.GetSimpleGlyph(); details.mAdvance = g.GetSimpleAdvance(); + details.mXOffset = 0; + details.mYOffset = 0; glyphs.AppendElement(details); } } else { diff --git a/layout/mathml/nsMathMLChar.cpp b/layout/mathml/nsMathMLChar.cpp index ae7fb2cdb61f..d6949ac3ecdb 100644 --- a/layout/mathml/nsMathMLChar.cpp +++ b/layout/mathml/nsMathMLChar.cpp @@ -588,6 +588,7 @@ nsOpenTypeTable::MakeTextRun(DrawTarget* aDrawTarget, NSToCoordRound(aAppUnitsPerDevPixel * aFontGroup->GetFirstValidFont()-> GetGlyphHAdvance(aDrawTarget, aGlyph.glyphID)); + detailedGlyph.mXOffset = detailedGlyph.mYOffset = 0; gfxShapedText::CompressedGlyph g; g.SetComplex(true, true, 1); textRun->SetGlyphs(0, g, &detailedGlyph);