1
- extern crate app_units;
2
1
extern crate webrender;
3
2
extern crate glutin;
4
3
extern crate gleam;
@@ -9,9 +8,8 @@ use euclid::{Size2D, Point2D, Rect, Matrix4D};
9
8
use gleam:: gl;
10
9
use std:: path:: PathBuf ;
11
10
use std:: ffi:: CStr ;
12
- use webrender_traits:: { PipelineId , StackingContextId , DisplayListId } ;
13
- use webrender_traits:: { AuxiliaryListsBuilder , Epoch , ColorF , GlyphInstance } ;
14
- use webrender_traits:: { ImageFormat , RendererKind } ;
11
+ use webrender_traits:: { AuxiliaryListsBuilder , ColorF , Epoch , GlyphInstance } ;
12
+ use webrender_traits:: { ImageFormat , PipelineId , RendererKind } ;
15
13
use std:: fs:: File ;
16
14
use std:: io:: Read ;
17
15
use std:: env;
@@ -36,54 +34,10 @@ impl Notifier {
36
34
}
37
35
38
36
pub struct WebRenderFrameBuilder {
39
- pub stacking_contexts : Vec < ( StackingContextId , webrender_traits:: StackingContext ) > ,
40
- pub display_lists : Vec < ( DisplayListId , webrender_traits:: BuiltDisplayList ) > ,
41
- pub auxiliary_lists_builder : AuxiliaryListsBuilder ,
42
37
pub root_pipeline_id : PipelineId ,
43
38
pub next_scroll_layer_id : usize ,
44
39
}
45
40
46
- impl WebRenderFrameBuilder {
47
- pub fn new ( root_pipeline_id : PipelineId ) -> WebRenderFrameBuilder {
48
- WebRenderFrameBuilder {
49
- stacking_contexts : vec ! [ ] ,
50
- display_lists : vec ! [ ] ,
51
- auxiliary_lists_builder : AuxiliaryListsBuilder :: new ( ) ,
52
- root_pipeline_id : root_pipeline_id,
53
- next_scroll_layer_id : 0 ,
54
- }
55
- }
56
-
57
- pub fn add_stacking_context ( & mut self ,
58
- api : & mut webrender_traits:: RenderApi ,
59
- pipeline_id : PipelineId ,
60
- stacking_context : webrender_traits:: StackingContext )
61
- -> StackingContextId {
62
- assert ! ( pipeline_id == self . root_pipeline_id) ;
63
- let id = api. next_stacking_context_id ( ) ;
64
- self . stacking_contexts . push ( ( id, stacking_context) ) ;
65
- id
66
- }
67
-
68
- pub fn add_display_list ( & mut self ,
69
- api : & mut webrender_traits:: RenderApi ,
70
- display_list : webrender_traits:: BuiltDisplayList ,
71
- stacking_context : & mut webrender_traits:: StackingContext )
72
- -> DisplayListId {
73
- let id = api. next_display_list_id ( ) ;
74
- stacking_context. display_lists . push ( id) ;
75
- self . display_lists . push ( ( id, display_list) ) ;
76
- id
77
- }
78
-
79
- pub fn next_scroll_layer_id ( & mut self ) -> webrender_traits:: ScrollLayerId {
80
- let scroll_layer_id = webrender_traits:: ServoScrollRootId ( self . next_scroll_layer_id ) ;
81
- self . next_scroll_layer_id += 1 ;
82
- webrender_traits:: ScrollLayerId :: new ( self . root_pipeline_id , 0 , scroll_layer_id)
83
- }
84
-
85
- }
86
-
87
41
impl webrender_traits:: RenderNotifier for Notifier {
88
42
fn new_frame_ready ( & mut self ) {
89
43
self . window_proxy . wakeup_event_loop ( ) ;
@@ -144,7 +98,7 @@ fn main() {
144
98
} ;
145
99
146
100
let ( mut renderer, sender) = webrender:: renderer:: Renderer :: new ( opts) ;
147
- let mut api = sender. create_api ( ) ;
101
+ let api = sender. create_api ( ) ;
148
102
149
103
// let font_path = "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf";
150
104
// let font_bytes = load_file(font_path);
@@ -157,11 +111,15 @@ fn main() {
157
111
let epoch = Epoch ( 0 ) ;
158
112
let root_background_color = ColorF :: new ( 0.3 , 0.0 , 0.0 , 1.0 ) ;
159
113
160
- let mut frame_builder = WebRenderFrameBuilder :: new ( pipeline_id) ;
161
- let root_scroll_layer_id = frame_builder. next_scroll_layer_id ( ) ;
114
+ let mut auxiliary_lists_builder = AuxiliaryListsBuilder :: new ( ) ;
115
+ let mut builder = webrender_traits:: DisplayListBuilder :: new ( ) ;
116
+
117
+ let root_scroll_layer_id =
118
+ webrender_traits:: ScrollLayerId :: new ( pipeline_id, 0 ,
119
+ webrender_traits:: ServoScrollRootId ( 0 ) ) ;
162
120
163
121
let bounds = Rect :: new ( Point2D :: new ( 0.0 , 0.0 ) , Size2D :: new ( width as f32 , height as f32 ) ) ;
164
- let mut sc =
122
+ builder . push_stacking_context (
165
123
webrender_traits:: StackingContext :: new ( Some ( root_scroll_layer_id) ,
166
124
webrender_traits:: ScrollPolicy :: Scrollable ,
167
125
bounds,
@@ -172,9 +130,7 @@ fn main() {
172
130
true ,
173
131
webrender_traits:: MixBlendMode :: Normal ,
174
132
Vec :: new ( ) ,
175
- & mut frame_builder. auxiliary_lists_builder ) ;
176
-
177
- let mut builder = webrender_traits:: DisplayListBuilder :: new ( ) ;
133
+ & mut auxiliary_lists_builder) ) ;
178
134
179
135
let clip_region = {
180
136
let rect = Rect :: new ( Point2D :: new ( 100.0 , 100.0 ) , Size2D :: new ( 100.0 , 100.0 ) ) ;
@@ -189,7 +145,7 @@ fn main() {
189
145
webrender_traits:: ClipRegion :: new ( & bounds,
190
146
vec ! [ complex] ,
191
147
Some ( mask) ,
192
- & mut frame_builder . auxiliary_lists_builder )
148
+ & mut auxiliary_lists_builder)
193
149
} ;
194
150
195
151
builder. push_rect ( Rect :: new ( Point2D :: new ( 100.0 , 100.0 ) , Size2D :: new ( 100.0 , 100.0 ) ) ,
@@ -270,19 +226,15 @@ fn main() {
270
226
// Au::from_px(0),
271
227
// &mut frame_builder.auxiliary_lists_builder);
272
228
273
- frame_builder. add_display_list ( & mut api, builder. finalize ( ) , & mut sc) ;
274
- let sc_id = frame_builder. add_stacking_context ( & mut api, pipeline_id, sc) ;
275
-
276
- api. set_root_stacking_context ( sc_id,
277
- root_background_color,
278
- epoch,
279
- pipeline_id,
280
- Size2D :: new ( width as f32 , height as f32 ) ,
281
- frame_builder. stacking_contexts ,
282
- frame_builder. display_lists ,
283
- frame_builder. auxiliary_lists_builder
284
- . finalize ( ) ) ;
229
+ builder. pop_stacking_context ( ) ;
285
230
231
+ api. set_root_display_list (
232
+ root_background_color,
233
+ epoch,
234
+ pipeline_id,
235
+ Size2D :: new ( width as f32 , height as f32 ) ,
236
+ builder. finalize ( ) ,
237
+ auxiliary_lists_builder. finalize ( ) ) ;
286
238
api. set_root_pipeline ( pipeline_id) ;
287
239
288
240
for event in window. wait_events ( ) {
0 commit comments