8
8
//! See the comment at the top of the `renderer` module for a description of
9
9
//! how these two pieces interact.
10
10
11
- use api:: { ApiMsg , BuiltDisplayList , ClearCache , DebugCommand , DebugFlags } ;
11
+ use api:: { ApiMsg , ClearCache , DebugCommand , DebugFlags } ;
12
12
use api:: { DocumentId , DocumentLayer , ExternalScrollId , FrameMsg , HitTestFlags , HitTestResult } ;
13
13
use api:: { IdNamespace , MemoryReport , PipelineId , RenderNotifier , SceneMsg , ScrollClamping } ;
14
14
use api:: { ScrollLocation , TransactionMsg , ResourceUpdate , BlobImageKey } ;
@@ -30,7 +30,7 @@ use crate::glyph_rasterizer::{FontInstance};
30
30
use crate :: gpu_cache:: GpuCache ;
31
31
use crate :: hit_test:: { HitTest , HitTester , SharedHitTester } ;
32
32
use crate :: intern:: DataStore ;
33
- use crate :: internal_types:: { DebugOutput , FastHashMap , FastHashSet , RenderedDocument , ResultMsg } ;
33
+ use crate :: internal_types:: { DebugOutput , FastHashMap , RenderedDocument , ResultMsg } ;
34
34
use malloc_size_of:: { MallocSizeOf , MallocSizeOfOps } ;
35
35
use crate :: picture:: { RetainedTiles , TileCacheLogger } ;
36
36
use crate :: prim_store:: { PrimitiveScratchBuffer , PrimitiveInstance } ;
@@ -398,10 +398,6 @@ struct Document {
398
398
/// The builder object that prodces frames, kept around to preserve some retained state.
399
399
frame_builder : FrameBuilder ,
400
400
401
- /// A set of pipelines that the caller has requested be
402
- /// made available as output textures.
403
- output_pipelines : FastHashSet < PipelineId > ,
404
-
405
401
/// A data structure to allow hit testing against rendered frames. This is updated
406
402
/// every time we produce a fully rendered frame.
407
403
hit_tester : Option < Arc < HitTester > > ,
@@ -461,7 +457,6 @@ impl Document {
461
457
stamp : FrameStamp :: first ( id) ,
462
458
scene : BuiltScene :: empty ( ) ,
463
459
frame_builder : FrameBuilder :: new ( ) ,
464
- output_pipelines : FastHashSet :: default ( ) ,
465
460
hit_tester : None ,
466
461
shared_hit_tester : Arc :: new ( SharedHitTester :: new ( ) ) ,
467
462
dynamic_properties : SceneProperties :: new ( ) ,
@@ -665,11 +660,6 @@ impl Document {
665
660
}
666
661
}
667
662
668
- pub fn discard_frame_state_for_pipeline ( & mut self , pipeline_id : PipelineId ) {
669
- self . scene . spatial_tree
670
- . discard_frame_state_for_pipeline ( pipeline_id) ;
671
- }
672
-
673
663
/// Returns true if any nodes actually changed position or false otherwise.
674
664
pub fn scroll_nearest_scrolling_ancestor (
675
665
& mut self ,
@@ -822,90 +812,6 @@ impl RenderBackend {
822
812
}
823
813
}
824
814
825
- fn process_scene_msg (
826
- & mut self ,
827
- document_id : DocumentId ,
828
- message : SceneMsg ,
829
- txn : & mut Transaction ,
830
- ) {
831
- let doc = self . documents . get_mut ( & document_id) . expect ( "No document?" ) ;
832
-
833
- match message {
834
- SceneMsg :: UpdateEpoch ( pipeline_id, epoch) => {
835
- txn. epoch_updates . push ( ( pipeline_id, epoch) ) ;
836
- }
837
- SceneMsg :: SetPageZoom ( factor) => {
838
- doc. view . page_zoom_factor = factor. get ( ) ;
839
- }
840
- SceneMsg :: SetQualitySettings { settings } => {
841
- doc. view . quality_settings = settings;
842
- }
843
- SceneMsg :: SetDocumentView {
844
- device_rect,
845
- device_pixel_ratio,
846
- } => {
847
- doc. view . device_rect = device_rect;
848
- doc. view . device_pixel_ratio = device_pixel_ratio;
849
- }
850
- SceneMsg :: SetDisplayList {
851
- epoch,
852
- pipeline_id,
853
- background,
854
- viewport_size,
855
- content_size,
856
- list_descriptor,
857
- list_data,
858
- preserve_frame_state,
859
- } => {
860
- profile_scope ! ( "SetDisplayList" ) ;
861
-
862
- let built_display_list =
863
- BuiltDisplayList :: from_data ( list_data, list_descriptor) ;
864
-
865
- if !preserve_frame_state {
866
- doc. discard_frame_state_for_pipeline ( pipeline_id) ;
867
- }
868
-
869
- let display_list_len = built_display_list. data ( ) . len ( ) ;
870
- let ( builder_start_time_ns, builder_end_time_ns, send_time_ns) =
871
- built_display_list. times ( ) ;
872
-
873
- txn. display_list_updates . push ( DisplayListUpdate {
874
- built_display_list,
875
- pipeline_id,
876
- epoch,
877
- background,
878
- viewport_size,
879
- content_size,
880
- timings : TransactionTimings {
881
- builder_start_time_ns,
882
- builder_end_time_ns,
883
- send_time_ns,
884
- scene_build_start_time_ns : 0 ,
885
- scene_build_end_time_ns : 0 ,
886
- blob_rasterization_end_time_ns : 0 ,
887
- display_list_len,
888
- } ,
889
- } ) ;
890
- }
891
- SceneMsg :: SetRootPipeline ( pipeline_id) => {
892
- profile_scope ! ( "SetRootPipeline" ) ;
893
- txn. set_root_pipeline = Some ( pipeline_id) ;
894
- }
895
- SceneMsg :: RemovePipeline ( pipeline_id) => {
896
- profile_scope ! ( "RemovePipeline" ) ;
897
- txn. removed_pipelines . push ( ( pipeline_id, document_id) ) ;
898
- }
899
- SceneMsg :: EnableFrameOutput ( pipeline_id, enable) => {
900
- if enable {
901
- doc. output_pipelines . insert ( pipeline_id) ;
902
- } else {
903
- doc. output_pipelines . remove ( & pipeline_id) ;
904
- }
905
- }
906
- }
907
- }
908
-
909
815
fn next_namespace_id ( & self ) -> IdNamespace {
910
816
IdNamespace ( NEXT_NAMESPACE_ID . fetch_add ( 1 , Ordering :: Relaxed ) as u32 )
911
817
}
@@ -1051,6 +957,7 @@ impl RenderBackend {
1051
957
1052
958
if let Some ( doc) = self . documents . get_mut ( & txn. document_id ) {
1053
959
doc. removed_pipelines . append ( & mut txn. removed_pipelines ) ;
960
+ doc. view = txn. view ;
1054
961
1055
962
if let Some ( built_scene) = txn. built_scene . take ( ) {
1056
963
doc. new_async_scene_ready (
@@ -1178,6 +1085,11 @@ impl RenderBackend {
1178
1085
) ;
1179
1086
let old = self . documents . insert ( document_id, document) ;
1180
1087
debug_assert ! ( old. is_none( ) ) ;
1088
+
1089
+ self . scene_tx . send (
1090
+ SceneBuilderRequest :: AddDocument ( document_id, initial_size, layer)
1091
+ ) . unwrap ( ) ;
1092
+
1181
1093
}
1182
1094
ApiMsg :: DeleteDocument ( document_id) => {
1183
1095
self . documents . remove ( & document_id) ;
@@ -1405,39 +1317,41 @@ impl RenderBackend {
1405
1317
let use_high_priority = transaction_msgs. iter ( )
1406
1318
. any ( |transaction_msg| !transaction_msg. low_priority ) ;
1407
1319
1408
- let mut txns : Vec < Box < Transaction > > = document_ids. iter ( ) . zip ( transaction_msgs. drain ( ..) )
1320
+ let txns : Vec < Box < Transaction > > = document_ids. iter ( ) . zip ( transaction_msgs. drain ( ..) )
1409
1321
. map ( |( & document_id, mut transaction_msg) | {
1322
+
1323
+ self . resource_cache . pre_scene_building_update (
1324
+ & mut transaction_msg. resource_updates ,
1325
+ & mut profile_counters. resources ,
1326
+ ) ;
1327
+
1328
+ // TODO(nical) I believe this is wrong. We should discard this state when swapping the
1329
+ // scene after it is built.
1330
+ for msg in & transaction_msg. scene_ops {
1331
+ if let SceneMsg :: SetDisplayList { preserve_frame_state : false , pipeline_id, .. } = * msg {
1332
+ self . documents
1333
+ . get_mut ( & document_id)
1334
+ . unwrap ( )
1335
+ . scene
1336
+ . spatial_tree
1337
+ . discard_frame_state_for_pipeline ( pipeline_id) ;
1338
+ }
1339
+ }
1340
+
1410
1341
let mut txn = Box :: new ( Transaction {
1411
1342
document_id,
1412
- display_list_updates : Vec :: new ( ) ,
1413
- removed_pipelines : Vec :: new ( ) ,
1414
- epoch_updates : Vec :: new ( ) ,
1415
- request_scene_build : None ,
1416
1343
blob_rasterizer : None ,
1417
1344
blob_requests : Vec :: new ( ) ,
1418
1345
resource_updates : transaction_msg. resource_updates ,
1419
1346
frame_ops : transaction_msg. frame_ops ,
1347
+ scene_ops : transaction_msg. scene_ops ,
1420
1348
rasterized_blobs : Vec :: new ( ) ,
1421
1349
notifications : transaction_msg. notifications ,
1422
- set_root_pipeline : None ,
1423
1350
render_frame : transaction_msg. generate_frame ,
1424
1351
invalidate_rendered_frame : transaction_msg. invalidate_rendered_frame ,
1352
+ fonts : self . resource_cache . get_font_instances ( ) ,
1425
1353
} ) ;
1426
1354
1427
- self . resource_cache . pre_scene_building_update (
1428
- & mut txn. resource_updates ,
1429
- & mut profile_counters. resources ,
1430
- ) ;
1431
-
1432
- for scene_msg in transaction_msg. scene_ops . drain ( ..) {
1433
- let _timer = profile_counters. total_time . timer ( ) ;
1434
- self . process_scene_msg (
1435
- document_id,
1436
- scene_msg,
1437
- & mut txn,
1438
- )
1439
- }
1440
-
1441
1355
let blobs_to_rasterize = get_blob_image_updates ( & txn. resource_updates ) ;
1442
1356
if !blobs_to_rasterize. is_empty ( ) {
1443
1357
let ( blob_rasterizer, blob_requests) = self . resource_cache
@@ -1453,19 +1367,7 @@ impl RenderBackend {
1453
1367
!txn. can_skip_scene_builder ( ) || txn. blob_rasterizer . is_some ( )
1454
1368
} ) ;
1455
1369
1456
- if use_scene_builder {
1457
- for txn in txns. iter_mut ( ) {
1458
- let doc = self . documents . get_mut ( & txn. document_id ) . unwrap ( ) ;
1459
-
1460
- if txn. should_build_scene ( ) {
1461
- txn. request_scene_build = Some ( SceneRequest {
1462
- view : doc. view . clone ( ) ,
1463
- font_instances : self . resource_cache . get_font_instances ( ) ,
1464
- output_pipelines : doc. output_pipelines . clone ( ) ,
1465
- } ) ;
1466
- }
1467
- }
1468
- } else {
1370
+ if !use_scene_builder {
1469
1371
self . prepare_for_frames ( ) ;
1470
1372
self . maybe_force_nop_documents (
1471
1373
frame_counter,
@@ -2072,7 +1974,6 @@ impl RenderBackend {
2072
1974
view : view. clone ( ) ,
2073
1975
stamp : FrameStamp :: first ( id) ,
2074
1976
frame_builder : FrameBuilder :: new ( ) ,
2075
- output_pipelines : FastHashSet :: default ( ) ,
2076
1977
dynamic_properties : properties,
2077
1978
hit_tester : None ,
2078
1979
shared_hit_tester : Arc :: new ( SharedHitTester :: new ( ) ) ,
@@ -2122,7 +2023,6 @@ impl RenderBackend {
2122
2023
scene,
2123
2024
view : view. clone ( ) ,
2124
2025
config : self . frame_config . clone ( ) ,
2125
- output_pipelines : self . documents [ & id] . output_pipelines . clone ( ) ,
2126
2026
font_instances : self . resource_cache . get_font_instances ( ) ,
2127
2027
build_frame,
2128
2028
interners,
0 commit comments