From 10f4292c33cbf7b54cead46acc399940c6ab4f2a Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Tue, 29 May 2018 08:45:25 -0400 Subject: [PATCH] Bug 1464473 - Update webrender to 3829687ffbe8d55885d71a3d5e5e79216251548f. r=Gankro MozReview-Commit-ID: 100EQ2cTdj4 --HG-- extra : rebase_source : 22829dcb9b4a4b07a9b76aea6f1df5c9a1f1b488 --- gfx/webrender/Cargo.toml | 4 +- gfx/webrender/examples/alpha_perf.rs | 13 ++--- gfx/webrender/examples/animation.rs | 25 ++++----- gfx/webrender/examples/basic.rs | 9 ++-- gfx/webrender/examples/blob.rs | 1 + gfx/webrender/examples/common/boilerplate.rs | 52 ++++++++++--------- gfx/webrender/examples/document.rs | 1 + gfx/webrender/examples/frame_output.rs | 1 + gfx/webrender/examples/iframe.rs | 1 + gfx/webrender/examples/image_resize.rs | 11 ++-- gfx/webrender/examples/multiwindow.rs | 29 ++++++----- gfx/webrender/examples/scrolling.rs | 27 +++++----- .../examples/texture_cache_stress.rs | 19 +++---- gfx/webrender/examples/yuv.rs | 3 +- gfx/webrender/src/clip_scroll_node.rs | 25 +++++---- gfx/webrender/src/device.rs | 47 ++++++++++++++--- gfx/webrender/src/lib.rs | 5 +- gfx/webrender/src/renderer.rs | 4 ++ gfx/webrender/src/scene_builder.rs | 5 ++ gfx/webrender_bindings/revision.txt | 2 +- gfx/wrench/Cargo.toml | 3 +- gfx/wrench/src/angle.rs | 6 +-- gfx/wrench/src/egl.rs | 2 +- gfx/wrench/src/main.rs | 46 ++++++++-------- gfx/wrench/src/wrench.rs | 2 +- 25 files changed, 208 insertions(+), 135 deletions(-) diff --git a/gfx/webrender/Cargo.toml b/gfx/webrender/Cargo.toml index 79e6f29b1715..eaea88fa97fa 100644 --- a/gfx/webrender/Cargo.toml +++ b/gfx/webrender/Cargo.toml @@ -15,6 +15,7 @@ capture = ["webrender_api/serialize", "ron", "serde", "debug_renderer"] replay = ["webrender_api/deserialize", "ron", "serde"] debug_renderer = [] pathfinder = ["pathfinder_font_renderer", "pathfinder_gfx_utils", "pathfinder_partitioner", "pathfinder_path_utils"] +serialize_program = ["serde"] [dependencies] app_units = "0.6" @@ -64,7 +65,8 @@ optional = true mozangle = "0.1" env_logger = "0.5" rand = "0.3" # for the benchmarks -glutin = "0.13" # for the example apps +glutin = "0.15" # for the example apps +winit = "0.13" # for the example apps [target.'cfg(any(target_os = "android", all(unix, not(target_os = "macos"))))'.dependencies] freetype = { version = "0.4", default-features = false } diff --git a/gfx/webrender/examples/alpha_perf.rs b/gfx/webrender/examples/alpha_perf.rs index f0b5afb7b63a..9feb9f677afc 100644 --- a/gfx/webrender/examples/alpha_perf.rs +++ b/gfx/webrender/examples/alpha_perf.rs @@ -6,6 +6,7 @@ extern crate euclid; extern crate gleam; extern crate glutin; extern crate webrender; +extern crate winit; #[path = "common/boilerplate.rs"] mod boilerplate; @@ -51,25 +52,25 @@ impl Example for App { fn on_event( &mut self, - event: glutin::WindowEvent, + event: winit::WindowEvent, _api: &RenderApi, _document_id: DocumentId ) -> bool { match event { - glutin::WindowEvent::KeyboardInput { - input: glutin::KeyboardInput { - state: glutin::ElementState::Pressed, + winit::WindowEvent::KeyboardInput { + input: winit::KeyboardInput { + state: winit::ElementState::Pressed, virtual_keycode: Some(key), .. }, .. } => { match key { - glutin::VirtualKeyCode::Right => { + winit::VirtualKeyCode::Right => { self.rect_count += 1; println!("rects = {}", self.rect_count); } - glutin::VirtualKeyCode::Left => { + winit::VirtualKeyCode::Left => { self.rect_count = cmp::max(self.rect_count, 1) - 1; println!("rects = {}", self.rect_count); } diff --git a/gfx/webrender/examples/animation.rs b/gfx/webrender/examples/animation.rs index edfd82d53ace..ad7ecb9d8e7d 100644 --- a/gfx/webrender/examples/animation.rs +++ b/gfx/webrender/examples/animation.rs @@ -14,6 +14,7 @@ extern crate euclid; extern crate gleam; extern crate glutin; extern crate webrender; +extern crate winit; #[path = "common/boilerplate.rs"] mod boilerplate; @@ -74,25 +75,25 @@ impl Example for App { builder.pop_stacking_context(); } - fn on_event(&mut self, win_event: glutin::WindowEvent, api: &RenderApi, document_id: DocumentId) -> bool { + fn on_event(&mut self, win_event: winit::WindowEvent, api: &RenderApi, document_id: DocumentId) -> bool { match win_event { - glutin::WindowEvent::KeyboardInput { - input: glutin::KeyboardInput { - state: glutin::ElementState::Pressed, + winit::WindowEvent::KeyboardInput { + input: winit::KeyboardInput { + state: winit::ElementState::Pressed, virtual_keycode: Some(key), .. }, .. } => { let (offset_x, offset_y, angle, delta_opacity) = match key { - glutin::VirtualKeyCode::Down => (0.0, 10.0, 0.0, 0.0), - glutin::VirtualKeyCode::Up => (0.0, -10.0, 0.0, 0.0), - glutin::VirtualKeyCode::Right => (10.0, 0.0, 0.0, 0.0), - glutin::VirtualKeyCode::Left => (-10.0, 0.0, 0.0, 0.0), - glutin::VirtualKeyCode::Comma => (0.0, 0.0, 0.1, 0.0), - glutin::VirtualKeyCode::Period => (0.0, 0.0, -0.1, 0.0), - glutin::VirtualKeyCode::Z => (0.0, 0.0, 0.0, -0.1), - glutin::VirtualKeyCode::X => (0.0, 0.0, 0.0, 0.1), + winit::VirtualKeyCode::Down => (0.0, 10.0, 0.0, 0.0), + winit::VirtualKeyCode::Up => (0.0, -10.0, 0.0, 0.0), + winit::VirtualKeyCode::Right => (10.0, 0.0, 0.0, 0.0), + winit::VirtualKeyCode::Left => (-10.0, 0.0, 0.0, 0.0), + winit::VirtualKeyCode::Comma => (0.0, 0.0, 0.1, 0.0), + winit::VirtualKeyCode::Period => (0.0, 0.0, -0.1, 0.0), + winit::VirtualKeyCode::Z => (0.0, 0.0, 0.0, -0.1), + winit::VirtualKeyCode::X => (0.0, 0.0, 0.0, 0.1), _ => return false, }; // Update the transform based on the keyboard input and push it to diff --git a/gfx/webrender/examples/basic.rs b/gfx/webrender/examples/basic.rs index d1c93432438b..a49cf1ffbca3 100644 --- a/gfx/webrender/examples/basic.rs +++ b/gfx/webrender/examples/basic.rs @@ -7,13 +7,14 @@ extern crate euclid; extern crate gleam; extern crate glutin; extern crate webrender; +extern crate winit; #[path = "common/boilerplate.rs"] mod boilerplate; use boilerplate::{Example, HandyDandyRectBuilder}; use euclid::vec2; -use glutin::TouchPhase; +use winit::TouchPhase; use std::collections::HashMap; use webrender::api::*; @@ -85,7 +86,7 @@ impl TouchState { } } - fn handle_event(&mut self, touch: glutin::Touch) -> TouchResult { + fn handle_event(&mut self, touch: winit::Touch) -> TouchResult { match touch.phase { TouchPhase::Started => { debug_assert!(!self.active_touches.contains_key(&touch.id)); @@ -274,10 +275,10 @@ impl Example for App { builder.pop_stacking_context(); } - fn on_event(&mut self, event: glutin::WindowEvent, api: &RenderApi, document_id: DocumentId) -> bool { + fn on_event(&mut self, event: winit::WindowEvent, api: &RenderApi, document_id: DocumentId) -> bool { let mut txn = Transaction::new(); match event { - glutin::WindowEvent::Touch(touch) => match self.touch_state.handle_event(touch) { + winit::WindowEvent::Touch(touch) => match self.touch_state.handle_event(touch) { TouchResult::Pan(pan) => { txn.set_pan(pan); } diff --git a/gfx/webrender/examples/blob.rs b/gfx/webrender/examples/blob.rs index 95c490155950..ba2df6943d10 100644 --- a/gfx/webrender/examples/blob.rs +++ b/gfx/webrender/examples/blob.rs @@ -6,6 +6,7 @@ extern crate gleam; extern crate glutin; extern crate rayon; extern crate webrender; +extern crate winit; #[path = "common/boilerplate.rs"] mod boilerplate; diff --git a/gfx/webrender/examples/common/boilerplate.rs b/gfx/webrender/examples/common/boilerplate.rs index 4a86b8cecfc9..4f7c017482f1 100644 --- a/gfx/webrender/examples/common/boilerplate.rs +++ b/gfx/webrender/examples/common/boilerplate.rs @@ -10,14 +10,15 @@ use glutin::{self, GlContext}; use std::env; use std::path::PathBuf; use webrender; +use winit; use webrender::api::*; struct Notifier { - events_proxy: glutin::EventsLoopProxy, + events_proxy: winit::EventsLoopProxy, } impl Notifier { - fn new(events_proxy: glutin::EventsLoopProxy) -> Notifier { + fn new(events_proxy: winit::EventsLoopProxy) -> Notifier { Notifier { events_proxy } } } @@ -76,7 +77,7 @@ pub trait Example { pipeline_id: PipelineId, document_id: DocumentId, ); - fn on_event(&mut self, glutin::WindowEvent, &RenderApi, DocumentId) -> bool { + fn on_event(&mut self, winit::WindowEvent, &RenderApi, DocumentId) -> bool { false } fn get_image_handlers( @@ -103,13 +104,13 @@ pub fn main_wrapper( None }; - let mut events_loop = glutin::EventsLoop::new(); + let mut events_loop = winit::EventsLoop::new(); let context_builder = glutin::ContextBuilder::new() .with_gl(glutin::GlRequest::GlThenGles { opengl_version: (3, 2), opengles_version: (3, 0), }); - let window_builder = glutin::WindowBuilder::new() + let window_builder = winit::WindowBuilder::new() .with_title(E::TITLE) .with_multitouch() .with_dimensions(E::WIDTH, E::HEIGHT); @@ -196,11 +197,14 @@ pub fn main_wrapper( let mut custom_event = true; match global_event { - glutin::Event::WindowEvent { event: glutin::WindowEvent::Closed, .. } => return glutin::ControlFlow::Break, - glutin::Event::WindowEvent { - event: glutin::WindowEvent::KeyboardInput { - input: glutin::KeyboardInput { - state: glutin::ElementState::Pressed, + winit::Event::WindowEvent { + event: winit::WindowEvent::CloseRequested, + .. + } => return winit::ControlFlow::Break, + winit::Event::WindowEvent { + event: winit::WindowEvent::KeyboardInput { + input: winit::KeyboardInput { + state: winit::ElementState::Pressed, virtual_keycode: Some(key), .. }, @@ -208,27 +212,27 @@ pub fn main_wrapper( }, .. } => match key { - glutin::VirtualKeyCode::Escape => return glutin::ControlFlow::Break, - glutin::VirtualKeyCode::P => renderer.toggle_debug_flags(webrender::DebugFlags::PROFILER_DBG), - glutin::VirtualKeyCode::O => renderer.toggle_debug_flags(webrender::DebugFlags::RENDER_TARGET_DBG), - glutin::VirtualKeyCode::I => renderer.toggle_debug_flags(webrender::DebugFlags::TEXTURE_CACHE_DBG), - glutin::VirtualKeyCode::S => renderer.toggle_debug_flags(webrender::DebugFlags::COMPACT_PROFILER), - glutin::VirtualKeyCode::Q => renderer.toggle_debug_flags( + winit::VirtualKeyCode::Escape => return winit::ControlFlow::Break, + winit::VirtualKeyCode::P => renderer.toggle_debug_flags(webrender::DebugFlags::PROFILER_DBG), + winit::VirtualKeyCode::O => renderer.toggle_debug_flags(webrender::DebugFlags::RENDER_TARGET_DBG), + winit::VirtualKeyCode::I => renderer.toggle_debug_flags(webrender::DebugFlags::TEXTURE_CACHE_DBG), + winit::VirtualKeyCode::S => renderer.toggle_debug_flags(webrender::DebugFlags::COMPACT_PROFILER), + winit::VirtualKeyCode::Q => renderer.toggle_debug_flags( webrender::DebugFlags::GPU_TIME_QUERIES | webrender::DebugFlags::GPU_SAMPLE_QUERIES ), - glutin::VirtualKeyCode::Key1 => txn.set_window_parameters( + winit::VirtualKeyCode::Key1 => txn.set_window_parameters( framebuffer_size, DeviceUintRect::new(DeviceUintPoint::zero(), framebuffer_size), 1.0 ), - glutin::VirtualKeyCode::Key2 => txn.set_window_parameters( + winit::VirtualKeyCode::Key2 => txn.set_window_parameters( framebuffer_size, DeviceUintRect::new(DeviceUintPoint::zero(), framebuffer_size), 2.0 ), - glutin::VirtualKeyCode::M => api.notify_memory_pressure(), + winit::VirtualKeyCode::M => api.notify_memory_pressure(), #[cfg(feature = "capture")] - glutin::VirtualKeyCode::C => { + winit::VirtualKeyCode::C => { let path: PathBuf = "../captures/example".into(); //TODO: switch between SCENE/FRAME capture types // based on "shift" modifier, when `glutin` is updated. @@ -237,14 +241,14 @@ pub fn main_wrapper( }, _ => { let win_event = match global_event { - glutin::Event::WindowEvent { event, .. } => event, + winit::Event::WindowEvent { event, .. } => event, _ => unreachable!() }; custom_event = example.on_event(win_event, &api, document_id) }, }, - glutin::Event::WindowEvent { event, .. } => custom_event = example.on_event(event, &api, document_id), - _ => return glutin::ControlFlow::Continue, + winit::Event::WindowEvent { event, .. } => custom_event = example.on_event(event, &api, document_id), + _ => return winit::ControlFlow::Continue, }; if custom_event { @@ -275,7 +279,7 @@ pub fn main_wrapper( example.draw_custom(&*gl); window.swap_buffers().ok(); - glutin::ControlFlow::Continue + winit::ControlFlow::Continue }); renderer.deinit(); diff --git a/gfx/webrender/examples/document.rs b/gfx/webrender/examples/document.rs index f3d3d7bfe134..2ae41703ae9d 100644 --- a/gfx/webrender/examples/document.rs +++ b/gfx/webrender/examples/document.rs @@ -6,6 +6,7 @@ extern crate euclid; extern crate gleam; extern crate glutin; extern crate webrender; +extern crate winit; #[path = "common/boilerplate.rs"] mod boilerplate; diff --git a/gfx/webrender/examples/frame_output.rs b/gfx/webrender/examples/frame_output.rs index 66b8d5f153e2..fc67c8bf27f6 100644 --- a/gfx/webrender/examples/frame_output.rs +++ b/gfx/webrender/examples/frame_output.rs @@ -6,6 +6,7 @@ extern crate euclid; extern crate gleam; extern crate glutin; extern crate webrender; +extern crate winit; #[path = "common/boilerplate.rs"] mod boilerplate; diff --git a/gfx/webrender/examples/iframe.rs b/gfx/webrender/examples/iframe.rs index 78d71dad1e59..4cca0091cbad 100644 --- a/gfx/webrender/examples/iframe.rs +++ b/gfx/webrender/examples/iframe.rs @@ -5,6 +5,7 @@ extern crate gleam; extern crate glutin; extern crate webrender; +extern crate winit; #[path = "common/boilerplate.rs"] mod boilerplate; diff --git a/gfx/webrender/examples/image_resize.rs b/gfx/webrender/examples/image_resize.rs index 76a1ad906dd8..fc01c4d8cc53 100644 --- a/gfx/webrender/examples/image_resize.rs +++ b/gfx/webrender/examples/image_resize.rs @@ -5,6 +5,7 @@ extern crate gleam; extern crate glutin; extern crate webrender; +extern crate winit; #[path = "common/boilerplate.rs"] mod boilerplate; @@ -80,12 +81,12 @@ impl Example for App { builder.pop_stacking_context(); } - fn on_event(&mut self, event: glutin::WindowEvent, api: &RenderApi, document_id: DocumentId) -> bool { + fn on_event(&mut self, event: winit::WindowEvent, api: &RenderApi, document_id: DocumentId) -> bool { match event { - glutin::WindowEvent::KeyboardInput { - input: glutin::KeyboardInput { - state: glutin::ElementState::Pressed, - virtual_keycode: Some(glutin::VirtualKeyCode::Space), + winit::WindowEvent::KeyboardInput { + input: winit::KeyboardInput { + state: winit::ElementState::Pressed, + virtual_keycode: Some(winit::VirtualKeyCode::Space), .. }, .. diff --git a/gfx/webrender/examples/multiwindow.rs b/gfx/webrender/examples/multiwindow.rs index 707d21b10173..0c15f8ba7076 100644 --- a/gfx/webrender/examples/multiwindow.rs +++ b/gfx/webrender/examples/multiwindow.rs @@ -7,6 +7,7 @@ extern crate euclid; extern crate gleam; extern crate glutin; extern crate webrender; +extern crate winit; use app_units::Au; use gleam::gl; @@ -16,11 +17,11 @@ use std::io::Read; use webrender::api::*; struct Notifier { - events_proxy: glutin::EventsLoopProxy, + events_proxy: winit::EventsLoopProxy, } impl Notifier { - fn new(events_proxy: glutin::EventsLoopProxy) -> Notifier { + fn new(events_proxy: winit::EventsLoopProxy) -> Notifier { Notifier { events_proxy } } } @@ -43,7 +44,7 @@ impl RenderNotifier for Notifier { } struct Window { - events_loop: glutin::EventsLoop, //TODO: share events loop? + events_loop: winit::EventsLoop, //TODO: share events loop? window: glutin::GlWindow, renderer: webrender::Renderer, name: &'static str, @@ -56,13 +57,13 @@ struct Window { impl Window { fn new(name: &'static str, clear_color: ColorF) -> Self { - let events_loop = glutin::EventsLoop::new(); + let events_loop = winit::EventsLoop::new(); let context_builder = glutin::ContextBuilder::new() .with_gl(glutin::GlRequest::GlThenGles { opengl_version: (3, 2), opengles_version: (3, 0), }); - let window_builder = glutin::WindowBuilder::new() + let window_builder = winit::WindowBuilder::new() .with_title(name) .with_multitouch() .with_dimensions(800, 600); @@ -135,21 +136,21 @@ impl Window { let renderer = &mut self.renderer; self.events_loop.poll_events(|global_event| match global_event { - glutin::Event::WindowEvent { event, .. } => match event { - glutin::WindowEvent::Closed | - glutin::WindowEvent::KeyboardInput { - input: glutin::KeyboardInput { - virtual_keycode: Some(glutin::VirtualKeyCode::Escape), + winit::Event::WindowEvent { event, .. } => match event { + winit::WindowEvent::CloseRequested | + winit::WindowEvent::KeyboardInput { + input: winit::KeyboardInput { + virtual_keycode: Some(winit::VirtualKeyCode::Escape), .. }, .. } => { do_exit = true } - glutin::WindowEvent::KeyboardInput { - input: glutin::KeyboardInput { - state: glutin::ElementState::Pressed, - virtual_keycode: Some(glutin::VirtualKeyCode::P), + winit::WindowEvent::KeyboardInput { + input: winit::KeyboardInput { + state: winit::ElementState::Pressed, + virtual_keycode: Some(winit::VirtualKeyCode::P), .. }, .. diff --git a/gfx/webrender/examples/scrolling.rs b/gfx/webrender/examples/scrolling.rs index ea1ba7c54241..582003bd004c 100644 --- a/gfx/webrender/examples/scrolling.rs +++ b/gfx/webrender/examples/scrolling.rs @@ -6,6 +6,7 @@ extern crate euclid; extern crate gleam; extern crate glutin; extern crate webrender; +extern crate winit; #[path = "common/boilerplate.rs"] mod boilerplate; @@ -143,22 +144,22 @@ impl Example for App { builder.pop_stacking_context(); } - fn on_event(&mut self, event: glutin::WindowEvent, api: &RenderApi, document_id: DocumentId) -> bool { + fn on_event(&mut self, event: winit::WindowEvent, api: &RenderApi, document_id: DocumentId) -> bool { let mut txn = Transaction::new(); match event { - glutin::WindowEvent::KeyboardInput { - input: glutin::KeyboardInput { - state: glutin::ElementState::Pressed, + winit::WindowEvent::KeyboardInput { + input: winit::KeyboardInput { + state: winit::ElementState::Pressed, virtual_keycode: Some(key), .. }, .. } => { let offset = match key { - glutin::VirtualKeyCode::Down => (0.0, -10.0), - glutin::VirtualKeyCode::Up => (0.0, 10.0), - glutin::VirtualKeyCode::Right => (-10.0, 0.0), - glutin::VirtualKeyCode::Left => (10.0, 0.0), + winit::VirtualKeyCode::Down => (0.0, -10.0), + winit::VirtualKeyCode::Up => (0.0, 10.0), + winit::VirtualKeyCode::Right => (-10.0, 0.0), + winit::VirtualKeyCode::Left => (10.0, 0.0), _ => return false, }; @@ -167,14 +168,14 @@ impl Example for App { self.cursor_position, ); } - glutin::WindowEvent::CursorMoved { position: (x, y), .. } => { + winit::WindowEvent::CursorMoved { position: (x, y), .. } => { self.cursor_position = WorldPoint::new(x as f32, y as f32); } - glutin::WindowEvent::MouseWheel { delta, .. } => { + winit::WindowEvent::MouseWheel { delta, .. } => { const LINE_HEIGHT: f32 = 38.0; let (dx, dy) = match delta { - glutin::MouseScrollDelta::LineDelta(dx, dy) => (dx, dy * LINE_HEIGHT), - glutin::MouseScrollDelta::PixelDelta(dx, dy) => (dx, dy), + winit::MouseScrollDelta::LineDelta(dx, dy) => (dx, dy * LINE_HEIGHT), + winit::MouseScrollDelta::PixelDelta(dx, dy) => (dx, dy), }; txn.scroll( @@ -182,7 +183,7 @@ impl Example for App { self.cursor_position, ); } - glutin::WindowEvent::MouseInput { .. } => { + winit::WindowEvent::MouseInput { .. } => { let results = api.hit_test( document_id, None, diff --git a/gfx/webrender/examples/texture_cache_stress.rs b/gfx/webrender/examples/texture_cache_stress.rs index 4f4270cd8e10..84b4120ce188 100644 --- a/gfx/webrender/examples/texture_cache_stress.rs +++ b/gfx/webrender/examples/texture_cache_stress.rs @@ -5,6 +5,7 @@ extern crate gleam; extern crate glutin; extern crate webrender; +extern crate winit; #[path = "common/boilerplate.rs"] mod boilerplate; @@ -187,14 +188,14 @@ impl Example for App { fn on_event( &mut self, - event: glutin::WindowEvent, + event: winit::WindowEvent, api: &RenderApi, _document_id: DocumentId, ) -> bool { match event { - glutin::WindowEvent::KeyboardInput { - input: glutin::KeyboardInput { - state: glutin::ElementState::Pressed, + winit::WindowEvent::KeyboardInput { + input: winit::KeyboardInput { + state: winit::ElementState::Pressed, virtual_keycode: Some(key), .. }, @@ -203,7 +204,7 @@ impl Example for App { let mut txn = Transaction::new(); match key { - glutin::VirtualKeyCode::S => { + winit::VirtualKeyCode::S => { self.stress_keys.clear(); for _ in 0 .. 16 { @@ -225,10 +226,10 @@ impl Example for App { } } } - glutin::VirtualKeyCode::D => if let Some(image_key) = self.image_key.take() { + winit::VirtualKeyCode::D => if let Some(image_key) = self.image_key.take() { txn.delete_image(image_key); }, - glutin::VirtualKeyCode::U => if let Some(image_key) = self.image_key { + winit::VirtualKeyCode::U => if let Some(image_key) = self.image_key { let size = 128; self.image_generator.generate_image(size); @@ -239,7 +240,7 @@ impl Example for App { None, ); }, - glutin::VirtualKeyCode::E => { + winit::VirtualKeyCode::E => { if let Some(image_key) = self.image_key.take() { txn.delete_image(image_key); } @@ -262,7 +263,7 @@ impl Example for App { self.image_key = Some(image_key); } - glutin::VirtualKeyCode::R => { + winit::VirtualKeyCode::R => { if let Some(image_key) = self.image_key.take() { txn.delete_image(image_key); } diff --git a/gfx/webrender/examples/yuv.rs b/gfx/webrender/examples/yuv.rs index 7acaaef2048f..40e0a5451336 100644 --- a/gfx/webrender/examples/yuv.rs +++ b/gfx/webrender/examples/yuv.rs @@ -5,6 +5,7 @@ extern crate gleam; extern crate glutin; extern crate webrender; +extern crate winit; #[path = "common/boilerplate.rs"] mod boilerplate; @@ -176,7 +177,7 @@ impl Example for App { fn on_event( &mut self, - _event: glutin::WindowEvent, + _event: winit::WindowEvent, _api: &RenderApi, _document_id: DocumentId, ) -> bool { diff --git a/gfx/webrender/src/clip_scroll_node.rs b/gfx/webrender/src/clip_scroll_node.rs index 88e6eb41b48f..e5a524e227d4 100644 --- a/gfx/webrender/src/clip_scroll_node.rs +++ b/gfx/webrender/src/clip_scroll_node.rs @@ -211,18 +211,12 @@ impl ClipScrollNode { self.children.push(child); } - pub fn apply_old_scrolling_state(&mut self, old_scrolling_state: &ScrollFrameInfo) { + pub fn apply_old_scrolling_state(&mut self, old_scroll_info: &ScrollFrameInfo) { match self.node_type { NodeType::ScrollFrame(ref mut scrolling) => { - let scroll_sensitivity = scrolling.scroll_sensitivity; - let scrollable_size = scrolling.scrollable_size; - let viewport_rect = scrolling.viewport_rect; - *scrolling = *old_scrolling_state; - scrolling.scroll_sensitivity = scroll_sensitivity; - scrolling.scrollable_size = scrollable_size; - scrolling.viewport_rect = viewport_rect; + *scrolling = scrolling.combine_with_old_scroll_info(old_scroll_info); } - _ if old_scrolling_state.offset != LayoutVector2D::zero() => { + _ if old_scroll_info.offset != LayoutVector2D::zero() => { warn!("Tried to scroll a non-scroll node.") } _ => {} @@ -768,6 +762,19 @@ impl ScrollFrameInfo { ScrollSensitivity::Script => false, } } + + pub fn combine_with_old_scroll_info( + self, + old_scroll_info: &ScrollFrameInfo + ) -> ScrollFrameInfo { + ScrollFrameInfo { + viewport_rect: self.viewport_rect, + offset: old_scroll_info.offset, + scroll_sensitivity: self.scroll_sensitivity, + scrollable_size: self.scrollable_size, + external_id: self.external_id, + } + } } /// Contains information about reference frames. diff --git a/gfx/webrender/src/device.rs b/gfx/webrender/src/device.rs index 0bb78fccf94f..5e1f189c9d08 100644 --- a/gfx/webrender/src/device.rs +++ b/gfx/webrender/src/device.rs @@ -23,6 +23,7 @@ use std::path::PathBuf; use std::ptr; use std::rc::Rc; use std::slice; +use std::sync::Arc; use std::thread; #[derive(Debug, Copy, Clone, PartialEq, Ord, Eq, PartialOrd)] @@ -575,7 +576,8 @@ pub struct VBOId(gl::GLuint); #[derive(PartialEq, Eq, Hash, Debug, Copy, Clone)] struct IBOId(gl::GLuint); -#[derive(PartialEq, Eq, Hash, Debug)] +#[derive(Clone, PartialEq, Eq, Hash, Debug)] +#[cfg_attr(feature = "serialize_program", derive(Deserialize, Serialize))] pub struct ProgramSources { renderer_name: String, vs_source: String, @@ -592,32 +594,58 @@ impl ProgramSources { } } +#[cfg_attr(feature = "serialize_program", derive(Deserialize, Serialize))] pub struct ProgramBinary { binary: Vec, format: gl::GLenum, + #[cfg(feature = "serialize_program")] + sources: ProgramSources, } impl ProgramBinary { - fn new(binary: Vec, format: gl::GLenum) -> Self { + #[allow(unused_variables)] + fn new(binary: Vec, + format: gl::GLenum, + sources: &ProgramSources) -> Self { ProgramBinary { binary, - format + format, + #[cfg(feature = "serialize_program")] + sources: sources.clone(), } } } +/// The interfaces that an application can implement to handle ProgramCache update +pub trait ProgramCacheObserver { + fn notify_binary_added(&self, program_binary: &Arc); + fn notify_program_binary_failed(&self, program_binary: &Arc); +} + pub struct ProgramCache { - pub binaries: RefCell>, + binaries: RefCell>>, + + /// Optional trait object that allows the client + /// application to handle ProgramCache updating + program_cache_handler: Option>, } impl ProgramCache { - pub fn new() -> Rc { + pub fn new(program_cache_observer: Option>) -> Rc { Rc::new( ProgramCache { binaries: RefCell::new(FastHashMap::default()), + program_cache_handler: program_cache_observer, } ) } + /// Load ProgramBinary to ProgramCache. + /// The function is typically used to load ProgramBinary from disk. + #[cfg(feature = "serialize_program")] + pub fn load_program_binary(&self, program_binary: Arc) { + let sources = program_binary.sources.clone(); + self.binaries.borrow_mut().insert(sources, program_binary); + } } #[derive(Debug, Copy, Clone)] @@ -1422,6 +1450,9 @@ impl Device { self.renderer_name, error_log ); + if let Some(ref program_cache_handler) = cached_programs.program_cache_handler { + program_cache_handler.notify_program_binary_failed(&binary); + } } else { loaded = true; } @@ -1496,7 +1527,11 @@ impl Device { if !cached_programs.binaries.borrow().contains_key(&sources) { let (buffer, format) = self.gl.get_program_binary(pid); if buffer.len() > 0 { - cached_programs.binaries.borrow_mut().insert(sources, ProgramBinary::new(buffer, format)); + let program_binary = Arc::new(ProgramBinary::new(buffer, format, &sources)); + if let Some(ref program_cache_handler) = cached_programs.program_cache_handler { + program_cache_handler.notify_binary_added(&program_binary); + } + cached_programs.binaries.borrow_mut().insert(sources, program_binary); } } } diff --git a/gfx/webrender/src/lib.rs b/gfx/webrender/src/lib.rs index 402ca1954669..fe29f4511fa7 100644 --- a/gfx/webrender/src/lib.rs +++ b/gfx/webrender/src/lib.rs @@ -48,7 +48,7 @@ extern crate cfg_if; extern crate lazy_static; #[macro_use] extern crate log; -#[cfg(any(feature = "debugger", feature = "capture", feature = "replay"))] +#[cfg(any(feature = "serde"))] #[macro_use] extern crate serde; #[macro_use] @@ -180,7 +180,8 @@ extern crate png; pub extern crate webrender_api; #[doc(hidden)] -pub use device::{build_shader_strings, ProgramCache, ReadPixelsFormat, UploadMethod, VertexUsageHint}; +pub use device::{build_shader_strings, ReadPixelsFormat, UploadMethod, VertexUsageHint}; +pub use device::{ProgramBinary, ProgramCache, ProgramCacheObserver, ProgramSources}; pub use renderer::{AsyncPropertySampler, CpuProfile, DebugFlags, OutputImageHandler, RendererKind}; pub use renderer::{ExternalImage, ExternalImageHandler, ExternalImageSource, GpuProfile}; pub use renderer::{GraphicsApi, GraphicsApiInfo, PipelineInfo, Renderer, RendererOptions}; diff --git a/gfx/webrender/src/renderer.rs b/gfx/webrender/src/renderer.rs index d02fa28a127f..50f92cdcaed9 100644 --- a/gfx/webrender/src/renderer.rs +++ b/gfx/webrender/src/renderer.rs @@ -4020,6 +4020,10 @@ pub trait SceneBuilderHooks { /// the updated epochs and pipelines removed in the new scene compared to /// the old scene. fn post_scene_swap(&self, info: PipelineInfo); + /// This is called after a resource update operation on the scene builder + /// thread, in the case where resource updates were applied without a scene + /// build. + fn post_resource_update(&self); /// This is a generic callback which provides an opportunity to run code /// on the scene builder thread. This is called as part of the main message /// loop of the scene builder thread, but outside of any specific message diff --git a/gfx/webrender/src/scene_builder.rs b/gfx/webrender/src/scene_builder.rs index 7e7de5311e11..fec42e28a3e8 100644 --- a/gfx/webrender/src/scene_builder.rs +++ b/gfx/webrender/src/scene_builder.rs @@ -162,6 +162,7 @@ impl SceneBuilder { _ => (None, None, None), }; + let has_resources_updates = !resource_updates.is_empty(); self.tx.send(SceneBuilderResult::Transaction { document_id, built_scene, @@ -184,6 +185,10 @@ impl SceneBuilder { }, _ => (), }; + } else if has_resources_updates { + if let &Some(ref hooks) = &self.hooks { + hooks.post_resource_update(); + } } } SceneBuilderRequest::Stop => { diff --git a/gfx/webrender_bindings/revision.txt b/gfx/webrender_bindings/revision.txt index 1da4625b4373..1fd4b5d8b928 100644 --- a/gfx/webrender_bindings/revision.txt +++ b/gfx/webrender_bindings/revision.txt @@ -1 +1 @@ -63c71ca9bbe4dec0ebc9c9bc8ab65b06a6b40641 +3829687ffbe8d55885d71a3d5e5e79216251548f diff --git a/gfx/wrench/Cargo.toml b/gfx/wrench/Cargo.toml index cbed03a5f3e3..650746906293 100644 --- a/gfx/wrench/Cargo.toml +++ b/gfx/wrench/Cargo.toml @@ -12,7 +12,7 @@ byteorder = "1.0" env_logger = { version = "0.5", optional = true } euclid = "0.17" gleam = "0.5" -glutin = "0.13" +glutin = "0.15" app_units = "0.6" image = "0.18" clap = { version = "2", features = ["yaml"] } @@ -27,6 +27,7 @@ osmesa-sys = { version = "0.1.2", optional = true } osmesa-src = { git = "https://github.com/jrmuizel/osmesa-src", optional = true, branch = "serialize" } webrender = {path = "../webrender", features=["capture","replay","debugger","png","profiler"]} webrender_api = {path = "../webrender_api", features=["serialize","deserialize"]} +winit = "0.13" serde = {version = "1.0", features = ["derive"] } [target.'cfg(target_os = "macos")'.dependencies] diff --git a/gfx/wrench/src/angle.rs b/gfx/wrench/src/angle.rs index 2cf06dcef80e..d754cd22fdf0 100644 --- a/gfx/wrench/src/angle.rs +++ b/gfx/wrench/src/angle.rs @@ -2,8 +2,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use glutin; -use glutin::{WindowBuilder, ContextBuilder, EventsLoop, Window, CreationError}; +use glutin::{self, ContextBuilder, CreationError}; +use winit::{EventsLoop, Window, WindowBuilder}; #[cfg(not(windows))] pub enum Context {} @@ -27,7 +27,7 @@ impl Context { context_builder: ContextBuilder, events_loop: &EventsLoop, ) -> Result<(Window, Self), CreationError> { - use glutin::os::windows::WindowExt; + use winit::os::windows::WindowExt; // FIXME: &context_builder.pf_reqs https://github.com/tomaka/glutin/pull/1002 let pf_reqs = &glutin::PixelFormatRequirements::default(); diff --git a/gfx/wrench/src/egl.rs b/gfx/wrench/src/egl.rs index 4c0ad6080ffc..6b432453aab6 100644 --- a/gfx/wrench/src/egl.rs +++ b/gfx/wrench/src/egl.rs @@ -54,7 +54,7 @@ impl Context { let display = unsafe { egl::GetDisplay(ptr::null_mut()) }; if display.is_null() { - return Err(CreationError::OsError("Could not create EGL display object".to_string())); + return Err(CreationError::PlatformSpecific("Could not create EGL display object".to_string())); } let egl_version = unsafe { diff --git a/gfx/wrench/src/main.rs b/gfx/wrench/src/main.rs index a39a115cc882..1b301c7e50b3 100644 --- a/gfx/wrench/src/main.rs +++ b/gfx/wrench/src/main.rs @@ -37,6 +37,7 @@ extern crate serde; extern crate serde_json; extern crate time; extern crate webrender; +extern crate winit; extern crate yaml_rust; mod angle; @@ -61,7 +62,7 @@ mod cgfont_to_data; use binary_frame_reader::BinaryFrameReader; use gleam::gl; -use glutin::{GlContext, VirtualKeyCode}; +use glutin::GlContext; use perf::PerfHarness; use png::save_flipped; use rawtest::RawtestHarness; @@ -78,6 +79,7 @@ use std::rc::Rc; use std::sync::mpsc::{channel, Sender, Receiver}; use webrender::DebugFlags; use webrender::api::*; +use winit::VirtualKeyCode; use wrench::{Wrench, WrenchThing}; use yaml_frame_reader::YamlFrameReader; @@ -163,7 +165,7 @@ impl HeadlessContext { pub enum WindowWrapper { Window(glutin::GlWindow, Rc), - Angle(glutin::Window, angle::Context, Rc), + Angle(winit::Window, angle::Context, Rc), Headless(HeadlessContext, Rc), } @@ -181,13 +183,13 @@ impl WindowWrapper { fn get_inner_size(&self) -> DeviceUintSize { //HACK: `winit` needs to figure out its hidpi story... #[cfg(target_os = "macos")] - fn inner_size(window: &glutin::Window) -> (u32, u32) { + fn inner_size(window: &winit::Window) -> (u32, u32) { let (w, h) = window.get_inner_size().unwrap(); let factor = window.hidpi_factor(); ((w as f32 * factor) as _, (h as f32 * factor) as _) } #[cfg(not(target_os = "macos"))] - fn inner_size(window: &glutin::Window) -> (u32, u32) { + fn inner_size(window: &winit::Window) -> (u32, u32) { window.get_inner_size().unwrap() } let (w, h) = match *self { @@ -243,7 +245,7 @@ fn make_window( size: DeviceUintSize, dp_ratio: Option, vsync: bool, - events_loop: &Option, + events_loop: &Option, angle: bool, ) -> WindowWrapper { let wrapper = match *events_loop { @@ -254,7 +256,7 @@ fn make_window( opengles_version: (3, 0), }) .with_vsync(vsync); - let window_builder = glutin::WindowBuilder::new() + let window_builder = winit::WindowBuilder::new() .with_title("WRech") .with_multitouch() .with_dimensions(size.width, size.height); @@ -401,7 +403,7 @@ fn main() { let mut events_loop = if args.is_present("headless") { None } else { - Some(glutin::EventsLoop::new()) + Some(winit::EventsLoop::new()) }; let mut window = make_window( @@ -510,7 +512,7 @@ fn main() { wrench.update(dim); thing.do_frame(&mut wrench); - let mut body = |wrench: &mut Wrench, global_event: glutin::Event| { + let mut body = |wrench: &mut Wrench, global_event: winit::Event| { if let Some(window_title) = wrench.take_title() { if !cfg!(windows) { //TODO: calling `set_title` from inside the `run_forever` loop is illegal... window.set_title(&window_title); @@ -521,31 +523,31 @@ fn main() { let mut do_render = false; match global_event { - glutin::Event::Awakened => { + winit::Event::Awakened => { do_render = true; } - glutin::Event::WindowEvent { event, .. } => match event { - glutin::WindowEvent::Closed => { - return glutin::ControlFlow::Break; + winit::Event::WindowEvent { event, .. } => match event { + winit::WindowEvent::CloseRequested => { + return winit::ControlFlow::Break; } - glutin::WindowEvent::Refresh | - glutin::WindowEvent::Focused(..) => { + winit::WindowEvent::Refresh | + winit::WindowEvent::Focused(..) => { do_render = true; } - glutin::WindowEvent::CursorMoved { position: (x, y), .. } => { + winit::WindowEvent::CursorMoved { position: (x, y), .. } => { cursor_position = WorldPoint::new(x as f32, y as f32); do_render = true; } - glutin::WindowEvent::KeyboardInput { - input: glutin::KeyboardInput { - state: glutin::ElementState::Pressed, + winit::WindowEvent::KeyboardInput { + input: winit::KeyboardInput { + state: winit::ElementState::Pressed, virtual_keycode: Some(vk), .. }, .. } => match vk { VirtualKeyCode::Escape => { - return glutin::ControlFlow::Break; + return winit::ControlFlow::Break; } VirtualKeyCode::P => { wrench.renderer.toggle_debug_flags(DebugFlags::PROFILER_DBG); @@ -634,7 +636,7 @@ fn main() { } _ => {} }, - _ => return glutin::ControlFlow::Continue, + _ => return winit::ControlFlow::Continue, }; let dim = window.get_inner_size(); @@ -660,12 +662,12 @@ fn main() { } } - glutin::ControlFlow::Continue + winit::ControlFlow::Continue }; match events_loop { None => { - while body(&mut wrench, glutin::Event::Awakened) == glutin::ControlFlow::Continue {} + while body(&mut wrench, winit::Event::Awakened) == winit::ControlFlow::Continue {} let rect = DeviceUintRect::new(DeviceUintPoint::zero(), size); let pixels = wrench.renderer.read_pixels_rgba8(rect); save_flipped("screenshot.png", pixels, size); diff --git a/gfx/wrench/src/wrench.rs b/gfx/wrench/src/wrench.rs index 21026d11bfb2..45c17a981425 100644 --- a/gfx/wrench/src/wrench.rs +++ b/gfx/wrench/src/wrench.rs @@ -10,7 +10,7 @@ use crossbeam::sync::chase_lev; use dwrote; #[cfg(any(target_os = "linux", target_os = "macos"))] use font_loader::system_fonts; -use glutin::EventsLoopProxy; +use winit::EventsLoopProxy; use json_frame_writer::JsonFrameWriter; use ron_frame_writer::RonFrameWriter; use std::collections::HashMap;