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/lib.rs | 2 +- wgpu/src/primitive/pipeline.rs | 2 +- wgpu/src/window/compositor.rs | 24 ++++++++++-------------- 3 files changed, 12 insertions(+), 16 deletions(-) (limited to 'wgpu') diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs index 424dfeb3..b00e5c3c 100644 --- a/wgpu/src/lib.rs +++ b/wgpu/src/lib.rs @@ -63,4 +63,4 @@ mod image; /// /// [`wgpu`]: https://github.com/gfx-rs/wgpu-rs /// [`iced`]: https://github.com/iced-rs/iced -pub type Renderer = iced_graphics::Renderer; +pub type Renderer = iced_graphics::Renderer; diff --git a/wgpu/src/primitive/pipeline.rs b/wgpu/src/primitive/pipeline.rs index c8e45458..c6b7c5e2 100644 --- a/wgpu/src/primitive/pipeline.rs +++ b/wgpu/src/primitive/pipeline.rs @@ -67,7 +67,7 @@ pub trait Renderer: crate::core::Renderer { ); } -impl Renderer for crate::Renderer { +impl Renderer for crate::Renderer { fn draw_pipeline_primitive( &mut self, bounds: Rectangle, 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