From 4ede482ab5ff6364237f5f4626784075045d5dfb Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 5 Apr 2023 18:41:40 +0200 Subject: Present new frame only when damaged in `iced_tiny_skia` --- tiny_skia/src/window/compositor.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'tiny_skia/src/window/compositor.rs') diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index cea1cabf..6e4bb6ef 100644 --- a/tiny_skia/src/window/compositor.rs +++ b/tiny_skia/src/window/compositor.rs @@ -106,7 +106,7 @@ pub fn present>( ) -> Result<(), compositor::SurfaceError> { let physical_size = viewport.physical_size(); - backend.draw( + let drawn = backend.draw( &mut tiny_skia::PixmapMut::from_bytes( bytemuck::cast_slice_mut(&mut surface.buffer), physical_size.width, @@ -120,11 +120,13 @@ pub fn present>( overlay, ); - surface.window.set_buffer( - &surface.buffer, - physical_size.width as u16, - physical_size.height as u16, - ); + if drawn { + surface.window.set_buffer( + &surface.buffer, + physical_size.width as u16, + physical_size.height as u16, + ); + } Ok(()) } -- cgit From 92d61e5c592818745abbab245a82cb14b262ae67 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 5 Apr 2023 19:23:48 +0200 Subject: Use `softbuffer` fork with owned pixel buffer --- tiny_skia/src/window/compositor.rs | 42 +++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'tiny_skia/src/window/compositor.rs') diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index 6e4bb6ef..5b1e56a4 100644 --- a/tiny_skia/src/window/compositor.rs +++ b/tiny_skia/src/window/compositor.rs @@ -5,6 +5,7 @@ use crate::{Backend, Renderer, Settings}; use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle}; use std::marker::PhantomData; +use std::num::NonZeroU32; pub struct Compositor { clip_mask: tiny_skia::ClipMask, @@ -12,8 +13,7 @@ pub struct Compositor { } pub struct Surface { - window: softbuffer::GraphicsContext, - buffer: Vec, + window: softbuffer::Surface, } impl crate::graphics::Compositor for Compositor { @@ -36,14 +36,20 @@ impl crate::graphics::Compositor for Compositor { width: u32, height: u32, ) -> Surface { - let window = - unsafe { softbuffer::GraphicsContext::new(window, window) } - .expect("Create softbuffer for window"); + let platform = unsafe { softbuffer::Context::new(window) } + .expect("Create softbuffer context"); - Surface { - window, - buffer: vec![0; width as usize * height as usize], - } + let mut window = unsafe { softbuffer::Surface::new(&platform, window) } + .expect("Create softbuffer surface"); + + window + .resize( + NonZeroU32::new(width).unwrap(), + NonZeroU32::new(height).unwrap(), + ) + .expect("Resize surface"); + + Surface { window } } fn configure_surface( @@ -52,7 +58,13 @@ impl crate::graphics::Compositor for Compositor { width: u32, height: u32, ) { - surface.buffer.resize((width * height) as usize, 0); + surface + .window + .resize( + NonZeroU32::new(width).unwrap(), + NonZeroU32::new(height).unwrap(), + ) + .expect("Resize surface"); } fn fetch_information(&self) -> Information { @@ -106,9 +118,11 @@ pub fn present>( ) -> Result<(), compositor::SurfaceError> { let physical_size = viewport.physical_size(); + let mut buffer = surface.window.buffer_mut().expect("Get window buffer"); + let drawn = backend.draw( &mut tiny_skia::PixmapMut::from_bytes( - bytemuck::cast_slice_mut(&mut surface.buffer), + bytemuck::cast_slice_mut(&mut buffer), physical_size.width, physical_size.height, ) @@ -121,11 +135,7 @@ pub fn present>( ); if drawn { - surface.window.set_buffer( - &surface.buffer, - physical_size.width as u16, - physical_size.height as u16, - ); + let _ = buffer.present(); } Ok(()) -- cgit From 940a47eafd098dce3567a95c38dc8697b0fc7115 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 5 Apr 2023 19:30:07 +0200 Subject: Revert "Use `softbuffer` fork with owned pixel buffer" This reverts commit 92d61e5c592818745abbab245a82cb14b262ae67. The owned pixel buffer zeroes the data in some platforms. `softbuffer` will need some first-class support for damage regions. --- tiny_skia/src/window/compositor.rs | 42 +++++++++++++++----------------------- 1 file changed, 16 insertions(+), 26 deletions(-) (limited to 'tiny_skia/src/window/compositor.rs') diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index 5b1e56a4..6e4bb6ef 100644 --- a/tiny_skia/src/window/compositor.rs +++ b/tiny_skia/src/window/compositor.rs @@ -5,7 +5,6 @@ use crate::{Backend, Renderer, Settings}; use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle}; use std::marker::PhantomData; -use std::num::NonZeroU32; pub struct Compositor { clip_mask: tiny_skia::ClipMask, @@ -13,7 +12,8 @@ pub struct Compositor { } pub struct Surface { - window: softbuffer::Surface, + window: softbuffer::GraphicsContext, + buffer: Vec, } impl crate::graphics::Compositor for Compositor { @@ -36,20 +36,14 @@ impl crate::graphics::Compositor for Compositor { width: u32, height: u32, ) -> Surface { - let platform = unsafe { softbuffer::Context::new(window) } - .expect("Create softbuffer context"); + let window = + unsafe { softbuffer::GraphicsContext::new(window, window) } + .expect("Create softbuffer for window"); - let mut window = unsafe { softbuffer::Surface::new(&platform, window) } - .expect("Create softbuffer surface"); - - window - .resize( - NonZeroU32::new(width).unwrap(), - NonZeroU32::new(height).unwrap(), - ) - .expect("Resize surface"); - - Surface { window } + Surface { + window, + buffer: vec![0; width as usize * height as usize], + } } fn configure_surface( @@ -58,13 +52,7 @@ impl crate::graphics::Compositor for Compositor { width: u32, height: u32, ) { - surface - .window - .resize( - NonZeroU32::new(width).unwrap(), - NonZeroU32::new(height).unwrap(), - ) - .expect("Resize surface"); + surface.buffer.resize((width * height) as usize, 0); } fn fetch_information(&self) -> Information { @@ -118,11 +106,9 @@ pub fn present>( ) -> Result<(), compositor::SurfaceError> { let physical_size = viewport.physical_size(); - let mut buffer = surface.window.buffer_mut().expect("Get window buffer"); - let drawn = backend.draw( &mut tiny_skia::PixmapMut::from_bytes( - bytemuck::cast_slice_mut(&mut buffer), + bytemuck::cast_slice_mut(&mut surface.buffer), physical_size.width, physical_size.height, ) @@ -135,7 +121,11 @@ pub fn present>( ); if drawn { - let _ = buffer.present(); + surface.window.set_buffer( + &surface.buffer, + physical_size.width as u16, + physical_size.height as u16, + ); } Ok(()) -- cgit From 16e6efe020e75d51958875fa198196534679af8d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 8 Apr 2023 05:58:27 +0200 Subject: Use `pixels` for presentation in `iced_tiny_skia` when possible --- tiny_skia/src/window/compositor.rs | 76 +++++++++++++++++++++++++++++++------- 1 file changed, 63 insertions(+), 13 deletions(-) (limited to 'tiny_skia/src/window/compositor.rs') diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index 6e4bb6ef..5a0097df 100644 --- a/tiny_skia/src/window/compositor.rs +++ b/tiny_skia/src/window/compositor.rs @@ -11,9 +11,13 @@ pub struct Compositor { _theme: PhantomData, } -pub struct Surface { - window: softbuffer::GraphicsContext, - buffer: Vec, +pub enum Surface { + Cpu { + window: softbuffer::GraphicsContext, + buffer: Vec, + }, + #[cfg(feature = "gpu")] + Gpu { pixels: pixels::Pixels }, } impl crate::graphics::Compositor for Compositor { @@ -36,11 +40,29 @@ impl crate::graphics::Compositor for Compositor { width: u32, height: u32, ) -> Surface { + #[cfg(feature = "gpu")] + { + let surface_texture = + pixels::SurfaceTexture::new(width, height, window); + + if let Ok(pixels) = + pixels::PixelsBuilder::new(width, height, surface_texture) + .texture_format(pixels::wgpu::TextureFormat::Bgra8UnormSrgb) + .build() + { + log::info!("GPU surface created"); + + return Surface::Gpu { pixels }; + } + } + let window = unsafe { softbuffer::GraphicsContext::new(window, window) } .expect("Create softbuffer for window"); - Surface { + log::info!("CPU surface created"); + + Surface::Cpu { window, buffer: vec![0; width as usize * height as usize], } @@ -52,7 +74,19 @@ impl crate::graphics::Compositor for Compositor { width: u32, height: u32, ) { - surface.buffer.resize((width * height) as usize, 0); + match surface { + Surface::Cpu { buffer, .. } => { + buffer.resize((width * height) as usize, 0); + } + #[cfg(feature = "gpu")] + Surface::Gpu { pixels } => { + pixels + .resize_surface(width, height) + .expect("Resize surface"); + + pixels.resize_buffer(width, height).expect("Resize buffer"); + } + } } fn fetch_information(&self) -> Information { @@ -106,9 +140,15 @@ pub fn present>( ) -> Result<(), compositor::SurfaceError> { let physical_size = viewport.physical_size(); + let buffer = match surface { + Surface::Cpu { buffer, .. } => bytemuck::cast_slice_mut(buffer), + #[cfg(feature = "gpu")] + Surface::Gpu { pixels } => pixels.frame_mut(), + }; + let drawn = backend.draw( &mut tiny_skia::PixmapMut::from_bytes( - bytemuck::cast_slice_mut(&mut surface.buffer), + buffer, physical_size.width, physical_size.height, ) @@ -121,12 +161,22 @@ pub fn present>( ); if drawn { - surface.window.set_buffer( - &surface.buffer, - physical_size.width as u16, - physical_size.height as u16, - ); + match surface { + Surface::Cpu { window, buffer } => { + window.set_buffer( + buffer, + physical_size.width as u16, + physical_size.height as u16, + ); + + Ok(()) + } + #[cfg(feature = "gpu")] + Surface::Gpu { pixels } => { + pixels.render().map_err(|_| compositor::SurfaceError::Lost) + } + } + } else { + Ok(()) } - - Ok(()) } -- cgit From 435b54e57ecdaf08b1f36626f0000438895c909d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 26 Apr 2023 16:09:36 +0200 Subject: Revert "Use `pixels` for presentation in `iced_tiny_skia` when possible" This reverts commit 16e6efe020e75d51958875fa198196534679af8d. --- tiny_skia/src/window/compositor.rs | 76 +++++++------------------------------- 1 file changed, 13 insertions(+), 63 deletions(-) (limited to 'tiny_skia/src/window/compositor.rs') diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index 5a0097df..6e4bb6ef 100644 --- a/tiny_skia/src/window/compositor.rs +++ b/tiny_skia/src/window/compositor.rs @@ -11,13 +11,9 @@ pub struct Compositor { _theme: PhantomData, } -pub enum Surface { - Cpu { - window: softbuffer::GraphicsContext, - buffer: Vec, - }, - #[cfg(feature = "gpu")] - Gpu { pixels: pixels::Pixels }, +pub struct Surface { + window: softbuffer::GraphicsContext, + buffer: Vec, } impl crate::graphics::Compositor for Compositor { @@ -40,29 +36,11 @@ impl crate::graphics::Compositor for Compositor { width: u32, height: u32, ) -> Surface { - #[cfg(feature = "gpu")] - { - let surface_texture = - pixels::SurfaceTexture::new(width, height, window); - - if let Ok(pixels) = - pixels::PixelsBuilder::new(width, height, surface_texture) - .texture_format(pixels::wgpu::TextureFormat::Bgra8UnormSrgb) - .build() - { - log::info!("GPU surface created"); - - return Surface::Gpu { pixels }; - } - } - let window = unsafe { softbuffer::GraphicsContext::new(window, window) } .expect("Create softbuffer for window"); - log::info!("CPU surface created"); - - Surface::Cpu { + Surface { window, buffer: vec![0; width as usize * height as usize], } @@ -74,19 +52,7 @@ impl crate::graphics::Compositor for Compositor { width: u32, height: u32, ) { - match surface { - Surface::Cpu { buffer, .. } => { - buffer.resize((width * height) as usize, 0); - } - #[cfg(feature = "gpu")] - Surface::Gpu { pixels } => { - pixels - .resize_surface(width, height) - .expect("Resize surface"); - - pixels.resize_buffer(width, height).expect("Resize buffer"); - } - } + surface.buffer.resize((width * height) as usize, 0); } fn fetch_information(&self) -> Information { @@ -140,15 +106,9 @@ pub fn present>( ) -> Result<(), compositor::SurfaceError> { let physical_size = viewport.physical_size(); - let buffer = match surface { - Surface::Cpu { buffer, .. } => bytemuck::cast_slice_mut(buffer), - #[cfg(feature = "gpu")] - Surface::Gpu { pixels } => pixels.frame_mut(), - }; - let drawn = backend.draw( &mut tiny_skia::PixmapMut::from_bytes( - buffer, + bytemuck::cast_slice_mut(&mut surface.buffer), physical_size.width, physical_size.height, ) @@ -161,22 +121,12 @@ pub fn present>( ); if drawn { - match surface { - Surface::Cpu { window, buffer } => { - window.set_buffer( - buffer, - physical_size.width as u16, - physical_size.height as u16, - ); - - Ok(()) - } - #[cfg(feature = "gpu")] - Surface::Gpu { pixels } => { - pixels.render().map_err(|_| compositor::SurfaceError::Lost) - } - } - } else { - Ok(()) + surface.window.set_buffer( + &surface.buffer, + physical_size.width as u16, + physical_size.height as u16, + ); } + + Ok(()) } -- cgit From 9c63eb7df559e58b14188b4096e9bd206444bbf3 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 26 Apr 2023 16:46:27 +0200 Subject: Update `tiny-skia` and `resvg` --- tiny_skia/src/window/compositor.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'tiny_skia/src/window/compositor.rs') diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index 6e4bb6ef..7523e06f 100644 --- a/tiny_skia/src/window/compositor.rs +++ b/tiny_skia/src/window/compositor.rs @@ -7,13 +7,13 @@ use raw_window_handle::{HasRawDisplayHandle, HasRawWindowHandle}; use std::marker::PhantomData; pub struct Compositor { - clip_mask: tiny_skia::ClipMask, _theme: PhantomData, } pub struct Surface { window: softbuffer::GraphicsContext, buffer: Vec, + clip_mask: tiny_skia::Mask, } impl crate::graphics::Compositor for Compositor { @@ -43,6 +43,8 @@ impl crate::graphics::Compositor for Compositor { Surface { window, buffer: vec![0; width as usize * height as usize], + clip_mask: tiny_skia::Mask::new(width, height) + .expect("Create clip mask"), } } @@ -53,6 +55,8 @@ impl crate::graphics::Compositor for Compositor { height: u32, ) { surface.buffer.resize((width * height) as usize, 0); + surface.clip_mask = + tiny_skia::Mask::new(width, height).expect("Create clip mask"); } fn fetch_information(&self) -> Information { @@ -72,7 +76,6 @@ impl crate::graphics::Compositor for Compositor { ) -> Result<(), SurfaceError> { renderer.with_primitives(|backend, primitives| { present( - self, backend, surface, primitives, @@ -85,18 +88,15 @@ impl crate::graphics::Compositor for Compositor { } pub fn new(settings: Settings) -> (Compositor, Backend) { - // TOD ( Compositor { - clip_mask: tiny_skia::ClipMask::new(), _theme: PhantomData, }, Backend::new(settings), ) } -pub fn present>( - compositor: &mut Compositor, +pub fn present>( backend: &mut Backend, surface: &mut Surface, primitives: &[Primitive], @@ -113,7 +113,7 @@ pub fn present>( physical_size.height, ) .expect("Create pixel map"), - &mut compositor.clip_mask, + &mut surface.clip_mask, primitives, viewport, background_color, -- cgit From af0303f95e27737d9de8915f939b60a2bc3282ae Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 27 Apr 2023 15:10:41 +0200 Subject: Move damage tracking logic to `compositor` in `iced_tiny_skia` --- tiny_skia/src/window/compositor.rs | 54 +++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 15 deletions(-) (limited to 'tiny_skia/src/window/compositor.rs') diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index 7523e06f..d3dffb18 100644 --- a/tiny_skia/src/window/compositor.rs +++ b/tiny_skia/src/window/compositor.rs @@ -1,5 +1,6 @@ -use crate::core::Color; +use crate::core::{Color, Rectangle}; use crate::graphics::compositor::{self, Information, SurfaceError}; +use crate::graphics::damage; use crate::graphics::{Error, Primitive, Viewport}; use crate::{Backend, Renderer, Settings}; @@ -14,6 +15,8 @@ pub struct Surface { window: softbuffer::GraphicsContext, buffer: Vec, clip_mask: tiny_skia::Mask, + last_primitives: Vec, + last_background_color: Color, } impl crate::graphics::Compositor for Compositor { @@ -45,6 +48,8 @@ impl crate::graphics::Compositor for Compositor { buffer: vec![0; width as usize * height as usize], clip_mask: tiny_skia::Mask::new(width, height) .expect("Create clip mask"), + last_primitives: Vec::new(), + last_background_color: Color::BLACK, } } @@ -57,6 +62,8 @@ impl crate::graphics::Compositor for Compositor { surface.buffer.resize((width * height) as usize, 0); surface.clip_mask = tiny_skia::Mask::new(width, height).expect("Create clip mask"); + + surface.last_primitives.clear(); } fn fetch_information(&self) -> Information { @@ -105,28 +112,45 @@ pub fn present>( overlay: &[T], ) -> Result<(), compositor::SurfaceError> { let physical_size = viewport.physical_size(); + let scale_factor = viewport.scale_factor() as f32; + + let mut pixels = &mut tiny_skia::PixmapMut::from_bytes( + bytemuck::cast_slice_mut(&mut surface.buffer), + physical_size.width, + physical_size.height, + ) + .expect("Create pixel map"); + + let damage = if surface.last_background_color == background_color { + damage::list(&surface.last_primitives, primitives) + } else { + vec![Rectangle::with_size(viewport.logical_size())] + }; + + if damage.is_empty() { + return Ok(()); + } + + surface.last_primitives = primitives.to_vec(); + surface.last_background_color = background_color; + + let damage = damage::group(damage, scale_factor, physical_size); - let drawn = backend.draw( - &mut tiny_skia::PixmapMut::from_bytes( - bytemuck::cast_slice_mut(&mut surface.buffer), - physical_size.width, - physical_size.height, - ) - .expect("Create pixel map"), + backend.draw( + &mut pixels, &mut surface.clip_mask, primitives, viewport, + &damage, background_color, overlay, ); - if drawn { - surface.window.set_buffer( - &surface.buffer, - physical_size.width as u16, - physical_size.height as u16, - ); - } + surface.window.set_buffer( + &surface.buffer, + physical_size.width as u16, + physical_size.height as u16, + ); Ok(()) } -- cgit From 92d808ee73b261b639a4a8d1d4f930cd61a380c6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 27 Apr 2023 15:16:05 +0200 Subject: Fix double reference in `compositor` in `iced_tiny_skia` --- tiny_skia/src/window/compositor.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tiny_skia/src/window/compositor.rs') diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index d3dffb18..1bcce6fe 100644 --- a/tiny_skia/src/window/compositor.rs +++ b/tiny_skia/src/window/compositor.rs @@ -114,7 +114,7 @@ pub fn present>( let physical_size = viewport.physical_size(); let scale_factor = viewport.scale_factor() as f32; - let mut pixels = &mut tiny_skia::PixmapMut::from_bytes( + let mut pixels = tiny_skia::PixmapMut::from_bytes( bytemuck::cast_slice_mut(&mut surface.buffer), physical_size.width, physical_size.height, -- cgit From eb1b2bf24174759bba8c63db0ec89c7c6d15d191 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 27 Apr 2023 15:45:02 +0200 Subject: Invalidate `last_primitives` on resize in `iced_tiny_skia` --- tiny_skia/src/window/compositor.rs | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'tiny_skia/src/window/compositor.rs') diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index 1bcce6fe..3bc06970 100644 --- a/tiny_skia/src/window/compositor.rs +++ b/tiny_skia/src/window/compositor.rs @@ -15,7 +15,7 @@ pub struct Surface { window: softbuffer::GraphicsContext, buffer: Vec, clip_mask: tiny_skia::Mask, - last_primitives: Vec, + last_primitives: Option>, last_background_color: Color, } @@ -48,7 +48,7 @@ impl crate::graphics::Compositor for Compositor { buffer: vec![0; width as usize * height as usize], clip_mask: tiny_skia::Mask::new(width, height) .expect("Create clip mask"), - last_primitives: Vec::new(), + last_primitives: None, last_background_color: Color::BLACK, } } @@ -62,8 +62,7 @@ impl crate::graphics::Compositor for Compositor { surface.buffer.resize((width * height) as usize, 0); surface.clip_mask = tiny_skia::Mask::new(width, height).expect("Create clip mask"); - - surface.last_primitives.clear(); + surface.last_primitives = None; } fn fetch_information(&self) -> Information { @@ -121,17 +120,20 @@ pub fn present>( ) .expect("Create pixel map"); - let damage = if surface.last_background_color == background_color { - damage::list(&surface.last_primitives, primitives) - } else { - vec![Rectangle::with_size(viewport.logical_size())] - }; + let damage = surface + .last_primitives + .as_deref() + .and_then(|last_primitives| { + (surface.last_background_color == background_color) + .then(|| damage::list(last_primitives, primitives)) + }) + .unwrap_or_else(|| vec![Rectangle::with_size(viewport.logical_size())]); if damage.is_empty() { return Ok(()); } - surface.last_primitives = primitives.to_vec(); + surface.last_primitives = Some(primitives.to_vec()); surface.last_background_color = background_color; let damage = damage::group(damage, scale_factor, physical_size); -- cgit From a755472ee35dfb7839f989becafc6028921a3b99 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 27 Apr 2023 15:51:51 +0200 Subject: Remove unnecessary `last_` prefix in `Surface` of `iced_tiny_skia` --- tiny_skia/src/window/compositor.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'tiny_skia/src/window/compositor.rs') diff --git a/tiny_skia/src/window/compositor.rs b/tiny_skia/src/window/compositor.rs index 3bc06970..9999a188 100644 --- a/tiny_skia/src/window/compositor.rs +++ b/tiny_skia/src/window/compositor.rs @@ -15,8 +15,8 @@ pub struct Surface { window: softbuffer::GraphicsContext, buffer: Vec, clip_mask: tiny_skia::Mask, - last_primitives: Option>, - last_background_color: Color, + primitives: Option>, + background_color: Color, } impl crate::graphics::Compositor for Compositor { @@ -48,8 +48,8 @@ impl crate::graphics::Compositor for Compositor { buffer: vec![0; width as usize * height as usize], clip_mask: tiny_skia::Mask::new(width, height) .expect("Create clip mask"), - last_primitives: None, - last_background_color: Color::BLACK, + primitives: None, + background_color: Color::BLACK, } } @@ -62,7 +62,7 @@ impl crate::graphics::Compositor for Compositor { surface.buffer.resize((width * height) as usize, 0); surface.clip_mask = tiny_skia::Mask::new(width, height).expect("Create clip mask"); - surface.last_primitives = None; + surface.primitives = None; } fn fetch_information(&self) -> Information { @@ -121,10 +121,10 @@ pub fn present>( .expect("Create pixel map"); let damage = surface - .last_primitives + .primitives .as_deref() .and_then(|last_primitives| { - (surface.last_background_color == background_color) + (surface.background_color == background_color) .then(|| damage::list(last_primitives, primitives)) }) .unwrap_or_else(|| vec![Rectangle::with_size(viewport.logical_size())]); @@ -133,8 +133,8 @@ pub fn present>( return Ok(()); } - surface.last_primitives = Some(primitives.to_vec()); - surface.last_background_color = background_color; + surface.primitives = Some(primitives.to_vec()); + surface.background_color = background_color; let damage = damage::group(damage, scale_factor, physical_size); -- cgit