From 7a50e9e8fbb8d37e53a42c1dd5936b97463ead53 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 21 Jan 2024 17:56:01 +0100 Subject: Convert `Renderer::Theme` to generic `Widget` type --- wgpu/src/window/compositor.rs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'wgpu/src/window') diff --git a/wgpu/src/window/compositor.rs b/wgpu/src/window/compositor.rs index 31cf3819..58f3f654 100644 --- a/wgpu/src/window/compositor.rs +++ b/wgpu/src/window/compositor.rs @@ -6,21 +6,18 @@ use crate::graphics::compositor; use crate::graphics::{Error, Viewport}; use crate::{Backend, Primitive, Renderer, Settings}; -use std::marker::PhantomData; - /// A window graphics backend for iced powered by `wgpu`. #[allow(missing_debug_implementations)] -pub struct Compositor { +pub struct Compositor { settings: Settings, instance: wgpu::Instance, adapter: wgpu::Adapter, device: wgpu::Device, queue: wgpu::Queue, format: wgpu::TextureFormat, - theme: PhantomData, } -impl Compositor { +impl Compositor { /// Requests a new [`Compositor`] with the given [`Settings`]. /// /// Returns `None` if no compatible graphics adapter could be found. @@ -123,7 +120,6 @@ impl Compositor { device, queue, format, - theme: PhantomData, }) } @@ -135,10 +131,10 @@ impl Compositor { /// Creates a [`Compositor`] and its [`Backend`] for the given [`Settings`] and /// window. -pub fn new( +pub fn new( settings: Settings, compatible_window: W, -) -> Result, Error> { +) -> Result { let compositor = futures::executor::block_on(Compositor::request( settings, Some(compatible_window), @@ -149,8 +145,8 @@ pub fn new( } /// Presents the given primitives with the given [`Compositor`] and [`Backend`]. -pub fn present>( - compositor: &mut Compositor, +pub fn present>( + compositor: &mut Compositor, backend: &mut Backend, surface: &mut wgpu::Surface<'static>, primitives: &[Primitive], @@ -203,9 +199,9 @@ pub fn present>( } } -impl graphics::Compositor for Compositor { +impl graphics::Compositor for Compositor { type Settings = Settings; - type Renderer = Renderer; + type Renderer = Renderer; type Surface = wgpu::Surface<'static>; fn new( @@ -314,8 +310,8 @@ impl graphics::Compositor for Compositor { /// Renders the current surface to an offscreen buffer. /// /// Returns RGBA bytes of the texture data. -pub fn screenshot>( - compositor: &Compositor, +pub fn screenshot>( + compositor: &Compositor, backend: &mut Backend, primitives: &[Primitive], viewport: &Viewport, -- cgit