Closed Bug 1820988 Opened 2 years ago Closed 2 years ago

Optimize canvas2d text drawing for purely-LTR strings

Categories

(Core :: Graphics: Canvas2D, defect)

defect

Tracking

()

RESOLVED FIXED
112 Branch
Tracking Status
firefox112 --- fixed

People

(Reporter: jfkthame, Assigned: jfkthame)

References

(Blocks 1 open bug)

Details

Attachments

(7 files)

I think we can (marginally) improve Canvas text performance for common cases by avoiding some of the Unicode bidi processing for strings that are known to be purely LTR.

We already have a simplified code path used for single-character strings (introduced because pdf.js likes to paint each character individually, so this is a hot path), but I think we can extend that to also cover longer strings where no potentially-bidi content is present.

In local testing on macOS, this gives me about a 2.5% improvement on the old IETestDrive Preschool demo mentioned in bug 932613.

No functional change, just a drive-by cleanup noticed when looking over the text-rendering APIs.

Assignee: nobody → jfkthame
Status: NEW → ASSIGNED

I guess this used to be needed somewhere, but it's long dead now.
Removing the parameter makes it clear that the caller doesn't need
to compute and pass it.

Depends on D171984

This function doesn't need a Bidi engine, it just does property lookups
via the intl API. So drop the redundant parameter.

Depends on D171985

This avoids an extra string copy/scan in ProcessText, by including the block/segment
separators it cares about in the preprocessing that's already being done to normalize
whitespace characters by the caller.

Depends on D171986

Just to reduce visual clutter in the code, for readability.

Depends on D171987

This is the significant change here: extend the single-character fast-path that skips
bidi processing to also handle strings that are confirmed to have no bidi content.
In such cases, we don't need to pass the text to a Bidi engine for analysis at all.

Depends on D171988

Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/6fdd0782eb8d Templatize the 8- and 16-bit versions of gfxFontGroup::MakeTextRun for convenience. r=gfx-reviewers,aosmond https://hg.mozilla.org/integration/autoland/rev/bcc2e31546e8 The width parameter to BidiProcessor::DrawText is not used by any implementation, so remove it. r=emilio https://hg.mozilla.org/integration/autoland/rev/b618fa47868b Remove unused bidiEngine parameter to CalculateBidiClass. r=emilio https://hg.mozilla.org/integration/autoland/rev/a9888772a4e1 Handle separator characters in canvas2d TextReplaceWhitespaceCharacters, to avoid a second preprocessing of the string in ProcessText. r=gfx-reviewers,aosmond https://hg.mozilla.org/integration/autoland/rev/1926e59c9e75 Use 'using' to eliminate a bunch of explicit namespace-prefix usage in nsBidiPresUtils. r=emilio https://hg.mozilla.org/integration/autoland/rev/5fd91fb4cb3b Rename ProcessOneChar to ProcessSimpleRun, and allow it to also handle purely-LTR strings. r=emilio

Backed out changeset 6fdd0782eb8d for causing build bustage

Backout link

Push with failures

Failure log

Flags: needinfo?(jfkthame)
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7f486b8078ac followup, use nsDependentSubstring in the assertion, because the text may not be null-terminated.
Pushed by jkew@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/223bc3a0b9b5 Templatize the 8- and 16-bit versions of gfxFontGroup::MakeTextRun for convenience. r=gfx-reviewers,aosmond
Regressions: 1821469
Flags: needinfo?(jfkthame)
Regressions: 1857991
Regressions: 1880996
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: