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

Only call wgpu paint callback if viewport is positive #3778

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
54 changes: 25 additions & 29 deletions crates/egui-wgpu/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,39 +450,35 @@ impl Renderer {
continue;
};

if callback.rect.is_positive() {
emilk marked this conversation as resolved.
Show resolved Hide resolved
let info = PaintCallbackInfo {
viewport: callback.rect,
clip_rect: *clip_rect,
pixels_per_point,
screen_size_px: size_in_pixels,
};

let viewport_px = info.viewport_in_pixels();
if viewport_px.width_px > 0 && viewport_px.height_px > 0 {
crate::profile_scope!("callback");

needs_reset = true;

let info = PaintCallbackInfo {
viewport: callback.rect,
clip_rect: *clip_rect,
pixels_per_point,
screen_size_px: size_in_pixels,
};

{
// We're setting a default viewport for the render pass as a
// courtesy for the user, so that they don't have to think about
// it in the simple case where they just want to fill the whole
// paint area.
//
// The user still has the possibility of setting their own custom
// viewport during the paint callback, effectively overriding this
// one.

let viewport_px = info.viewport_in_pixels();

render_pass.set_viewport(
viewport_px.left_px as f32,
viewport_px.top_px as f32,
viewport_px.width_px as f32,
viewport_px.height_px as f32,
0.0,
1.0,
);
}
// We're setting a default viewport for the render pass as a
// courtesy for the user, so that they don't have to think about
// it in the simple case where they just want to fill the whole
// paint area.
//
// The user still has the possibility of setting their own custom
// viewport during the paint callback, effectively overriding this
// one.
render_pass.set_viewport(
viewport_px.left_px as f32,
viewport_px.top_px as f32,
viewport_px.width_px as f32,
viewport_px.height_px as f32,
0.0,
1.0,
);

cbfn.0.paint(info, render_pass, &self.callback_resources);
}
Expand Down