Optimizing label text recaching

I had previously had similar logic in here, but I realized I couldn't
reliably detect if cosmic_text had done any wrapping or not. After a
discussion prompted me to see if recaching was happening while
scrolling, I realized I could at least allow the width to be >= the
measured text size and <= the requested layout width.

This prevents recaching while scrolling.
This commit is contained in:
Jonathan Johnson 2024-04-07 14:33:50 -07:00
parent 20ae2b7c72
commit 5e266f1551
No known key found for this signature in database
GPG key ID: A66D6A34D6620579

View file

@ -52,7 +52,8 @@ where
if cache.text.can_render_to(&context.gfx)
&& cache.generation == check_generation
&& cache.color == color
&& cache.width == width
&& width <= cache.width
&& cache.text.size.width <= width
&& cache.families == current_families => {}
_ => {
let measured = self.display.map(|text| {