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

Issue 676523003: Offset-only GlyphBuffer (Closed)

Created:
6 years, 1 month ago by f(malita)
Modified:
6 years, 1 month ago
CC:
blink-reviews, krit, Rik, jbroman, danakj, pdr+graphicswatchlist_chromium.org, Stephen Chennney, rwlbuis, reed1, bungeman-skia
Project:
blink
Visibility:
Public.

Description

Offset-only GlyphBuffer Instead of storing glyph advances (only to later convert to offsets for the Skia draw calls), refactor GlyphBuffer to store offsets directly. This reduces the amount of buffer post-processing and decreases the API friction when calling into Skia. GlyphBuffer offsets are relative to the text run origin and are either horizontal/x-only (generated by the simple shaper) or x/y interleaved (generated by the complex shaper). These correspond to the text positioning modes used by Skia. Thanks to the new buffer format, the refactor also includes: * zero offset processing when building text blobs (the offsets are essentially memcpy-ed) * minimal processing (translate by destination point) for the legacy drawPosText path (we could also optimize this path, but the added complexity is probably not justified given the plans to completely switch to text blobs) * SimpleShaper::adjustSpacing no longer needs to inject synthetic glyphs but simply adjusts the offsets for following glyps * drawEmphasisMarks uses explicit offsets to glyph-midpoint instead of computing them based on advances Other things to investigate: * multi-run buffer builder (to support multi-run text blobs) * stop storing space glyphs (simply adjust the following glyph offsets instead) R=jbroman@chromium.org,eae@chromium.org,dominik.rottsches@intel.com BUG=377845 Committed: https://src.chromium.org/viewvc/blink?view=rev&revision=185129

Patch Set 1 #

Patch Set 2 : updated unit test #

Patch Set 3 : speculative vertical rounding fix #

Patch Set 4 : speculative vertical rounding fix 2 #

Patch Set 5 : instrumented test run #

Patch Set 6 : speculative vertical rounding fix take 3 #

Patch Set 7 : cleanup #

Patch Set 8 : expectations update #

Patch Set 9 : refactor emphasis to avoid advances #

Patch Set 10 : minor cleanup #

Total comments: 16

Patch Set 11 : review comments #

Total comments: 2

Patch Set 12 : review nit #

Total comments: 6

Patch Set 13 : review comments + rebase #

Patch Set 14 : rebased #

Unified diffs Side-by-side diffs Delta from patch set Stats (+330 lines, -292 lines) Patch
M LayoutTests/TestExpectations View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +9 lines, -0 lines 0 comments Download
M Source/platform/fonts/Font.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 1 chunk +5 lines, -5 lines 0 comments Download
M Source/platform/fonts/Font.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 13 11 chunks +111 lines, -148 lines 0 comments Download
M Source/platform/fonts/GlyphBuffer.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +86 lines, -27 lines 0 comments Download
M Source/platform/fonts/GlyphBufferTest.cpp View 1 2 3 4 5 6 7 8 9 10 11 5 chunks +69 lines, -50 lines 0 comments Download
M Source/platform/fonts/shaping/HarfBuzzShaper.h View 1 2 3 4 5 6 7 8 1 chunk +2 lines, -2 lines 0 comments Download
M Source/platform/fonts/shaping/HarfBuzzShaper.cpp View 1 2 3 4 5 6 7 8 3 chunks +33 lines, -39 lines 0 comments Download
M Source/platform/fonts/shaping/SimpleShaper.h View 1 2 3 4 5 6 7 8 1 chunk +1 line, -1 line 0 comments Download
M Source/platform/fonts/shaping/SimpleShaper.cpp View 1 2 3 4 5 6 7 8 3 chunks +14 lines, -20 lines 0 comments Download

Messages

