diff options
Diffstat (limited to 'third_party/webrender/example-compositor/compositor')
-rw-r--r-- | third_party/webrender/example-compositor/compositor/Cargo.toml | 5 | ||||
-rw-r--r-- | third_party/webrender/example-compositor/compositor/src/main.rs | 107 |
2 files changed, 19 insertions, 93 deletions
diff --git a/third_party/webrender/example-compositor/compositor/Cargo.toml b/third_party/webrender/example-compositor/compositor/Cargo.toml index 02c6ebe0ce2..d505e9ad295 100644 --- a/third_party/webrender/example-compositor/compositor/Cargo.toml +++ b/third_party/webrender/example-compositor/compositor/Cargo.toml @@ -7,10 +7,7 @@ license = "MPL-2.0" [dependencies] webrender = { path = "../../webrender" } -gleam = "0.15" +gleam = "0.12.0" [target.'cfg(windows)'.dependencies] compositor-windows = { path = "../compositor-windows" } - -[target.'cfg(target_os = "linux")'.dependencies] -compositor-wayland = { path = "../compositor-wayland" } diff --git a/third_party/webrender/example-compositor/compositor/src/main.rs b/third_party/webrender/example-compositor/compositor/src/main.rs index fef9438ec20..b2a7aac3a94 100644 --- a/third_party/webrender/example-compositor/compositor/src/main.rs +++ b/third_party/webrender/example-compositor/compositor/src/main.rs @@ -16,12 +16,10 @@ use euclid::Angle; use gleam::gl; use std::ffi::CString; use std::sync::mpsc; -use webrender::{CompositorSurfaceTransform, Transaction, api::*, euclid::point2}; +use webrender::api::*; use webrender::api::units::*; #[cfg(target_os = "windows")] use compositor_windows as compositor; -#[cfg(target_os = "linux")] -use compositor_wayland as compositor; use std::{env, f32, process}; // A very hacky integration with DirectComposite. It proxies calls from the compositor @@ -44,7 +42,6 @@ impl webrender::Compositor for DirectCompositeInterface { fn create_surface( &mut self, id: webrender::NativeSurfaceId, - _virtual_offset: DeviceIntPoint, tile_size: DeviceIntSize, is_opaque: bool, ) { @@ -92,7 +89,6 @@ impl webrender::Compositor for DirectCompositeInterface { &mut self, id: webrender::NativeTileId, dirty_rect: DeviceIntRect, - _valid_rect: DeviceIntRect, ) -> webrender::NativeSurfaceInfo { let (fbo_id, x, y) = compositor::bind_surface( self.window, @@ -122,15 +118,14 @@ impl webrender::Compositor for DirectCompositeInterface { fn add_surface( &mut self, id: webrender::NativeSurfaceId, - transform: CompositorSurfaceTransform, + position: DeviceIntPoint, clip_rect: DeviceIntRect, - _image_rendering: ImageRendering, ) { compositor::add_surface( self.window, id.0, - transform.transform_point2d(point2(0., 0.)).unwrap().x as i32, - transform.transform_point2d(point2(0., 0.)).unwrap().y as i32, + position.x, + position.y, clip_rect.origin.x, clip_rect.origin.y, clip_rect.size.width, @@ -141,42 +136,6 @@ impl webrender::Compositor for DirectCompositeInterface { fn end_frame(&mut self) { compositor::end_transaction(self.window); } - fn create_external_surface(&mut self, _: webrender::NativeSurfaceId, _: bool) { todo!() } - - fn attach_external_image( - &mut self, - _id: webrender::NativeSurfaceId, - _external_image: ExternalImageId - ) { - todo!() - } - - fn enable_native_compositor(&mut self, _enable: bool) { - todo!() - } - - fn deinit(&mut self) { - compositor::deinit(self.window); - } - - fn get_capabilities(&self) -> webrender::CompositorCapabilities { - webrender::CompositorCapabilities { - virtual_surface_size: 1024 * 1024, - ..Default::default() - } - } - - fn invalidate_tile( - &mut self, - _id: webrender::NativeTileId, - _valid_rect: DeviceIntRect, - ) {} - - fn start_compositing( - &mut self, - _dirty_rects: &[DeviceIntRect], - _opaque_rects: &[DeviceIntRect], - ) {} } // Simplisitic implementation of the WR notifier interface to know when a frame @@ -200,7 +159,7 @@ impl RenderNotifier for Notifier { }) } - fn wake_up(&self, _composite_needed: bool) { + fn wake_up(&self) { } fn new_frame_ready(&self, @@ -222,7 +181,7 @@ fn push_rotated_rect( time: f32, ) { let color = color.scale_rgb(time); - let rotation = LayoutTransform::rotation( + let rotation = LayoutTransform::create_rotation( 0.0, 0.0, 1.0, @@ -235,16 +194,13 @@ fn push_rotated_rect( ); let transform = rotation .pre_translate(-transform_origin) - .then_translate(transform_origin); + .post_translate(transform_origin); let spatial_id = builder.push_reference_frame( LayoutPoint::zero(), spatial_id, TransformStyle::Flat, PropertyBinding::Value(transform), - ReferenceFrameKind::Transform { - is_2d_scale_translation: false, - should_snap: false, - }, + ReferenceFrameKind::Transform, ); builder.push_rect( &CommonItemProperties::new( @@ -279,7 +235,7 @@ fn build_display_list( let scroll_space_info = builder.define_scroll_frame( &fixed_space_info, - scroll_id, + Some(scroll_id), LayoutRect::new(LayoutPoint::zero(), layout_size), LayoutRect::new(LayoutPoint::zero(), layout_size), ScrollSensitivity::Script, @@ -333,32 +289,6 @@ fn build_display_list( 0.1, time, ); - - push_rotated_rect( - builder, - LayoutRect::new( - LayoutPoint::new(100.0, 600.0), - LayoutSize::new(size_factor * 400.0, size_factor * 400.0), - ), - ColorF::new(1.0, 1.0, 0.0, 1.0), - scroll_space_info.spatial_id, - root_pipeline_id, - time, - time, - ); - - push_rotated_rect( - builder, - LayoutRect::new( - LayoutPoint::new(700.0, 600.0), - LayoutSize::new(size_factor * 400.0, size_factor * 400.0), - ), - ColorF::new(0.0, 1.0, 1.0, 1.0), - scroll_space_info.spatial_id, - root_pipeline_id, - time, - time, - ); } #[derive(Debug, Copy, Clone)] @@ -428,15 +358,13 @@ fn main() { } else { webrender::CompositorConfig::Draw { max_partial_present_rects: 0, - draw_previous_partial_present_regions: false, - partial_present: None, } }; let opts = webrender::RendererOptions { clear_color: Some(ColorF::new(1.0, 1.0, 1.0, 1.0)), debug_flags, + enable_picture_caching: true, compositor_config, - surface_origin_is_top_left: false, ..webrender::RendererOptions::default() }; let (tx, rx) = mpsc::channel(); @@ -455,9 +383,10 @@ fn main() { notifier, opts, None, + device_size, ).unwrap(); - let mut api = sender.create_api(); - let document_id = api.add_document(device_size); + let api = sender.create_api(); + let document_id = api.add_document(device_size, 0); let device_pixel_ratio = 1.0; let mut current_epoch = Epoch(0); let root_pipeline_id = PipelineId(0, 0); @@ -470,7 +399,7 @@ fn main() { txn.set_root_pipeline(root_pipeline_id); if let Invalidations::Scrolling = inv_mode { - let mut root_builder = DisplayListBuilder::new(root_pipeline_id); + let mut root_builder = DisplayListBuilder::new(root_pipeline_id, layout_size); build_display_list( &mut root_builder, @@ -490,7 +419,7 @@ fn main() { ); } - txn.generate_frame(0); + txn.generate_frame(); api.send_transaction(document_id, txn); // Tick the compositor (in this sample, we don't block on UI events) @@ -500,7 +429,7 @@ fn main() { // Update and render. This will invoke the native compositor interface implemented above // as required. renderer.update(); - renderer.render(device_size, 0).unwrap(); + renderer.render(device_size).unwrap(); let _ = renderer.flush_pipeline_info(); // Construct a simple display list that can be drawn and composited by DC. @@ -508,7 +437,7 @@ fn main() { match inv_mode { Invalidations::Small | Invalidations::Large => { - let mut root_builder = DisplayListBuilder::new(root_pipeline_id); + let mut root_builder = DisplayListBuilder::new(root_pipeline_id, layout_size); build_display_list( &mut root_builder, @@ -537,7 +466,7 @@ fn main() { } } - txn.generate_frame(0); + txn.generate_frame(); api.send_transaction(document_id, txn); current_epoch.0 += 1; time += 0.001; |