servo / webrender

A GPU-based renderer for the web
https://doc.servo.org/webrender/
Mozilla Public License 2.0
3.11k stars 276 forks source link

Select glyph based on subpixel offset in vertex shader. #1632

Closed glennw closed 6 years ago

glennw commented 7 years ago

Currently, we handle subpixel positioning of glyphs (along the layout axis direction), by selecting which glyph to use on the CPU based on the subpixel offset.

Instead, we should do this:

This has several benefits:

[1] Once a glyph is used, it's likely that somewhere on the page will require each of the subpx variations, so this shouldn't add any overhead in most normal cases. [2] If we arrange the four glyphs in a 2x2 configuration, this will keep the allocation sizes square-ish enough to work well with the texture cache slab allocator.

glennw commented 7 years ago

cc @kvark @nical

gw3583 commented 6 years ago

It turns out that we want to do the subpixel selection based on the local position anyway (otherwise we get 'swimming' of glyphs within a word in some animation cases). Although this code is still in a hot spot, we can handle that by caching text runs between frames and display lists.