Total messages: 17 (3 generated)
f(malita)
8 tests require minimal rebaselining due to slightly different rounding (oddly, no platform overlap): https://storage.googleapis.com/chromium-layout-test-archives/linux_blink_rel/31348/layout-test-results/css1/box_properties/float_on_text_elements-diffs.html ...
6 years, 1 month ago (2014-10-29 02:15:21 UTC) #2
jbroman
Nice work. I'm totally unconcerned about the layout test changes as I think they're the ...
6 years, 1 month ago (2014-10-29 15:06:08 UTC) #3
f(malita)
https://codereview.chromium.org/676523003/diff/170001/Source/platform/fonts/Font.cpp File Source/platform/fonts/Font.cpp (right): https://codereview.chromium.org/676523003/diff/170001/Source/platform/fonts/Font.cpp#newcode120 Source/platform/fonts/Font.cpp:120: if (runInfo.run.rtl()) { On 2014/10/29 15:06:07, jbroman wrote: > ...
6 years, 1 month ago (2014-10-29 16:48:30 UTC) #4
jbroman
LGTM, but you might want to also get eae's opinion before landing. https://codereview.chromium.org/676523003/diff/170001/Source/platform/fonts/GlyphBuffer.h File Source/platform/fonts/GlyphBuffer.h ...
6 years, 1 month ago (2014-10-29 19:05:37 UTC) #5
f(malita)
Thanks. Emil/Dominik - WDYT? https://codereview.chromium.org/676523003/diff/180001/Source/platform/fonts/GlyphBufferTest.cpp File Source/platform/fonts/GlyphBufferTest.cpp (right): https://codereview.chromium.org/676523003/diff/180001/Source/platform/fonts/GlyphBufferTest.cpp#newcode196 Source/platform/fonts/GlyphBufferTest.cpp:196: TEST(GlyphBufferTest, Reverse) On 2014/10/29 19:05:36, ...
6 years, 1 month ago (2014-10-30 15:53:11 UTC) #6
eae
This is a very nice and exciting change, thanks for taking it on! https://codereview.chromium.org/676523003/diff/200001/LayoutTests/TestExpectations File ...
6 years, 1 month ago (2014-11-04 15:33:27 UTC) #7
f(malita)
https://codereview.chromium.org/676523003/diff/200001/LayoutTests/TestExpectations File LayoutTests/TestExpectations (right): https://codereview.chromium.org/676523003/diff/200001/LayoutTests/TestExpectations#newcode1153 LayoutTests/TestExpectations:1153: crbug.com/377845 css1/box_properties/float_on_text_elements.html [ NeedsRebaseline ] On 2014/11/04 15:33:26, eae ...
6 years, 1 month ago (2014-11-04 21:52:23 UTC) #8
eae
LGTM
6 years, 1 month ago (2014-11-05 19:24:30 UTC) #9
f(malita)
I'm tempted to land this in order to unblock related work and avoid further bitrot ...
6 years, 1 month ago (2014-11-11 15:27:59 UTC) #10
eae
Go for it.
6 years, 1 month ago (2014-11-11 16:09:07 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/676523003/240001
6 years, 1 month ago (2014-11-11 16:32:04 UTC) #13
commit-bot: I haz the power
Committed patchset #14 (id:240001) as 185129
6 years, 1 month ago (2014-11-11 16:34:29 UTC) #14
behdad_google
I'm not sure this is a good idea. Currently our uses of GlyphBuffer only need ...
6 years, 1 month ago (2014-11-11 18:18:02 UTC) #16
f(malita)
6 years, 1 month ago (2014-11-11 20:53:04 UTC) #17
Message was sent while issue was closed.
On 2014/11/11 18:18:02, behdad_google wrote:
> I'm not sure this is a good idea.
> 
> Currently our uses of GlyphBuffer only need the glyph positions.  But I think
in
> the long run we want to use advances for width measurements of selection, etc.

I guess my argument is:

* We only build glyph buffers for drawing, not for measuring.
* Regardless of whether or not we store advances, it makes sense to compute and
store the final offsets simply because that's what we ultimately need to pass to
Skia - why postpone it and force another pass if we have all the info upfront?
* Storing offsets opens the door for some interesting optimizations (we could
skip space glyphs, generate the emphasis marks buffer directly/during shaping,
coalesce multiple runs <- particularly interesting for text blobs)
* Since we no longer have a use for advances beyond shaping, why store them? It
would be trivial to add them later if needed (alongside final offsets), but I
would be interested to see what that use case looks like (and possibly question
whether GlyphBuffer is the right structure for the task).


> We sure can add them back again if needed, but this is a tricky piece of code,
> as eae@ can definitely tell given his experience moving from relative glyph
> offsets to the offsets and advances model two month ago...

I agree that the code is tricky, but I think this is actually removing some
complexity. At a high level we're just front-loading the final offset
computation at GB build time. The logic is equivalent (advance accumulator ->
offsets) and the only diffs should be related to rounding/precision.

Powered by Google App Engine
This is Rietveld 408576698