grovesNL / glyphon

🦅🦁 Fast, simple 2D text renderer for wgpu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TextArea buffer reference field

madmaxio opened this issue · comments

At the moment text area holds reference for a buffer. This create lifetimes issues when storing text areas somewhere.
Are there any ways to change this API?
Because at the moment it is hard to organize text area storage, and the only usable option is to recreate text areas on every redraw call.

Open to changing this API, but ultimately we'd still need to tie a buffer to TextArea in some way. The idea was that TextArea should be really lightweight to create during setup/preparation for rendering, then the renderer can keep reusing them.

In my application I cache the Buffer and any data I need to set up a TextArea (not the TextArea itself, but it could contain left, top, and bounds if you'd like, or you could derive them from something else), which avoids the lifetime issue.

I agree TextArea should stay as lightweight as possible (maybe even implement Copy). No need to own a Buffer, which would cause problems with reusing buffers. For instance, the current API allows reusing the same buffer multiple times in the same prepare call!

Besides, now that #31 is merged, text areas can be recreated during prepare without allocating a new collection.

I agree TextArea should stay as lightweight as possible (maybe even implement Copy). No need to own a Buffer, which would cause problems with reusing buffers. For instance, the current API allows reusing the same buffer multiple times in the same prepare call!

Besides, now that #31 is merged, text areas can be recreated during prepare without allocating a new collection.

Can you share no allocation example? There is probably on in iced. Because doesn't work for me without mutable reference for collection.