@@ -66,33 +66,50 @@ use crate::frame_builder::Frame;
6666use time:: precise_time_ns;
6767use crate :: util:: { Recycler , VecHelper , drain_filter} ;
6868
69-
7069#[ cfg_attr( feature = "capture" , derive( Serialize ) ) ]
7170#[ cfg_attr( feature = "replay" , derive( Deserialize ) ) ]
72- #[ derive( Clone ) ]
71+ #[ derive( Copy , Clone ) ]
7372pub struct DocumentView {
73+ scene : SceneView ,
74+ frame : FrameView ,
75+ }
76+
77+ /// Some rendering parameters applying at the scene level.
78+ #[ cfg_attr( feature = "capture" , derive( Serialize ) ) ]
79+ #[ cfg_attr( feature = "replay" , derive( Deserialize ) ) ]
80+ #[ derive( Copy , Clone ) ]
81+ pub struct SceneView {
7482 pub device_rect : DeviceIntRect ,
7583 pub layer : DocumentLayer ,
76- pub pan : DeviceIntPoint ,
7784 pub device_pixel_ratio : f32 ,
7885 pub page_zoom_factor : f32 ,
79- pub pinch_zoom_factor : f32 ,
8086 pub quality_settings : QualitySettings ,
8187}
8288
83- impl DocumentView {
84- pub fn accumulated_scale_factor ( & self ) -> DevicePixelScale {
89+ impl SceneView {
90+ pub fn accumulated_scale_factor_for_snapping ( & self ) -> DevicePixelScale {
8591 DevicePixelScale :: new (
8692 self . device_pixel_ratio *
87- self . page_zoom_factor *
88- self . pinch_zoom_factor
93+ self . page_zoom_factor
8994 )
9095 }
96+ }
9197
92- pub fn accumulated_scale_factor_for_snapping ( & self ) -> DevicePixelScale {
98+ /// Some rendering parameters applying at the frame level.
99+ #[ cfg_attr( feature = "capture" , derive( Serialize ) ) ]
100+ #[ cfg_attr( feature = "replay" , derive( Deserialize ) ) ]
101+ #[ derive( Copy , Clone ) ]
102+ pub struct FrameView {
103+ pan : DeviceIntPoint ,
104+ pinch_zoom_factor : f32 ,
105+ }
106+
107+ impl DocumentView {
108+ pub fn accumulated_scale_factor ( & self ) -> DevicePixelScale {
93109 DevicePixelScale :: new (
94- self . device_pixel_ratio *
95- self . page_zoom_factor
110+ self . scene . device_pixel_ratio *
111+ self . scene . page_zoom_factor *
112+ self . frame . pinch_zoom_factor
96113 )
97114 }
98115}
@@ -446,13 +463,17 @@ impl Document {
446463 id,
447464 removed_pipelines : Vec :: new ( ) ,
448465 view : DocumentView {
449- device_rect : size. into ( ) ,
450- layer,
451- pan : DeviceIntPoint :: zero ( ) ,
452- page_zoom_factor : 1.0 ,
453- pinch_zoom_factor : 1.0 ,
454- device_pixel_ratio : default_device_pixel_ratio,
455- quality_settings : QualitySettings :: default ( ) ,
466+ scene : SceneView {
467+ device_rect : size. into ( ) ,
468+ layer,
469+ page_zoom_factor : 1.0 ,
470+ device_pixel_ratio : default_device_pixel_ratio,
471+ quality_settings : QualitySettings :: default ( ) ,
472+ } ,
473+ frame : FrameView {
474+ pan : DeviceIntPoint :: new ( 0 , 0 ) ,
475+ pinch_zoom_factor : 1.0 ,
476+ } ,
456477 } ,
457478 stamp : FrameStamp :: first ( id) ,
458479 scene : BuiltScene :: empty ( ) ,
@@ -478,7 +499,7 @@ impl Document {
478499 }
479500
480501 fn has_pixels ( & self ) -> bool {
481- !self . view . device_rect . size . is_empty_or_negative ( )
502+ !self . view . scene . device_rect . size . is_empty_or_negative ( )
482503 }
483504
484505 fn process_frame_msg (
@@ -535,8 +556,8 @@ impl Document {
535556 tx. send ( self . shared_hit_tester . clone ( ) ) . unwrap ( ) ;
536557 }
537558 FrameMsg :: SetPan ( pan) => {
538- if self . view . pan != pan {
539- self . view . pan = pan;
559+ if self . view . frame . pan != pan {
560+ self . view . frame . pan = pan;
540561 self . hit_tester_is_valid = false ;
541562 self . frame_is_valid = false ;
542563 }
@@ -565,8 +586,8 @@ impl Document {
565586 self . dynamic_properties . add_transforms ( property_bindings) ;
566587 }
567588 FrameMsg :: SetPinchZoom ( factor) => {
568- if self . view . pinch_zoom_factor != factor. get ( ) {
569- self . view . pinch_zoom_factor = factor. get ( ) ;
589+ if self . view . frame . pinch_zoom_factor != factor. get ( ) {
590+ self . view . frame . pinch_zoom_factor = factor. get ( ) ;
570591 self . frame_is_valid = false ;
571592 }
572593 }
@@ -594,7 +615,7 @@ impl Document {
594615 tile_cache_logger : & mut TileCacheLogger ,
595616 ) -> RenderedDocument {
596617 let accumulated_scale_factor = self . view . accumulated_scale_factor ( ) ;
597- let pan = self . view . pan . to_f32 ( ) / accumulated_scale_factor;
618+ let pan = self . view . frame . pan . to_f32 ( ) / accumulated_scale_factor;
598619
599620 // Advance to the next frame.
600621 self . stamp . advance ( ) ;
@@ -609,8 +630,8 @@ impl Document {
609630 gpu_cache,
610631 self . stamp ,
611632 accumulated_scale_factor,
612- self . view . layer ,
613- self . view . device_rect . origin ,
633+ self . view . scene . layer ,
634+ self . view . scene . device_rect . origin ,
614635 pan,
615636 resource_profile,
616637 & self . dynamic_properties ,
@@ -637,7 +658,7 @@ impl Document {
637658
638659 fn rebuild_hit_tester ( & mut self ) {
639660 let accumulated_scale_factor = self . view . accumulated_scale_factor ( ) ;
640- let pan = self . view . pan . to_f32 ( ) / accumulated_scale_factor;
661+ let pan = self . view . frame . pan . to_f32 ( ) / accumulated_scale_factor;
641662
642663 self . scene . spatial_tree . update_tree (
643664 pan,
@@ -957,7 +978,7 @@ impl RenderBackend {
957978
958979 if let Some ( doc) = self . documents . get_mut ( & txn. document_id ) {
959980 doc. removed_pipelines . append ( & mut txn. removed_pipelines ) ;
960- doc. view = txn. view ;
981+ doc. view . scene = txn. view ;
961982
962983 if let Some ( built_scene) = txn. built_scene . take ( ) {
963984 doc. new_async_scene_ready (
@@ -1704,7 +1725,7 @@ impl RenderBackend {
17041725 resource_sequence_id : config. resource_id ,
17051726 documents : self . documents
17061727 . iter ( )
1707- . map ( |( id, doc) | ( * id, doc. view . clone ( ) ) )
1728+ . map ( |( id, doc) | ( * id, doc. view ) )
17081729 . collect ( ) ,
17091730 } ;
17101731 config. serialize_for_frame ( & backend, "backend" ) ;
@@ -1832,7 +1853,7 @@ impl RenderBackend {
18321853 resource_sequence_id : 0 ,
18331854 documents : self . documents
18341855 . iter ( )
1835- . map ( |( id, doc) | ( * id, doc. view . clone ( ) ) )
1856+ . map ( |( id, doc) | ( * id, doc. view ) )
18361857 . collect ( ) ,
18371858 } ;
18381859
@@ -1957,7 +1978,7 @@ impl RenderBackend {
19571978 match self . documents . entry ( id) {
19581979 Occupied ( entry) => {
19591980 let doc = entry. into_mut ( ) ;
1960- doc. view = view. clone ( ) ;
1981+ doc. view = view;
19611982 doc. loaded_scene = scene. clone ( ) ;
19621983 doc. data_stores = data_stores;
19631984 doc. dynamic_properties = properties;
@@ -1971,7 +1992,7 @@ impl RenderBackend {
19711992 id,
19721993 scene : BuiltScene :: empty ( ) ,
19731994 removed_pipelines : Vec :: new ( ) ,
1974- view : view . clone ( ) ,
1995+ view,
19751996 stamp : FrameStamp :: first ( id) ,
19761997 frame_builder : FrameBuilder :: new ( ) ,
19771998 dynamic_properties : properties,
@@ -2021,7 +2042,7 @@ impl RenderBackend {
20212042 scenes_to_build. push ( LoadScene {
20222043 document_id : id,
20232044 scene,
2024- view : view. clone ( ) ,
2045+ view : view. scene . clone ( ) ,
20252046 config : self . frame_config . clone ( ) ,
20262047 font_instances : self . resource_cache . get_font_instances ( ) ,
20272048 build_frame,
0 commit comments