Closed Bug 1412355 Opened 7 years ago Closed 7 years ago

Revise the storage of glyph offsets in DetailedGlyph records so as to avoid x/y swapping in the inner loop of gfxFont::DrawGlyphs

Categories

(Core :: Graphics: Text, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla58
Tracking Status
firefox58 --- fixed

People

(Reporter: jfkthame, Assigned: jfkthame)

References

(Regressed 1 open bug)

Details

Attachments

(1 file)

As per bug 1408612 comment 18 and 21.

When shaping in vertical mode, we currently store glyph positioning data such that the mXOffset/mYOffset fields are being (ab)used such that the "x" offset is really an offset along the baseline of the text, and the "y" offset is perpendicular to this. During rendering, we end up having to check for vertical mode and swap the interpretations to get the physical offsets we need.

If we do an equivalent of this swap during shaping instead, this if-test can be removed from the DrawGlyphs inner loop. This should (marginally) improve text-drawing performance, given that we're likely to shape a run once but then paint it multiple times.
Tryserver says this passes reftests successfully (including the newly-added test from bug 1395926):
https://treeherder.mozilla.org/#/jobs?repo=try&revision=4a5e580a70bcfbdbbcb4d61ad9578058c16c61f3

(The android build failure there has been fixed.)
Attachment #8922910 - Flags: review?(jmuizelaar)
Assignee: nobody → jfkthame
Status: NEW → ASSIGNED
Attachment #8922910 - Flags: review?(jmuizelaar) → review+
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/4905048de8d1
Replace the mXOffset/mYOffset fields in DetailedGlyph records with a gfx::Point that stores glyph offsets in line-orientation-relative coordinates. r=jrmuizel
(In reply to Sebastian Hengst [:aryx][:archaeopteryx] (needinfo on intermittent or backout) from comment #3)
> Backed out for frequently failing reftest
> layout/reftests/writing-mode/1248248-1-orientation-break-glyphrun.html on
> Linux x64 debug and asan:

Interesting.... I'm not really sure why this is intermittent and only seemed to affect certain platforms. I guess it must be timing-dependent, related to exactly how dirty-rects and repaint operations work out. The root of the issue is that the test font we have in layout/reftest/fonts/gw1270797.ttf has incorrect 'vmtx' (vertical glyph metrics) values, which results in the glyphs getting painted much lower than they should -- largely outside their intended rects. Depending exactly how the textrun bounds and resulting invalidation areas get handled, they may end up mostly clipped.

The straightforward fix is to correct the 'vmtx' table topSideBearing values, such that the glyphs render in the proper positions relative to the font's em-square, and the (unreliable) clipping won't happen.

(Incidentally, I also noticed a bug in the patch here -- I failed to remove the obsolete "if (orientation == eVertical)..." branch from the IsSimpleGlyph() code path in gfxFont::Measure. So I'll clean that up before re-landing, although in practice it was unlikely to matter because I believe most fonts will never hit the IsSimpleGlyph() path when shaped in vertical mode, because of how vertical-origin offsets work.)
Flags: needinfo?(jfkthame)
Pushed by jkew@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/4558b0224f93
Replace the mXOffset/mYOffset fields in DetailedGlyph records with a gfx::Point that stores glyph offsets in line-orientation-relative coordinates. r=jrmuizel
Blocks: 1395774
https://hg.mozilla.org/mozilla-central/rev/4558b0224f93
Status: ASSIGNED → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla58
Regressions: 1852861
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: