Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Issue 1192223002: Optimize Complex Text Shaping and Caching (Closed)

Created:
5 years, 6 months ago by eae
Modified:
5 years, 5 months ago
CC:
blink-reviews, Rik, danakj, dshwang, drott+blinkwatch_chromium.org, krit, f(malita), Justin Novosad, pdr+graphicswatchlist_chromium.org, rwlbuis, Stephen Chennney
Target Ref:
refs/heads/master
Project:
blink
Visibility:
Public.

Description

Optimize Complex Text Shaping and Caching Change HarfBuzzShaper to return a ShapeResult instead of mutating itself with the results from the shape operation. This allows the results to be cached and reused without having the overhead of re-creating the shaper. In addition this adds a new intermediary shaping step before calling the HarfBuzzShaper; segmenting TextRuns based on spaces and shapes on a word by word basis. In itself this adds extra overhead but when combined with a new cache that caches the ShapeResults per word it allows for a higher cache hit rate and enables full TextRuns to be shaped without additional shaping as, in most cases, the full run can be satisfied based on cached results computed for preferred width calculation or from a previous run. The new cache replaces both the previous HarfBuzz and Font Width caches. Word based shaping assumes that words are shaped the same way regardless of where they occur in a sentence, as such it is currently disabled if a given font has entry for space in either the GSUB or GPOS tables as that indicates that the shape of a word may be affected by a space character. If kerning and ligatures are disabled word based shaping is always used. The current implementation hasn't been fully optimized and does a lot of extra work yet it's quite a bit faster than our existing implementation. Further optimization should allow even bigger wins. Similarly only width and fillGlyphBuffer operations are currently serviced through the cache. TEST=PerformanceTests/Layout BUG=462643 R=behdad@chromium.org, drott@chromium.org, leviw@chromium.org Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=198501

Patch Set 1 : #

Total comments: 12

Patch Set 2 : w/TextExpectations #

Patch Set 3 : Addressing review comments #

Total comments: 12

Patch Set 4 : Fix selection for vertical #

Patch Set 5 : Fix emphasis computation #

Patch Set 6 : Remove TypesettingFeatures check #

Total comments: 1

Patch Set 7 : Second attempt at fixing emphasis marks #

Patch Set 8 : Take directionality into account for single glyph cache entries #

Patch Set 9 : w/updated TestExpectations #

Total comments: 1

Patch Set 10 : Change CachingWordShaperTest as suggested #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1182 lines, -920 lines) Patch
M LayoutTests/TestExpectations View 1 2 3 4 5 6 7 8 1 chunk +30 lines, -0 lines 0 comments Download
M Source/platform/blink_platform.gypi View 1 2 3 4 5 6 3 chunks +5 lines, -1 line 0 comments Download
M Source/platform/fonts/Font.h View 1 2 3 4 5 6 7 4 chunks +16 lines, -0 lines 0 comments Download
M Source/platform/fonts/Font.cpp View 1 2 3 4 5 6 7 7 chunks +46 lines, -42 lines 0 comments Download
M Source/platform/fonts/FontCache.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/platform/fonts/FontFallbackList.h View 3 chunks +3 lines, -3 lines 0 comments Download
M Source/platform/fonts/FontFallbackList.cpp View 1 2 3 4 5 6 7 1 chunk +1 line, -1 line 0 comments Download
M Source/platform/fonts/FontPlatformData.h View 1 2 3 6 1 chunk +1 line, -0 lines 0 comments Download
M Source/platform/fonts/FontPlatformData.cpp View 1 2 3 6 2 chunks +53 lines, -0 lines 0 comments Download
D Source/platform/fonts/WidthCache.h View 1 chunk +0 lines, -212 lines 0 comments Download
A Source/platform/fonts/shaping/CachingWordShapeIterator.h View 1 2 3 4 5 6 7 1 chunk +126 lines, -0 lines 0 comments Download
A + Source/platform/fonts/shaping/CachingWordShaper.h View 1 2 3 4 5 6 2 chunks +29 lines, -29 lines 0 comments Download
A Source/platform/fonts/shaping/CachingWordShaper.cpp View 1 2 3 4 5 6 7 1 chunk +119 lines, -0 lines 0 comments Download
A Source/platform/fonts/shaping/CachingWordShaperTest.cpp View 1 2 3 4 5 6 7 8 9 1 chunk +157 lines, -0 lines 0 comments Download
M Source/platform/fonts/shaping/HarfBuzzFace.h View 1 chunk +2 lines, -1 line 0 comments Download
M Source/platform/fonts/shaping/HarfBuzzFace.cpp View 1 chunk +1 line, -1 line 0 comments Download
M Source/platform/fonts/shaping/HarfBuzzShaper.h View 1 2 3 4 5 6 7 4 chunks +54 lines, -69 lines 0 comments Download
M Source/platform/fonts/shaping/HarfBuzzShaper.cpp View 1 2 3 4 5 6 7 15 chunks +456 lines, -479 lines 0 comments Download
M Source/platform/fonts/shaping/HarfBuzzShaperTest.cpp View 8 chunks +30 lines, -29 lines 0 comments Download
A + Source/platform/fonts/shaping/ShapeCache.h View 1 2 3 4 5 6 7 7 chunks +52 lines, -52 lines 0 comments Download

Messages

Total messages: 29 (9 generated)
eae
Ready for review.
5 years, 6 months ago (2015-06-19 23:37:17 UTC) #4
leviw_travelin_and_unemployed
I didn't page all of this in, but just did a quick pass to familiarize ...
5 years, 6 months ago (2015-06-22 18:52:09 UTC) #6
eae
https://codereview.chromium.org/1192223002/diff/60001/Source/platform/fonts/Font.cpp File Source/platform/fonts/Font.cpp (right): https://codereview.chromium.org/1192223002/diff/60001/Source/platform/fonts/Font.cpp#newcode395 Source/platform/fonts/Font.cpp:395: if (!hb_font_get_glyph(font, spaceCharacter, 0, &space)) On 2015/06/22 18:52:08, leviw ...
5 years, 6 months ago (2015-06-22 19:19:54 UTC) #7
drott
+1 for Levi's comment, the patch is epic indeed, and revolutionary. Well done and thank ...
5 years, 6 months ago (2015-06-23 12:45:52 UTC) #8
eae
On 2015/06/23 12:45:52, drott wrote: > After the latest patch iteration I see real failures ...
5 years, 6 months ago (2015-06-23 17:56:44 UTC) #9
eae
Found a problem with how selections where handled and updated the selection code to use ...
5 years, 6 months ago (2015-06-23 22:25:15 UTC) #10
eae
See https://blink.gs/results/1192223002 for test results. Looking into the fast/css/text-overflow-ellipsis-vertical-select.html failure at the moment. No idea ...
5 years, 6 months ago (2015-06-24 00:12:19 UTC) #11
eae
emphasis is still broken in some cases as is vertical selection on mac, and only ...
5 years, 6 months ago (2015-06-24 06:35:45 UTC) #12
drott
> No idea as of yet why the emphasis tests only fail on mac or ...
5 years, 6 months ago (2015-06-24 07:56:58 UTC) #13
drott
https://codereview.chromium.org/1192223002/diff/160001/Source/platform/fonts/shaping/HarfBuzzShaper.cpp File Source/platform/fonts/shaping/HarfBuzzShaper.cpp (right): https://codereview.chromium.org/1192223002/diff/160001/Source/platform/fonts/shaping/HarfBuzzShaper.cpp#newcode64 Source/platform/fonts/shaping/HarfBuzzShaper.cpp:64: struct ShapeResult::RunInfo { One more comment perhaps - can ...
5 years, 5 months ago (2015-06-30 15:07:57 UTC) #14
eae
On 2015/06/30 15:07:57, drott wrote: > https://codereview.chromium.org/1192223002/diff/160001/Source/platform/fonts/shaping/HarfBuzzShaper.cpp > File Source/platform/fonts/shaping/HarfBuzzShaper.cpp (right): > > https://codereview.chromium.org/1192223002/diff/160001/Source/platform/fonts/shaping/HarfBuzzShaper.cpp#newcode64 > ...
5 years, 5 months ago (2015-06-30 17:12:12 UTC) #15
drott
> I'm not sure it's the right interface yet which is why it is local ...
5 years, 5 months ago (2015-07-01 09:10:27 UTC) #18
eae
Finally managed to fixed emphasis painting (yay!), still some problems with vertical selection on mac, ...
5 years, 5 months ago (2015-07-07 02:01:10 UTC) #19
eae
This is now ready for review. The latest patch-set fixes selection and ellipsis painting. The ...
5 years, 5 months ago (2015-07-07 22:22:07 UTC) #21
drott
Impressive work! LGTM. Just have one nit on the test SetUp(). Out of curiosity: What ...
5 years, 5 months ago (2015-07-08 13:00:59 UTC) #22
eae
On 2015/07/08 13:00:59, drott wrote: > Impressive work! > > LGTM. Just have one nit ...
5 years, 5 months ago (2015-07-08 14:20:17 UTC) #23
jbroman
On 2015/07/08 14:20:17, eae wrote: > Ideally I'd like to set up the font using ...
5 years, 5 months ago (2015-07-08 14:39:39 UTC) #24
eae
> For what it's worth, this worked for me in a unit test (that never ...
5 years, 5 months ago (2015-07-08 14:43:31 UTC) #25
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1192223002/260002
5 years, 5 months ago (2015-07-08 15:44:40 UTC) #28
commit-bot: I haz the power
5 years, 5 months ago (2015-07-08 15:50:20 UTC) #29
Message was sent while issue was closed.
Committed patchset #10 (id:260002) as
https://src.chromium.org/viewvc/blink?view=rev&revision=198501

Powered by Google App Engine
This is Rietveld 408576698