Skip to content
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

Merged
merged 11 commits into from
Jun 22, 2024

Conversation

tronical
Copy link
Member

No description provided.

@tronical tronical requested a review from ogoffart June 20, 2024 14:15
@tronical
Copy link
Member Author

I tested this locally by taking a screenshot when pressing a button in the gallery and saving it to disk.

Copy link
Member

@ogoffart ogoffart left a 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.

internal/backends/linuxkms/fullscreenwindowadapter.rs Outdated Show resolved Hide resolved
internal/backends/winit/lib.rs Outdated Show resolved Hide resolved
let mut target_buffer =
SharedPixelBuffer::<i_slint_core::graphics::Rgb8Pixel>::new(width, height);

self.force_next_frame_new_buffer.set(true);
Copy link
Member

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.

Copy link
Member Author

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).

internal/backends/winit/renderer/sw.rs Outdated Show resolved Hide resolved
Copy link
Member

@ogoffart ogoffart left a 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
Copy link
Member

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

Copy link
Member Author

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.

internal/core/software_renderer.rs Outdated Show resolved Hide resolved
@tronical
Copy link
Member Author

Can there be tests?

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.

@tronical tronical merged commit 977b827 into master Jun 22, 2024
36 checks passed
@tronical tronical deleted the simon/snapshots branch June 22, 2024 07:33
@ogoffart
Copy link
Member

I suppose I can add one to verify we don’t crash and return a non-empty array

One "easy" test might be with something like Rectangle { background: red } or something like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants