Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fonts are not clipped to scroll region when rendered #20

Closed
dhardy opened this issue Dec 12, 2019 · 2 comments
Closed

Fonts are not clipped to scroll region when rendered #20

dhardy opened this issue Dec 12, 2019 · 2 comments

Comments

@dhardy
Copy link
Collaborator

dhardy commented Dec 12, 2019

This is a known caveat of #19: most drawables are clipped to the region by use of a separate render pass; doing the same for fonts is less easy. To quote myself from that PR:

This is because glyph_brush draws everything in a single render pass, which doesn't let us apply GPU scissor regions as required. Options:

  • Queue sections for each region independently, using a new render pass for each region. This is what Iced does, but is not quite so easy with KAS's render pipe. This also implies one should use GlyphBrush::keep_cached to keep sections in the cache (which Iced currently doesn't; hint @hecrj).
  • Use a separate instance of GlyphBrush for each region. This makes it easy to queue sections correctly, but requires constructing new instances on demand (may cause lag) and prevents sharing of cached glyphs.
  • Use the z value included in sections and assign a distinct depth value to each layer. Needs further investigation.
  • Perform clipping within wgpu_glyph by adding a bounding rect to each section.

This turned out more complex than I had expected. @hecrj may I ask if you put any effort into investigating alternatives here?

@hecrj
Copy link

hecrj commented Dec 12, 2019

The proper fix for this is to overhaul wgpu_glyph and make the cache aware of multiple draw calls.

I have plans to change wgpu_glyph heavily at some point to support shaping and use a faster font rasterizer. It will probably turn into a new crate. I will most likely tackle this issue then.

@dhardy
Copy link
Collaborator Author

dhardy commented May 4, 2020

This was fixed in #94 via use of a depth-buffer. This may in any case be the best solution since it enables fonts to be drawn in a single pass, including on (and under) pop-up layers.

@dhardy dhardy closed this as completed May 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants