Remove image abstractions in iced_graphics
This commit is contained in:
parent
9b4bcd287a
commit
3a26baa564
11 changed files with 352 additions and 436 deletions
|
|
@ -1,5 +1,11 @@
|
|||
mod atlas;
|
||||
|
||||
#[cfg(feature = "image")]
|
||||
mod raster;
|
||||
|
||||
#[cfg(feature = "svg")]
|
||||
mod vector;
|
||||
|
||||
use atlas::Atlas;
|
||||
|
||||
use crate::core::{Rectangle, Size};
|
||||
|
|
@ -7,12 +13,6 @@ use crate::graphics::Transformation;
|
|||
use crate::layer;
|
||||
use crate::Buffer;
|
||||
|
||||
#[cfg(feature = "image")]
|
||||
use crate::graphics::image::raster;
|
||||
|
||||
#[cfg(feature = "svg")]
|
||||
use crate::graphics::image::vector;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::mem;
|
||||
|
||||
|
|
@ -30,9 +30,9 @@ use tracing::info_span;
|
|||
#[derive(Debug)]
|
||||
pub struct Pipeline {
|
||||
#[cfg(feature = "image")]
|
||||
raster_cache: RefCell<raster::Cache<Atlas>>,
|
||||
raster_cache: RefCell<raster::Cache>,
|
||||
#[cfg(feature = "svg")]
|
||||
vector_cache: RefCell<vector::Cache<Atlas>>,
|
||||
vector_cache: RefCell<vector::Cache>,
|
||||
|
||||
pipeline: wgpu::RenderPipeline,
|
||||
vertices: wgpu::Buffer,
|
||||
|
|
@ -368,8 +368,10 @@ impl Pipeline {
|
|||
#[cfg(feature = "image")]
|
||||
layer::Image::Raster { handle, bounds } => {
|
||||
if let Some(atlas_entry) = raster_cache.upload(
|
||||
device,
|
||||
queue,
|
||||
encoder,
|
||||
handle,
|
||||
&mut (device, queue, encoder),
|
||||
&mut self.texture_atlas,
|
||||
) {
|
||||
add_instances(
|
||||
|
|
@ -392,11 +394,13 @@ impl Pipeline {
|
|||
let size = [bounds.width, bounds.height];
|
||||
|
||||
if let Some(atlas_entry) = vector_cache.upload(
|
||||
device,
|
||||
queue,
|
||||
encoder,
|
||||
handle,
|
||||
*color,
|
||||
size,
|
||||
_scale,
|
||||
&mut (device, queue, encoder),
|
||||
&mut self.texture_atlas,
|
||||
) {
|
||||
add_instances(
|
||||
|
|
@ -477,21 +481,12 @@ impl Pipeline {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn end_frame(
|
||||
&mut self,
|
||||
device: &wgpu::Device,
|
||||
queue: &wgpu::Queue,
|
||||
encoder: &mut wgpu::CommandEncoder,
|
||||
) {
|
||||
pub fn end_frame(&mut self) {
|
||||
#[cfg(feature = "image")]
|
||||
self.raster_cache
|
||||
.borrow_mut()
|
||||
.trim(&mut self.texture_atlas, &mut (device, queue, encoder));
|
||||
self.raster_cache.borrow_mut().trim(&mut self.texture_atlas);
|
||||
|
||||
#[cfg(feature = "svg")]
|
||||
self.vector_cache
|
||||
.borrow_mut()
|
||||
.trim(&mut self.texture_atlas, &mut (device, queue, encoder));
|
||||
self.vector_cache.borrow_mut().trim(&mut self.texture_atlas);
|
||||
|
||||
self.prepare_layer = 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue