@@ -66,33 +66,50 @@ use crate::frame_builder::Frame;
66
66
use time:: precise_time_ns;
67
67
use crate :: util:: { Recycler , VecHelper , drain_filter} ;
68
68
69
-
70
69
#[ cfg_attr( feature = "capture" , derive( Serialize ) ) ]
71
70
#[ cfg_attr( feature = "replay" , derive( Deserialize ) ) ]
72
- #[ derive( Clone ) ]
71
+ #[ derive( Copy , Clone ) ]
73
72
pub 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 {
74
82
pub device_rect : DeviceIntRect ,
75
83
pub layer : DocumentLayer ,
76
- pub pan : DeviceIntPoint ,
77
84
pub device_pixel_ratio : f32 ,
78
85
pub page_zoom_factor : f32 ,
79
- pub pinch_zoom_factor : f32 ,
80
86
pub quality_settings : QualitySettings ,
81
87
}
82
88
83
- impl DocumentView {
84
- pub fn accumulated_scale_factor ( & self ) -> DevicePixelScale {
89
+ impl SceneView {
90
+ pub fn accumulated_scale_factor_for_snapping ( & self ) -> DevicePixelScale {
85
91
DevicePixelScale :: new (
86
92
self . device_pixel_ratio *
87
- self . page_zoom_factor *
88
- self . pinch_zoom_factor
93
+ self . page_zoom_factor
89
94
)
90
95
}
96
+ }
91
97
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 {
93
109
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
96
113
)
97
114
}
98
115
}
@@ -446,13 +463,17 @@ impl Document {
446
463
id,
447
464
removed_pipelines : Vec :: new ( ) ,
448
465
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
+ } ,
456
477
} ,
457
478
stamp : FrameStamp :: first ( id) ,
458
479
scene : BuiltScene :: empty ( ) ,
@@ -478,7 +499,7 @@ impl Document {
478
499
}
479
500
480
501
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 ( )
482
503
}
483
504
484
505
fn process_frame_msg (
@@ -535,8 +556,8 @@ impl Document {
535
556
tx. send ( self . shared_hit_tester . clone ( ) ) . unwrap ( ) ;
536
557
}
537
558
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;
540
561
self . hit_tester_is_valid = false ;
541
562
self . frame_is_valid = false ;
542
563
}
@@ -565,8 +586,8 @@ impl Document {
565
586
self . dynamic_properties . add_transforms ( property_bindings) ;
566
587
}
567
588
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 ( ) ;
570
591
self . frame_is_valid = false ;
571
592
}
572
593
}
@@ -594,7 +615,7 @@ impl Document {
594
615
tile_cache_logger : & mut TileCacheLogger ,
595
616
) -> RenderedDocument {
596
617
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;
598
619
599
620
// Advance to the next frame.
600
621
self . stamp . advance ( ) ;
@@ -609,8 +630,8 @@ impl Document {
609
630
gpu_cache,
610
631
self . stamp ,
611
632
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 ,
614
635
pan,
615
636
resource_profile,
616
637
& self . dynamic_properties ,
@@ -637,7 +658,7 @@ impl Document {
637
658
638
659
fn rebuild_hit_tester ( & mut self ) {
639
660
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;
641
662
642
663
self . scene . spatial_tree . update_tree (
643
664
pan,
@@ -957,7 +978,7 @@ impl RenderBackend {
957
978
958
979
if let Some ( doc) = self . documents . get_mut ( & txn. document_id ) {
959
980
doc. removed_pipelines . append ( & mut txn. removed_pipelines ) ;
960
- doc. view = txn. view ;
981
+ doc. view . scene = txn. view ;
961
982
962
983
if let Some ( built_scene) = txn. built_scene . take ( ) {
963
984
doc. new_async_scene_ready (
@@ -1704,7 +1725,7 @@ impl RenderBackend {
1704
1725
resource_sequence_id : config. resource_id ,
1705
1726
documents : self . documents
1706
1727
. iter ( )
1707
- . map ( |( id, doc) | ( * id, doc. view . clone ( ) ) )
1728
+ . map ( |( id, doc) | ( * id, doc. view ) )
1708
1729
. collect ( ) ,
1709
1730
} ;
1710
1731
config. serialize_for_frame ( & backend, "backend" ) ;
@@ -1832,7 +1853,7 @@ impl RenderBackend {
1832
1853
resource_sequence_id : 0 ,
1833
1854
documents : self . documents
1834
1855
. iter ( )
1835
- . map ( |( id, doc) | ( * id, doc. view . clone ( ) ) )
1856
+ . map ( |( id, doc) | ( * id, doc. view ) )
1836
1857
. collect ( ) ,
1837
1858
} ;
1838
1859
@@ -1957,7 +1978,7 @@ impl RenderBackend {
1957
1978
match self . documents . entry ( id) {
1958
1979
Occupied ( entry) => {
1959
1980
let doc = entry. into_mut ( ) ;
1960
- doc. view = view. clone ( ) ;
1981
+ doc. view = view;
1961
1982
doc. loaded_scene = scene. clone ( ) ;
1962
1983
doc. data_stores = data_stores;
1963
1984
doc. dynamic_properties = properties;
@@ -1971,7 +1992,7 @@ impl RenderBackend {
1971
1992
id,
1972
1993
scene : BuiltScene :: empty ( ) ,
1973
1994
removed_pipelines : Vec :: new ( ) ,
1974
- view : view . clone ( ) ,
1995
+ view,
1975
1996
stamp : FrameStamp :: first ( id) ,
1976
1997
frame_builder : FrameBuilder :: new ( ) ,
1977
1998
dynamic_properties : properties,
@@ -2021,7 +2042,7 @@ impl RenderBackend {
2021
2042
scenes_to_build. push ( LoadScene {
2022
2043
document_id : id,
2023
2044
scene,
2024
- view : view. clone ( ) ,
2045
+ view : view. scene . clone ( ) ,
2025
2046
config : self . frame_config . clone ( ) ,
2026
2047
font_instances : self . resource_cache . get_font_instances ( ) ,
2027
2048
build_frame,
0 commit comments