@@ -12,7 +12,6 @@ use std::{
1212 u32,
1313} ;
1414
15-
1615#[ derive( Debug ) ]
1716pub struct Pipeline {
1817 cache : RefCell < Cache > ,
@@ -220,10 +219,11 @@ impl Pipeline {
220219 opt. usvg . dpi = handle. dpi as f64 ;
221220 opt. usvg . font_size = handle. font_size as f64 ;
222221
223- let mem = match resvg:: usvg:: Tree :: from_file ( & handle. path , & opt. usvg ) {
224- Ok ( tree) => Memory :: Host { tree } ,
225- Err ( _) => Memory :: Invalid
226- } ;
222+ let mem =
223+ match resvg:: usvg:: Tree :: from_file ( & handle. path , & opt. usvg ) {
224+ Ok ( tree) => Memory :: Host { tree } ,
225+ Err ( _) => Memory :: Invalid ,
226+ } ;
227227
228228 let _ = self . cache . borrow_mut ( ) . insert ( & handle, mem) ;
229229 }
@@ -265,12 +265,14 @@ impl Pipeline {
265265
266266 self . load ( & handle) ;
267267
268- if let Some ( texture) = self
269- . cache
270- . borrow_mut ( )
271- . get ( & handle)
272- . unwrap ( )
273- . upload ( device, encoder, & self . texture_layout , svg. scale [ 0 ] as u32 , svg. scale [ 1 ] as u32 )
268+ if let Some ( texture) =
269+ self . cache . borrow_mut ( ) . get ( & handle) . unwrap ( ) . upload (
270+ device,
271+ encoder,
272+ & self . texture_layout ,
273+ svg. scale [ 0 ] as u32 ,
274+ svg. scale [ 1 ] as u32 ,
275+ )
274276 {
275277 let instance_buffer = device
276278 . create_buffer_mapped ( 1 , wgpu:: BufferUsage :: COPY_SRC )
@@ -409,12 +411,8 @@ impl Hash for Handle {
409411}
410412
411413enum Memory {
412- Host {
413- tree : resvg:: usvg:: Tree ,
414- } ,
415- Device {
416- bind_group : Rc < wgpu:: BindGroup > ,
417- } ,
414+ Host { tree : resvg:: usvg:: Tree } ,
415+ Device { bind_group : Rc < wgpu:: BindGroup > } ,
418416 NotFound ,
419417 Invalid ,
420418}
@@ -426,7 +424,7 @@ impl Memory {
426424 encoder : & mut wgpu:: CommandEncoder ,
427425 texture_layout : & wgpu:: BindGroupLayout ,
428426 width : u32 ,
429- height : u32
427+ height : u32 ,
430428 ) -> Option < Rc < wgpu:: BindGroup > > {
431429 match self {
432430 Memory :: Host { tree } => {
@@ -447,10 +445,17 @@ impl Memory {
447445 | wgpu:: TextureUsage :: SAMPLED ,
448446 } ) ;
449447
450- let mut canvas = resvg:: raqote:: DrawTarget :: new ( width as i32 , height as i32 ) ;
448+ let mut canvas =
449+ resvg:: raqote:: DrawTarget :: new ( width as i32 , height as i32 ) ;
451450 let opt = resvg:: Options :: default ( ) ;
452- let screen_size = resvg:: ScreenSize :: new ( width, height) . unwrap ( ) ;
453- resvg:: backend_raqote:: render_to_canvas ( tree, & opt, screen_size, & mut canvas) ;
451+ let screen_size =
452+ resvg:: ScreenSize :: new ( width, height) . unwrap ( ) ;
453+ resvg:: backend_raqote:: render_to_canvas (
454+ tree,
455+ & opt,
456+ screen_size,
457+ & mut canvas,
458+ ) ;
454459 let slice = canvas. get_data ( ) ;
455460 let temp_buf = device
456461 . create_buffer_mapped (
@@ -506,7 +511,10 @@ impl Memory {
506511}
507512
508513impl Debug for Memory {
509- fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> Result < ( ) , std:: fmt:: Error > {
514+ fn fmt (
515+ & self ,
516+ f : & mut std:: fmt:: Formatter < ' _ > ,
517+ ) -> Result < ( ) , std:: fmt:: Error > {
510518 match self {
511519 Memory :: Host { .. } => write ! ( f, "Memory::Host" ) ,
512520 Memory :: Device { .. } => write ! ( f, "Memory::Device" ) ,
@@ -593,4 +601,4 @@ struct Instance {
593601#[ derive( Debug , Clone , Copy ) ]
594602struct Uniforms {
595603 transform : [ f32 ; 16 ] ,
596- }
604+ }
0 commit comments