Conversation
|
I'm also happy to add comments and a screenshot and so on, but I wanted to see if you had any thoughts first. |
dhardy
left a comment
There was a problem hiding this comment.
Thanks for the example. I'll update my PR. (Looks like Sprite::allocate is unnecessary.)
f4a0621 to
c431a1b
Compare
c431a1b to
5cdb278
Compare
Oops, yes, I meant to check that and just forgot.
Never triggering a rerender when one is already in progress could leave the image out of sync with the size of the Also, to fully optimize this, we would want some way to cancel in progress rendering when a resize makes it obsolete. Should
Why does this require us to pass the size into |
| if let Some(NewBuffer { buffer, size }) = cx.try_pop() { | ||
| let draw = cx.draw_shared(); | ||
| if let Some(handle) = self.sprite.handle() | ||
| && draw.image_size(handle) == Some(size) | ||
| { |
There was a problem hiding this comment.
The size test is less important now (image_upload will fail if it doesn't match the allocation).
But what isn't handled here is the case rendering was already in progress when set_rect was last called, and thus size != self.sprite.rect().size, so that needs handling (optionally upload this result anyway).
There was a problem hiding this comment.
We still need to re-allocate if the size of the image has changed. Removing that check won't cause a panic but it will cause the upload to repeatedly fail and so the image won't update.
There was a problem hiding this comment.
You're comparing the size used by the render buffer to the allocation. There's a third size: sprite.rect().size.
At least on my system (Wayland/Linux) resize events can happen rather quickly. When it works right, resizing the window feels very responsive, but it can also cause excessive load.
I don't think this matters. Even if the result is outdated, it's probably more accurate than the previous one, so e.g. Hmm, futures can be "cancelled" by just dropping them (though "cancel safety" depends on the futures). I haven't provided any way of doing that; not sure if I should to be honest. It's still possible for long-running tasks to use shared state to check whether they should terminate themselves. |
Theoretically So go ahead and remove the |
|
You'll also need to check |
|
Converted to draft because I need to spend a bit more time looking at the soft backend to figure out how best to integrate with its existing error-handling scheme. I don't think the previous commit is the best choice. |
crates/kas-soft/src/atlas.rs
Outdated
| SpriteType::Bitmap => self.atlas_rgba.upload(atlas, origin, size, &data), | ||
| } | ||
| }?; | ||
| } |
There was a problem hiding this comment.
These tex uploads (from text glyph rastering) shouldn't fail, but in case they do this shouldn't stop the remaining uploads. Possibly best to catch-and-ignore here with a note about the cause having been logged.
|
@Kwarrtz would you like to rebase your example? The changes to Kas crates are no longer needed. |
262b80f to
d7d4d25
Compare
|
Done. The example itself is pretty much unchanged from before, just had to move the image format argument from |
This adds an example using
Spriteto the existing PR #627