libservo: Stop double-buffering OffscreenRenderingContext (#35638)

The `OffscreenRenderingContext` does not need to be double-buffered.
Instead, when resizing the framebuffer, create a new one and blit the
old contents onto the new surface. This allows immediately displaying
the contents without having to render paint the WebRender scene one more
time. In addition to speeding up the rendering pipeline, the goal here
is to reduce flickering during resizes (though there is more work to
do).

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Martin Robinson 2025-02-28 12:41:56 +01:00 committed by GitHub
parent 0065e63190
commit 06d4272462
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 82 additions and 75 deletions

View file

@ -80,15 +80,9 @@ impl Minibrowser {
event_loop: &ActiveEventLoop,
initial_url: ServoUrl,
) -> Self {
let gl = unsafe {
glow::Context::from_loader_function(|s| {
rendering_context.parent_context().get_proc_address(s)
})
};
// Adapted from https://github.com/emilk/egui/blob/9478e50d012c5138551c38cbee16b07bc1fcf283/crates/egui_glow/examples/pure_glow.rs
#[allow(clippy::arc_with_non_send_sync)]
let context = EguiGlow::new(event_loop, Arc::new(gl), None);
let context = EguiGlow::new(event_loop, rendering_context.glow_gl_api(), None);
// Disable the builtin egui handlers for the Ctrl+Plus, Ctrl+Minus and Ctrl+0
// shortcuts as they don't work well with servoshell's `device-pixel-ratio` CLI argument.