-
Notifications
You must be signed in to change notification settings - Fork 604
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
Add Rust API to grab the contents of a slint::Window into a slint::SharedImageBuffer #5445
Conversation
999268c
to
40c4b01
Compare
40c4b01
to
7d2c74d
Compare
I tested this locally by taking a screenshot when pressing a button in the gallery and saving it to disk. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this new API also be used (there therefore covered) by the screenshot test?
But that wouldn't let us apply custom dirty region or rotation.
let mut target_buffer = | ||
SharedPixelBuffer::<i_slint_core::graphics::Rgb8Pixel>::new(width, height); | ||
|
||
self.force_next_frame_new_buffer.set(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you need force_next_frame_new_buffer given that you already set the buffer type in the next line? This will clear the caches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, this isn't needed indeed. That said, I think I need to clear caches after this rendering, as the next call - from the windowing system or user - might pass an "age 1" buffer for example and caches don't apply to that one (As it's a different buffer).
…e RendererSealed trait
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can there be tests?
@@ -116,4 +117,10 @@ pub trait RendererSealed { | |||
fn resize(&self, _size: crate::api::PhysicalSize) -> Result<(), PlatformError> { | |||
Ok(()) | |||
} | |||
|
|||
/// Re-implement this function to support Window::grab_window(), i.e. return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment seems outdated since there isn't a grab_window funtion anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That’s still the name in the public API.
Co-authored-by: Olivier Goffart <[email protected]>
I suppose I can add one to verify we don’t crash and return a non-empty array, but other than that I don’t think so. I’ll add that to my todo next week. |
One "easy" test might be with something like |
No description provided.