-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
epaint: Memoize individual lines during text layout #5411
base: master
Are you sure you want to change the base?
Conversation
Preview available at https://egui-pr-preview.github.io/pr/5411-cache_galley_lines |
Okay, so I did the thing and implemented the Currently this "somewhat" works, I've managed to fix the selection issues I was seeing, but there is some layout issues you can actually see in the live demo above where the text is overlapping sometimes when wrapped (since this was present before the whole |
So I've managed to make this look pretty correct, these are the remaining issues:
|
I think I've made some good progress:
The remaining test failures are:
|
06e639e
to
139f286
Compare
This is an
almost completeimplementation of the approach described by emilk in this comment, excluding CoW semantics forLayoutJob
(but including them forRow
).It supersedes the previous unsuccessful attempt here: #4000.
Draft because:
Currently individual rows will haveends_with_newline
always set to false.This breaks selection with Ctrl+A (and probably many other things)
The whole block for doing the splitting and merging should probably become a function (I'll do that later).I haven't run the check script, the tests, and haven't made sure all of the examples build (although I assume they probably don't rely on Galley internals).Layout is sometimes incorrect (missing empty lines, wrapping sometimes makes text overlap).Row
s. Also this requires that we're fine making these very breaking changes.It does significantly improve the performance of rendering large blocks of text (if they have many newlines), this is the test program I used to test it (adapted from #3086):
code
I think the way to proceed would be to make a new type, something like
PositionedRow
, that would wrap anArc<Row>
but have a separatepos
and(that would meanends_with_newline
Row
only holds asize
instead of arect
). This type would of course have getters that would allow you to easily get aRect
from it and probably aDeref
to the underlyingRow
.I haven't done this yet because I wanted to get some opinions whether this would be an acceptable API first.This is now implemented, but of course I'm still open to discussion about this approach and whether it's what we want to do.Breaking changes (currently):
Galley::rows
field has a different type.PlacedRow
wrapper forRow
.Row
now uses an absolute coordinate system relative to itself instead of theGalley
.TextEdit
#3086