eframe: Early-out from context switching the `glow` backend (#4284)
* Closes https://github.com/emilk/egui/issues/4173
This commit is contained in:
parent
549b243228
commit
e03ea2e17d
|
|
@ -836,6 +836,13 @@ fn change_gl_context(
|
|||
) {
|
||||
crate::profile_function!();
|
||||
|
||||
if let Some(current_gl_context) = current_gl_context {
|
||||
crate::profile_scope!("is_current");
|
||||
if gl_surface.is_current(current_gl_context) {
|
||||
return; // Early-out to save a lot of time.
|
||||
}
|
||||
}
|
||||
|
||||
let not_current = {
|
||||
crate::profile_scope!("make_not_current");
|
||||
current_gl_context
|
||||
|
|
@ -844,6 +851,7 @@ fn change_gl_context(
|
|||
.make_not_current()
|
||||
.unwrap()
|
||||
};
|
||||
|
||||
crate::profile_scope!("make_current");
|
||||
*current_gl_context = Some(not_current.make_current(gl_surface).unwrap());
|
||||
}
|
||||
|
|
@ -1178,15 +1186,7 @@ impl GlutinWindowContext {
|
|||
|
||||
if let Some(viewport) = self.viewports.get(&viewport_id) {
|
||||
if let Some(gl_surface) = &viewport.gl_surface {
|
||||
self.current_gl_context = Some(
|
||||
self.current_gl_context
|
||||
.take()
|
||||
.unwrap()
|
||||
.make_not_current()
|
||||
.unwrap()
|
||||
.make_current(gl_surface)
|
||||
.unwrap(),
|
||||
);
|
||||
change_gl_context(&mut self.current_gl_context, gl_surface);
|
||||
gl_surface.resize(
|
||||
self.current_gl_context
|
||||
.as_ref()
|
||||
|
|
@ -1436,18 +1436,7 @@ fn render_immediate_viewport(
|
|||
|
||||
let screen_size_in_pixels: [u32; 2] = window.inner_size().into();
|
||||
|
||||
{
|
||||
crate::profile_function!("context-switch");
|
||||
*current_gl_context = Some(
|
||||
current_gl_context
|
||||
.take()
|
||||
.unwrap()
|
||||
.make_not_current()
|
||||
.unwrap()
|
||||
.make_current(gl_surface)
|
||||
.unwrap(),
|
||||
);
|
||||
}
|
||||
change_gl_context(current_gl_context, gl_surface);
|
||||
|
||||
let current_gl_context = current_gl_context.as_ref().unwrap();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue