From 5b6e205e998cbb20b3c8aaff8b515d78315d6703 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 27 Jun 2023 20:26:13 +0200 Subject: Simplify `offscreen` API as `color` module in `iced_wgpu` --- wgpu/src/window/compositor.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'wgpu/src/window') diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index 43c3dce5..1cfd7b67 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -345,17 +345,26 @@ pub fn screenshot>( let view = texture.create_view(&wgpu::TextureViewDescriptor::default()); - let rgba_texture = backend.offscreen( + backend.present( &compositor.device, &compositor.queue, &mut encoder, Some(background_color), &view, - compositor.format, primitives, viewport, overlay, - texture_extent, + ); + + let texture = crate::color::convert( + &compositor.device, + &mut encoder, + texture, + if color::GAMMA_CORRECTION { + wgpu::TextureFormat::Rgba8UnormSrgb + } else { + wgpu::TextureFormat::Rgba8Unorm + }, ); let output_buffer = @@ -368,7 +377,7 @@ pub fn screenshot>( }); encoder.copy_texture_to_buffer( - rgba_texture.unwrap_or(texture).as_image_copy(), + texture.as_image_copy(), wgpu::ImageCopyBuffer { buffer: &output_buffer, layout: wgpu::ImageDataLayout { -- cgit