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

Remove unnecessary parts2 #4508

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 13 additions & 47 deletions crates/eframe/src/native/glow_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,43 +565,6 @@ impl GlowWinitRunning {
(raw_input, viewport_ui_cb)
};

let clear_color = self
.app
.clear_color(&self.integration.egui_ctx.style().visuals);

let has_many_viewports = self.glutin.borrow().viewports.len() > 1;
let clear_before_update = !has_many_viewports; // HACK: for some reason, an early clear doesn't "take" on Mac with multiple viewports.

if clear_before_update {
// clear before we call update, so users can paint between clear-color and egui windows:

let mut glutin = self.glutin.borrow_mut();
let GlutinWindowContext {
viewports,
current_gl_context,
..
} = &mut *glutin;
let viewport = &viewports[&viewport_id];
let Some(window) = viewport.window.as_ref() else {
return EventResult::Wait;
};
let Some(gl_surface) = viewport.gl_surface.as_ref() else {
return EventResult::Wait;
};

let screen_size_in_pixels: [u32; 2] = window.inner_size().into();

{
frame_timer.pause();
change_gl_context(current_gl_context, gl_surface);
frame_timer.resume();
}

self.painter
.borrow()
.clear(screen_size_in_pixels, clear_color);
}

// ------------------------------------------------------------
// The update function, which could call immediate viewports,
// so make sure we don't hold any locks here required by the immediate viewports rendeer.
Expand Down Expand Up @@ -642,13 +605,17 @@ impl GlowWinitRunning {
let Some(viewport) = viewports.get_mut(&viewport_id) else {
return EventResult::Wait;
};

viewport.info.events.clear(); // they should have been processed
let window = viewport.window.clone().unwrap();
let gl_surface = viewport.gl_surface.as_ref().unwrap();
let egui_winit = viewport.egui_winit.as_mut().unwrap();

egui_winit.handle_platform_output(&window, platform_output);
let (Some(egui_winit), Some(window), Some(gl_surface)) = (
&mut viewport.egui_winit,
&viewport.window.clone(),
&viewport.gl_surface,
) else {
return EventResult::Wait;
};

egui_winit.handle_platform_output(window, platform_output);

let clipped_primitives = integration.egui_ctx.tessellate(shapes, pixels_per_point);

Expand All @@ -660,10 +627,9 @@ impl GlowWinitRunning {
}

let screen_size_in_pixels: [u32; 2] = window.inner_size().into();
let clear_color = app.clear_color(&integration.egui_ctx.style().visuals);

if !clear_before_update {
painter.clear(screen_size_in_pixels, clear_color);
}
painter.clear(screen_size_in_pixels, clear_color);

painter.paint_and_update_textures(
screen_size_in_pixels,
Expand Down Expand Up @@ -705,7 +671,7 @@ impl GlowWinitRunning {
}
}

integration.post_rendering(&window);
integration.post_rendering(window);
}

{
Expand Down Expand Up @@ -734,7 +700,7 @@ impl GlowWinitRunning {

integration.report_frame_time(frame_timer.total_time_sec()); // don't count auto-save time as part of regular frame time

integration.maybe_autosave(app.as_mut(), Some(&window));
integration.maybe_autosave(app.as_mut(), Some(window));

if window.is_minimized() == Some(true) {
// On Mac, a minimized Window uses up all CPU:
Expand Down
Loading