@@ -186,29 +186,33 @@ impl<'a, 'b, 'c, 'd> SceneBuilder<'a, 'b, 'c, 'd> {
186
186
PrepareMode :: GPU { .. } => None ,
187
187
} ;
188
188
189
- // TODO(pcwalton): Do this earlier?
190
- let scene_is_dirty = match ( & prepare_mode, & self . sink . last_scene ) {
191
- ( & PrepareMode :: GPU { .. } , & None ) => true ,
192
- ( & PrepareMode :: GPU { .. } , & Some ( LastSceneInfo {
193
- scene_id : ref last_scene_id,
194
- scene_epoch : ref last_scene_epoch,
195
- ..
196
- } ) ) => * last_scene_id != self . scene . id ( ) || * last_scene_epoch != self . scene . epoch ( ) ,
197
- _ => false ,
198
- } ;
199
189
200
- if scene_is_dirty {
201
- let built_segments = BuiltSegments :: from_scene ( & self . scene ) ;
202
- self . sink . listener . send ( RenderCommand :: UploadSceneD3D11 {
203
- draw_segments : built_segments. draw_segments ,
204
- clip_segments : built_segments. clip_segments ,
205
- } ) ;
206
- self . sink . last_scene = Some ( LastSceneInfo {
207
- scene_id : self . scene . id ( ) ,
208
- scene_epoch : self . scene . epoch ( ) ,
209
- draw_segment_ranges : built_segments. draw_segment_ranges ,
210
- clip_segment_ranges : built_segments. clip_segment_ranges ,
211
- } ) ;
190
+ #[ cfg( feature="d3d11" ) ]
191
+ {
192
+ // TODO(pcwalton): Do this earlier?
193
+ let scene_is_dirty = match ( & prepare_mode, & self . sink . last_scene ) {
194
+ ( & PrepareMode :: GPU { .. } , & None ) => true ,
195
+ ( & PrepareMode :: GPU { .. } , & Some ( LastSceneInfo {
196
+ scene_id : ref last_scene_id,
197
+ scene_epoch : ref last_scene_epoch,
198
+ ..
199
+ } ) ) => * last_scene_id != self . scene . id ( ) || * last_scene_epoch != self . scene . epoch ( ) ,
200
+ _ => false ,
201
+ } ;
202
+
203
+ if scene_is_dirty {
204
+ let built_segments = BuiltSegments :: from_scene ( & self . scene ) ;
205
+ self . sink . listener . send ( RenderCommand :: UploadSceneD3D11 {
206
+ draw_segments : built_segments. draw_segments ,
207
+ clip_segments : built_segments. clip_segments ,
208
+ } ) ;
209
+ self . sink . last_scene = Some ( LastSceneInfo {
210
+ scene_id : self . scene . id ( ) ,
211
+ scene_epoch : self . scene . epoch ( ) ,
212
+ draw_segment_ranges : built_segments. draw_segment_ranges ,
213
+ clip_segment_ranges : built_segments. clip_segment_ranges ,
214
+ } ) ;
215
+ }
212
216
}
213
217
214
218
self . finish_building ( & paint_metadata, built_paths, & prepare_mode) ;
@@ -314,6 +318,7 @@ impl<'a, 'b, 'c, 'd> SceneBuilder<'a, 'b, 'c, 'd> {
314
318
}
315
319
316
320
fn send_fills ( & self , fills : Vec < Fill > ) {
321
+ #[ cfg( feature="d3d9" ) ]
317
322
if !fills. is_empty ( ) {
318
323
self . sink . listener . send ( RenderCommand :: AddFillsD3D9 ( fills) ) ;
319
324
}
@@ -356,8 +361,9 @@ impl<'a, 'b, 'c, 'd> SceneBuilder<'a, 'b, 'c, 'd> {
356
361
built_paths : Option < BuiltPaths > ,
357
362
prepare_mode : & PrepareMode ) {
358
363
match self . sink . renderer_level {
364
+ #[ cfg( feature="d3d9" ) ]
359
365
RendererLevel :: D3D9 => self . sink . listener . send ( RenderCommand :: FlushFillsD3D9 ) ,
360
- RendererLevel :: D3D11 => { }
366
+ _ => { }
361
367
}
362
368
363
369
self . build_tile_batches ( paint_metadata, prepare_mode, built_paths) ;
@@ -837,13 +843,16 @@ impl SegmentsD3D11 {
837
843
struct TileBatchBuilder {
838
844
prepare_commands : Vec < RenderCommand > ,
839
845
draw_commands : Vec < RenderCommand > ,
846
+ #[ cfg( feature="d3d11" ) ]
840
847
clip_batches_d3d11 : Option < ClipBatchesD3D11 > ,
841
848
next_batch_id : TileBatchId ,
842
849
level : TileBatchBuilderLevel ,
843
850
}
844
851
845
852
enum TileBatchBuilderLevel {
853
+ #[ cfg( feature="d3d9" ) ]
846
854
D3D9 { built_paths : BuiltPaths } ,
855
+ #[ cfg( feature="d3d11" ) ]
847
856
D3D11 ,
848
857
}
849
858
@@ -853,6 +862,7 @@ impl TileBatchBuilder {
853
862
prepare_commands : vec ! [ ] ,
854
863
draw_commands : vec ! [ ] ,
855
864
next_batch_id : TileBatchId ( MAX_CLIP_BATCHES ) ,
865
+ #[ cfg( feature="d3d11" ) ]
856
866
clip_batches_d3d11 : match built_paths {
857
867
None => {
858
868
Some ( ClipBatchesD3D11 {
@@ -863,8 +873,12 @@ impl TileBatchBuilder {
863
873
Some ( _) => None ,
864
874
} ,
865
875
level : match built_paths {
876
+ #[ cfg( feature="d3d11" ) ]
866
877
None => TileBatchBuilderLevel :: D3D11 ,
878
+ #[ cfg( feature="d3d9" ) ]
867
879
Some ( built_paths) => TileBatchBuilderLevel :: D3D9 { built_paths } ,
880
+ #[ allow( unreachable_patterns) ]
881
+ _ => unreachable ! ( )
868
882
} ,
869
883
}
870
884
}
@@ -880,6 +894,7 @@ impl TileBatchBuilder {
880
894
for draw_path_id in draw_path_id_range. start . 0 ..draw_path_id_range. end . 0 {
881
895
let draw_path_id = DrawPathId ( draw_path_id) ;
882
896
let draw_path = match self . level {
897
+ #[ cfg( feature="d3d11" ) ]
883
898
TileBatchBuilderLevel :: D3D11 { .. } => {
884
899
match self . prepare_draw_path_for_gpu_binning ( scene,
885
900
built_options,
@@ -890,17 +905,20 @@ impl TileBatchBuilder {
890
905
Some ( built_draw_path) => Cow :: Owned ( built_draw_path) ,
891
906
}
892
907
}
908
+ #[ cfg( feature="d3d9" ) ]
893
909
TileBatchBuilderLevel :: D3D9 { ref built_paths } => {
894
910
Cow :: Borrowed ( & built_paths. draw [ draw_path_id. 0 as usize ] )
895
911
}
896
912
} ;
897
913
898
914
// Try to reuse the current batch if we can.
899
915
let flush_needed = match draw_tile_batch {
916
+ #[ cfg( feature="d3d11" ) ]
900
917
Some ( DrawTileBatch :: D3D11 ( ref mut existing_batch) ) => {
901
918
!fixup_batch_for_new_path_if_possible ( & mut existing_batch. color_texture ,
902
919
& draw_path)
903
920
}
921
+ #[ cfg( feature="d3d9" ) ]
904
922
Some ( DrawTileBatch :: D3D9 ( ref mut existing_batch) ) => {
905
923
!fixup_batch_for_new_path_if_possible ( & mut existing_batch. color_texture ,
906
924
& draw_path)
@@ -911,9 +929,11 @@ impl TileBatchBuilder {
911
929
// If we couldn't reuse the batch, flush it.
912
930
if flush_needed {
913
931
match draw_tile_batch. take ( ) {
932
+ #[ cfg( feature="d3d11" ) ]
914
933
Some ( DrawTileBatch :: D3D11 ( batch_to_flush) ) => {
915
934
self . draw_commands . push ( RenderCommand :: DrawTilesD3D11 ( batch_to_flush) ) ;
916
935
}
936
+ #[ cfg( feature="d3d9" ) ]
917
937
Some ( DrawTileBatch :: D3D9 ( batch_to_flush) ) => {
918
938
self . draw_commands . push ( RenderCommand :: DrawTilesD3D9 ( batch_to_flush) ) ;
919
939
}
@@ -924,6 +944,7 @@ impl TileBatchBuilder {
924
944
// Create a new batch if necessary.
925
945
if draw_tile_batch. is_none ( ) {
926
946
draw_tile_batch = match self . level {
947
+ #[ cfg( feature="d3d9" ) ]
927
948
TileBatchBuilderLevel :: D3D9 { .. } => {
928
949
let tile_bounds = tiles:: round_rect_out_to_tile_bounds ( scene. view_box ( ) ) ;
929
950
Some ( DrawTileBatch :: D3D9 ( DrawTileBatchD3D9 {
@@ -935,6 +956,7 @@ impl TileBatchBuilder {
935
956
blend_mode : draw_path. blend_mode ,
936
957
} ) )
937
958
}
959
+ #[ cfg( feature="d3d11" ) ]
938
960
TileBatchBuilderLevel :: D3D11 { .. } => {
939
961
Some ( DrawTileBatch :: D3D11 ( DrawTileBatchD3D11 {
940
962
tile_batch_data : TileBatchDataD3D11 :: new ( self . next_batch_id ,
@@ -948,6 +970,7 @@ impl TileBatchBuilder {
948
970
}
949
971
950
972
// Add clip path if necessary.
973
+ #[ cfg( feature="d3d11" ) ]
951
974
let clip_path = match self . clip_batches_d3d11 {
952
975
None => None ,
953
976
Some ( ref mut clip_batches_d3d11) => {
@@ -963,16 +986,20 @@ impl TileBatchBuilder {
963
986
964
987
let draw_tile_batch = draw_tile_batch. as_mut ( ) . unwrap ( ) ;
965
988
match * draw_tile_batch {
989
+ #[ cfg( feature="d3d11" ) ]
966
990
DrawTileBatch :: D3D11 ( ref mut draw_tile_batch) => {
967
991
draw_tile_batch. tile_batch_data . push ( & draw_path. path ,
968
992
draw_path_id. to_path_id ( ) ,
969
993
clip_path,
970
994
draw_path. occludes ,
971
995
sink) ;
972
996
}
997
+ #[ cfg( feature="d3d9" ) ]
973
998
DrawTileBatch :: D3D9 ( ref mut draw_tile_batch) => {
974
999
let built_paths = match self . level {
1000
+ #[ cfg( feature="d3d9" ) ]
975
1001
TileBatchBuilderLevel :: D3D9 { ref built_paths } => built_paths,
1002
+ #[ cfg( feature="d3d11" ) ]
976
1003
TileBatchBuilderLevel :: D3D11 { .. } => unreachable ! ( ) ,
977
1004
} ;
978
1005
@@ -1016,9 +1043,11 @@ impl TileBatchBuilder {
1016
1043
}
1017
1044
1018
1045
match draw_tile_batch {
1046
+ #[ cfg( feature="d3d11" ) ]
1019
1047
Some ( DrawTileBatch :: D3D11 ( draw_tile_batch) ) => {
1020
1048
self . draw_commands . push ( RenderCommand :: DrawTilesD3D11 ( draw_tile_batch) ) ;
1021
1049
}
1050
+ #[ cfg( feature="d3d9" ) ]
1022
1051
Some ( DrawTileBatch :: D3D9 ( draw_tile_batch) ) => {
1023
1052
self . draw_commands . push ( RenderCommand :: DrawTilesD3D9 ( draw_tile_batch) ) ;
1024
1053
}
@@ -1066,6 +1095,7 @@ impl TileBatchBuilder {
1066
1095
}
1067
1096
1068
1097
fn send_to ( self , sink : & SceneSink ) {
1098
+ #[ cfg( feature="d3d11" ) ]
1069
1099
if let Some ( clip_batches_d3d11) = self . clip_batches_d3d11 {
1070
1100
for prepare_batch in clip_batches_d3d11. prepare_batches . into_iter ( ) . rev ( ) {
1071
1101
if prepare_batch. path_count > 0 {
@@ -1083,12 +1113,14 @@ impl TileBatchBuilder {
1083
1113
}
1084
1114
}
1085
1115
1116
+ #[ cfg( feature="d3d11" ) ]
1086
1117
struct ClipBatchesD3D11 {
1087
1118
// Will be submitted in reverse (LIFO) order.
1088
1119
prepare_batches : Vec < TileBatchDataD3D11 > ,
1089
1120
clip_id_to_path_batch_index : FxHashMap < ClipPathId , PathBatchIndex > ,
1090
1121
}
1091
1122
1123
+ #[ cfg( feature="d3d11" ) ]
1092
1124
fn add_clip_path_to_batch ( scene : & Scene ,
1093
1125
sink : & SceneSink ,
1094
1126
built_options : & PreparedBuildOptions ,
@@ -1145,6 +1177,7 @@ fn add_clip_path_to_batch(scene: &Scene,
1145
1177
}
1146
1178
}
1147
1179
1180
+ #[ cfg( feature="d3d11" ) ]
1148
1181
fn prepare_clip_path_for_gpu_binning ( scene : & Scene ,
1149
1182
sink : & SceneSink ,
1150
1183
built_options : & PreparedBuildOptions ,
0 commit comments