Bug 1464473 - Update webrender to 3829687ffbe8d55885d71a3d5e5e79216251548f. r=Gankro

MozReview-Commit-ID: 100EQ2cTdj4

--HG--
extra : rebase_source : 22829dcb9b4a4b07a9b76aea6f1df5c9a1f1b488
This commit is contained in:
Kartikaya Gupta 2018-05-29 08:45:25 -04:00
parent 8469e02799
commit 10f4292c33
25 changed files with 208 additions and 135 deletions

View File

@ -15,6 +15,7 @@ capture = ["webrender_api/serialize", "ron", "serde", "debug_renderer"]
replay = ["webrender_api/deserialize", "ron", "serde"] replay = ["webrender_api/deserialize", "ron", "serde"]
debug_renderer = [] debug_renderer = []
pathfinder = ["pathfinder_font_renderer", "pathfinder_gfx_utils", "pathfinder_partitioner", "pathfinder_path_utils"] pathfinder = ["pathfinder_font_renderer", "pathfinder_gfx_utils", "pathfinder_partitioner", "pathfinder_path_utils"]
serialize_program = ["serde"]
[dependencies] [dependencies]
app_units = "0.6" app_units = "0.6"
@ -64,7 +65,8 @@ optional = true
mozangle = "0.1" mozangle = "0.1"
env_logger = "0.5" env_logger = "0.5"
rand = "0.3" # for the benchmarks 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] [target.'cfg(any(target_os = "android", all(unix, not(target_os = "macos"))))'.dependencies]
freetype = { version = "0.4", default-features = false } freetype = { version = "0.4", default-features = false }

View File

@ -6,6 +6,7 @@ extern crate euclid;
extern crate gleam; extern crate gleam;
extern crate glutin; extern crate glutin;
extern crate webrender; extern crate webrender;
extern crate winit;
#[path = "common/boilerplate.rs"] #[path = "common/boilerplate.rs"]
mod boilerplate; mod boilerplate;
@ -51,25 +52,25 @@ impl Example for App {
fn on_event( fn on_event(
&mut self, &mut self,
event: glutin::WindowEvent, event: winit::WindowEvent,
_api: &RenderApi, _api: &RenderApi,
_document_id: DocumentId _document_id: DocumentId
) -> bool { ) -> bool {
match event { match event {
glutin::WindowEvent::KeyboardInput { winit::WindowEvent::KeyboardInput {
input: glutin::KeyboardInput { input: winit::KeyboardInput {
state: glutin::ElementState::Pressed, state: winit::ElementState::Pressed,
virtual_keycode: Some(key), virtual_keycode: Some(key),
.. ..
}, },
.. ..
} => { } => {
match key { match key {
glutin::VirtualKeyCode::Right => { winit::VirtualKeyCode::Right => {
self.rect_count += 1; self.rect_count += 1;
println!("rects = {}", self.rect_count); println!("rects = {}", self.rect_count);
} }
glutin::VirtualKeyCode::Left => { winit::VirtualKeyCode::Left => {
self.rect_count = cmp::max(self.rect_count, 1) - 1; self.rect_count = cmp::max(self.rect_count, 1) - 1;
println!("rects = {}", self.rect_count); println!("rects = {}", self.rect_count);
} }

View File

@ -14,6 +14,7 @@ extern crate euclid;
extern crate gleam; extern crate gleam;
extern crate glutin; extern crate glutin;
extern crate webrender; extern crate webrender;
extern crate winit;
#[path = "common/boilerplate.rs"] #[path = "common/boilerplate.rs"]
mod boilerplate; mod boilerplate;
@ -74,25 +75,25 @@ impl Example for App {
builder.pop_stacking_context(); 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 { match win_event {
glutin::WindowEvent::KeyboardInput { winit::WindowEvent::KeyboardInput {
input: glutin::KeyboardInput { input: winit::KeyboardInput {
state: glutin::ElementState::Pressed, state: winit::ElementState::Pressed,
virtual_keycode: Some(key), virtual_keycode: Some(key),
.. ..
}, },
.. ..
} => { } => {
let (offset_x, offset_y, angle, delta_opacity) = match key { let (offset_x, offset_y, angle, delta_opacity) = match key {
glutin::VirtualKeyCode::Down => (0.0, 10.0, 0.0, 0.0), winit::VirtualKeyCode::Down => (0.0, 10.0, 0.0, 0.0),
glutin::VirtualKeyCode::Up => (0.0, -10.0, 0.0, 0.0), winit::VirtualKeyCode::Up => (0.0, -10.0, 0.0, 0.0),
glutin::VirtualKeyCode::Right => (10.0, 0.0, 0.0, 0.0), winit::VirtualKeyCode::Right => (10.0, 0.0, 0.0, 0.0),
glutin::VirtualKeyCode::Left => (-10.0, 0.0, 0.0, 0.0), winit::VirtualKeyCode::Left => (-10.0, 0.0, 0.0, 0.0),
glutin::VirtualKeyCode::Comma => (0.0, 0.0, 0.1, 0.0), winit::VirtualKeyCode::Comma => (0.0, 0.0, 0.1, 0.0),
glutin::VirtualKeyCode::Period => (0.0, 0.0, -0.1, 0.0), winit::VirtualKeyCode::Period => (0.0, 0.0, -0.1, 0.0),
glutin::VirtualKeyCode::Z => (0.0, 0.0, 0.0, -0.1), winit::VirtualKeyCode::Z => (0.0, 0.0, 0.0, -0.1),
glutin::VirtualKeyCode::X => (0.0, 0.0, 0.0, 0.1), winit::VirtualKeyCode::X => (0.0, 0.0, 0.0, 0.1),
_ => return false, _ => return false,
}; };
// Update the transform based on the keyboard input and push it to // Update the transform based on the keyboard input and push it to

View File

@ -7,13 +7,14 @@ extern crate euclid;
extern crate gleam; extern crate gleam;
extern crate glutin; extern crate glutin;
extern crate webrender; extern crate webrender;
extern crate winit;
#[path = "common/boilerplate.rs"] #[path = "common/boilerplate.rs"]
mod boilerplate; mod boilerplate;
use boilerplate::{Example, HandyDandyRectBuilder}; use boilerplate::{Example, HandyDandyRectBuilder};
use euclid::vec2; use euclid::vec2;
use glutin::TouchPhase; use winit::TouchPhase;
use std::collections::HashMap; use std::collections::HashMap;
use webrender::api::*; 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 { match touch.phase {
TouchPhase::Started => { TouchPhase::Started => {
debug_assert!(!self.active_touches.contains_key(&touch.id)); debug_assert!(!self.active_touches.contains_key(&touch.id));
@ -274,10 +275,10 @@ impl Example for App {
builder.pop_stacking_context(); 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(); let mut txn = Transaction::new();
match event { 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) => { TouchResult::Pan(pan) => {
txn.set_pan(pan); txn.set_pan(pan);
} }

View File

@ -6,6 +6,7 @@ extern crate gleam;
extern crate glutin; extern crate glutin;
extern crate rayon; extern crate rayon;
extern crate webrender; extern crate webrender;
extern crate winit;
#[path = "common/boilerplate.rs"] #[path = "common/boilerplate.rs"]
mod boilerplate; mod boilerplate;

View File

@ -10,14 +10,15 @@ use glutin::{self, GlContext};
use std::env; use std::env;
use std::path::PathBuf; use std::path::PathBuf;
use webrender; use webrender;
use winit;
use webrender::api::*; use webrender::api::*;
struct Notifier { struct Notifier {
events_proxy: glutin::EventsLoopProxy, events_proxy: winit::EventsLoopProxy,
} }
impl Notifier { impl Notifier {
fn new(events_proxy: glutin::EventsLoopProxy) -> Notifier { fn new(events_proxy: winit::EventsLoopProxy) -> Notifier {
Notifier { events_proxy } Notifier { events_proxy }
} }
} }
@ -76,7 +77,7 @@ pub trait Example {
pipeline_id: PipelineId, pipeline_id: PipelineId,
document_id: DocumentId, document_id: DocumentId,
); );
fn on_event(&mut self, glutin::WindowEvent, &RenderApi, DocumentId) -> bool { fn on_event(&mut self, winit::WindowEvent, &RenderApi, DocumentId) -> bool {
false false
} }
fn get_image_handlers( fn get_image_handlers(
@ -103,13 +104,13 @@ pub fn main_wrapper<E: Example>(
None None
}; };
let mut events_loop = glutin::EventsLoop::new(); let mut events_loop = winit::EventsLoop::new();
let context_builder = glutin::ContextBuilder::new() let context_builder = glutin::ContextBuilder::new()
.with_gl(glutin::GlRequest::GlThenGles { .with_gl(glutin::GlRequest::GlThenGles {
opengl_version: (3, 2), opengl_version: (3, 2),
opengles_version: (3, 0), opengles_version: (3, 0),
}); });
let window_builder = glutin::WindowBuilder::new() let window_builder = winit::WindowBuilder::new()
.with_title(E::TITLE) .with_title(E::TITLE)
.with_multitouch() .with_multitouch()
.with_dimensions(E::WIDTH, E::HEIGHT); .with_dimensions(E::WIDTH, E::HEIGHT);
@ -196,11 +197,14 @@ pub fn main_wrapper<E: Example>(
let mut custom_event = true; let mut custom_event = true;
match global_event { match global_event {
glutin::Event::WindowEvent { event: glutin::WindowEvent::Closed, .. } => return glutin::ControlFlow::Break, winit::Event::WindowEvent {
glutin::Event::WindowEvent { event: winit::WindowEvent::CloseRequested,
event: glutin::WindowEvent::KeyboardInput { ..
input: glutin::KeyboardInput { } => return winit::ControlFlow::Break,
state: glutin::ElementState::Pressed, winit::Event::WindowEvent {
event: winit::WindowEvent::KeyboardInput {
input: winit::KeyboardInput {
state: winit::ElementState::Pressed,
virtual_keycode: Some(key), virtual_keycode: Some(key),
.. ..
}, },
@ -208,27 +212,27 @@ pub fn main_wrapper<E: Example>(
}, },
.. ..
} => match key { } => match key {
glutin::VirtualKeyCode::Escape => return glutin::ControlFlow::Break, winit::VirtualKeyCode::Escape => return winit::ControlFlow::Break,
glutin::VirtualKeyCode::P => renderer.toggle_debug_flags(webrender::DebugFlags::PROFILER_DBG), winit::VirtualKeyCode::P => renderer.toggle_debug_flags(webrender::DebugFlags::PROFILER_DBG),
glutin::VirtualKeyCode::O => renderer.toggle_debug_flags(webrender::DebugFlags::RENDER_TARGET_DBG), winit::VirtualKeyCode::O => renderer.toggle_debug_flags(webrender::DebugFlags::RENDER_TARGET_DBG),
glutin::VirtualKeyCode::I => renderer.toggle_debug_flags(webrender::DebugFlags::TEXTURE_CACHE_DBG), winit::VirtualKeyCode::I => renderer.toggle_debug_flags(webrender::DebugFlags::TEXTURE_CACHE_DBG),
glutin::VirtualKeyCode::S => renderer.toggle_debug_flags(webrender::DebugFlags::COMPACT_PROFILER), winit::VirtualKeyCode::S => renderer.toggle_debug_flags(webrender::DebugFlags::COMPACT_PROFILER),
glutin::VirtualKeyCode::Q => renderer.toggle_debug_flags( winit::VirtualKeyCode::Q => renderer.toggle_debug_flags(
webrender::DebugFlags::GPU_TIME_QUERIES | webrender::DebugFlags::GPU_SAMPLE_QUERIES 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, framebuffer_size,
DeviceUintRect::new(DeviceUintPoint::zero(), framebuffer_size), DeviceUintRect::new(DeviceUintPoint::zero(), framebuffer_size),
1.0 1.0
), ),
glutin::VirtualKeyCode::Key2 => txn.set_window_parameters( winit::VirtualKeyCode::Key2 => txn.set_window_parameters(
framebuffer_size, framebuffer_size,
DeviceUintRect::new(DeviceUintPoint::zero(), framebuffer_size), DeviceUintRect::new(DeviceUintPoint::zero(), framebuffer_size),
2.0 2.0
), ),
glutin::VirtualKeyCode::M => api.notify_memory_pressure(), winit::VirtualKeyCode::M => api.notify_memory_pressure(),
#[cfg(feature = "capture")] #[cfg(feature = "capture")]
glutin::VirtualKeyCode::C => { winit::VirtualKeyCode::C => {
let path: PathBuf = "../captures/example".into(); let path: PathBuf = "../captures/example".into();
//TODO: switch between SCENE/FRAME capture types //TODO: switch between SCENE/FRAME capture types
// based on "shift" modifier, when `glutin` is updated. // based on "shift" modifier, when `glutin` is updated.
@ -237,14 +241,14 @@ pub fn main_wrapper<E: Example>(
}, },
_ => { _ => {
let win_event = match global_event { let win_event = match global_event {
glutin::Event::WindowEvent { event, .. } => event, winit::Event::WindowEvent { event, .. } => event,
_ => unreachable!() _ => unreachable!()
}; };
custom_event = example.on_event(win_event, &api, document_id) custom_event = example.on_event(win_event, &api, document_id)
}, },
}, },
glutin::Event::WindowEvent { event, .. } => custom_event = example.on_event(event, &api, document_id), winit::Event::WindowEvent { event, .. } => custom_event = example.on_event(event, &api, document_id),
_ => return glutin::ControlFlow::Continue, _ => return winit::ControlFlow::Continue,
}; };
if custom_event { if custom_event {
@ -275,7 +279,7 @@ pub fn main_wrapper<E: Example>(
example.draw_custom(&*gl); example.draw_custom(&*gl);
window.swap_buffers().ok(); window.swap_buffers().ok();
glutin::ControlFlow::Continue winit::ControlFlow::Continue
}); });
renderer.deinit(); renderer.deinit();

View File

@ -6,6 +6,7 @@ extern crate euclid;
extern crate gleam; extern crate gleam;
extern crate glutin; extern crate glutin;
extern crate webrender; extern crate webrender;
extern crate winit;
#[path = "common/boilerplate.rs"] #[path = "common/boilerplate.rs"]
mod boilerplate; mod boilerplate;

View File

@ -6,6 +6,7 @@ extern crate euclid;
extern crate gleam; extern crate gleam;
extern crate glutin; extern crate glutin;
extern crate webrender; extern crate webrender;
extern crate winit;
#[path = "common/boilerplate.rs"] #[path = "common/boilerplate.rs"]
mod boilerplate; mod boilerplate;

View File

@ -5,6 +5,7 @@
extern crate gleam; extern crate gleam;
extern crate glutin; extern crate glutin;
extern crate webrender; extern crate webrender;
extern crate winit;
#[path = "common/boilerplate.rs"] #[path = "common/boilerplate.rs"]
mod boilerplate; mod boilerplate;

View File

@ -5,6 +5,7 @@
extern crate gleam; extern crate gleam;
extern crate glutin; extern crate glutin;
extern crate webrender; extern crate webrender;
extern crate winit;
#[path = "common/boilerplate.rs"] #[path = "common/boilerplate.rs"]
mod boilerplate; mod boilerplate;
@ -80,12 +81,12 @@ impl Example for App {
builder.pop_stacking_context(); 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 { match event {
glutin::WindowEvent::KeyboardInput { winit::WindowEvent::KeyboardInput {
input: glutin::KeyboardInput { input: winit::KeyboardInput {
state: glutin::ElementState::Pressed, state: winit::ElementState::Pressed,
virtual_keycode: Some(glutin::VirtualKeyCode::Space), virtual_keycode: Some(winit::VirtualKeyCode::Space),
.. ..
}, },
.. ..

View File

@ -7,6 +7,7 @@ extern crate euclid;
extern crate gleam; extern crate gleam;
extern crate glutin; extern crate glutin;
extern crate webrender; extern crate webrender;
extern crate winit;
use app_units::Au; use app_units::Au;
use gleam::gl; use gleam::gl;
@ -16,11 +17,11 @@ use std::io::Read;
use webrender::api::*; use webrender::api::*;
struct Notifier { struct Notifier {
events_proxy: glutin::EventsLoopProxy, events_proxy: winit::EventsLoopProxy,
} }
impl Notifier { impl Notifier {
fn new(events_proxy: glutin::EventsLoopProxy) -> Notifier { fn new(events_proxy: winit::EventsLoopProxy) -> Notifier {
Notifier { events_proxy } Notifier { events_proxy }
} }
} }
@ -43,7 +44,7 @@ impl RenderNotifier for Notifier {
} }
struct Window { struct Window {
events_loop: glutin::EventsLoop, //TODO: share events loop? events_loop: winit::EventsLoop, //TODO: share events loop?
window: glutin::GlWindow, window: glutin::GlWindow,
renderer: webrender::Renderer, renderer: webrender::Renderer,
name: &'static str, name: &'static str,
@ -56,13 +57,13 @@ struct Window {
impl Window { impl Window {
fn new(name: &'static str, clear_color: ColorF) -> Self { 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() let context_builder = glutin::ContextBuilder::new()
.with_gl(glutin::GlRequest::GlThenGles { .with_gl(glutin::GlRequest::GlThenGles {
opengl_version: (3, 2), opengl_version: (3, 2),
opengles_version: (3, 0), opengles_version: (3, 0),
}); });
let window_builder = glutin::WindowBuilder::new() let window_builder = winit::WindowBuilder::new()
.with_title(name) .with_title(name)
.with_multitouch() .with_multitouch()
.with_dimensions(800, 600); .with_dimensions(800, 600);
@ -135,21 +136,21 @@ impl Window {
let renderer = &mut self.renderer; let renderer = &mut self.renderer;
self.events_loop.poll_events(|global_event| match global_event { self.events_loop.poll_events(|global_event| match global_event {
glutin::Event::WindowEvent { event, .. } => match event { winit::Event::WindowEvent { event, .. } => match event {
glutin::WindowEvent::Closed | winit::WindowEvent::CloseRequested |
glutin::WindowEvent::KeyboardInput { winit::WindowEvent::KeyboardInput {
input: glutin::KeyboardInput { input: winit::KeyboardInput {
virtual_keycode: Some(glutin::VirtualKeyCode::Escape), virtual_keycode: Some(winit::VirtualKeyCode::Escape),
.. ..
}, },
.. ..
} => { } => {
do_exit = true do_exit = true
} }
glutin::WindowEvent::KeyboardInput { winit::WindowEvent::KeyboardInput {
input: glutin::KeyboardInput { input: winit::KeyboardInput {
state: glutin::ElementState::Pressed, state: winit::ElementState::Pressed,
virtual_keycode: Some(glutin::VirtualKeyCode::P), virtual_keycode: Some(winit::VirtualKeyCode::P),
.. ..
}, },
.. ..

View File

@ -6,6 +6,7 @@ extern crate euclid;
extern crate gleam; extern crate gleam;
extern crate glutin; extern crate glutin;
extern crate webrender; extern crate webrender;
extern crate winit;
#[path = "common/boilerplate.rs"] #[path = "common/boilerplate.rs"]
mod boilerplate; mod boilerplate;
@ -143,22 +144,22 @@ impl Example for App {
builder.pop_stacking_context(); 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(); let mut txn = Transaction::new();
match event { match event {
glutin::WindowEvent::KeyboardInput { winit::WindowEvent::KeyboardInput {
input: glutin::KeyboardInput { input: winit::KeyboardInput {
state: glutin::ElementState::Pressed, state: winit::ElementState::Pressed,
virtual_keycode: Some(key), virtual_keycode: Some(key),
.. ..
}, },
.. ..
} => { } => {
let offset = match key { let offset = match key {
glutin::VirtualKeyCode::Down => (0.0, -10.0), winit::VirtualKeyCode::Down => (0.0, -10.0),
glutin::VirtualKeyCode::Up => (0.0, 10.0), winit::VirtualKeyCode::Up => (0.0, 10.0),
glutin::VirtualKeyCode::Right => (-10.0, 0.0), winit::VirtualKeyCode::Right => (-10.0, 0.0),
glutin::VirtualKeyCode::Left => (10.0, 0.0), winit::VirtualKeyCode::Left => (10.0, 0.0),
_ => return false, _ => return false,
}; };
@ -167,14 +168,14 @@ impl Example for App {
self.cursor_position, 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); 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; const LINE_HEIGHT: f32 = 38.0;
let (dx, dy) = match delta { let (dx, dy) = match delta {
glutin::MouseScrollDelta::LineDelta(dx, dy) => (dx, dy * LINE_HEIGHT), winit::MouseScrollDelta::LineDelta(dx, dy) => (dx, dy * LINE_HEIGHT),
glutin::MouseScrollDelta::PixelDelta(dx, dy) => (dx, dy), winit::MouseScrollDelta::PixelDelta(dx, dy) => (dx, dy),
}; };
txn.scroll( txn.scroll(
@ -182,7 +183,7 @@ impl Example for App {
self.cursor_position, self.cursor_position,
); );
} }
glutin::WindowEvent::MouseInput { .. } => { winit::WindowEvent::MouseInput { .. } => {
let results = api.hit_test( let results = api.hit_test(
document_id, document_id,
None, None,

View File

@ -5,6 +5,7 @@
extern crate gleam; extern crate gleam;
extern crate glutin; extern crate glutin;
extern crate webrender; extern crate webrender;
extern crate winit;
#[path = "common/boilerplate.rs"] #[path = "common/boilerplate.rs"]
mod boilerplate; mod boilerplate;
@ -187,14 +188,14 @@ impl Example for App {
fn on_event( fn on_event(
&mut self, &mut self,
event: glutin::WindowEvent, event: winit::WindowEvent,
api: &RenderApi, api: &RenderApi,
_document_id: DocumentId, _document_id: DocumentId,
) -> bool { ) -> bool {
match event { match event {
glutin::WindowEvent::KeyboardInput { winit::WindowEvent::KeyboardInput {
input: glutin::KeyboardInput { input: winit::KeyboardInput {
state: glutin::ElementState::Pressed, state: winit::ElementState::Pressed,
virtual_keycode: Some(key), virtual_keycode: Some(key),
.. ..
}, },
@ -203,7 +204,7 @@ impl Example for App {
let mut txn = Transaction::new(); let mut txn = Transaction::new();
match key { match key {
glutin::VirtualKeyCode::S => { winit::VirtualKeyCode::S => {
self.stress_keys.clear(); self.stress_keys.clear();
for _ in 0 .. 16 { 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); 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; let size = 128;
self.image_generator.generate_image(size); self.image_generator.generate_image(size);
@ -239,7 +240,7 @@ impl Example for App {
None, None,
); );
}, },
glutin::VirtualKeyCode::E => { winit::VirtualKeyCode::E => {
if let Some(image_key) = self.image_key.take() { if let Some(image_key) = self.image_key.take() {
txn.delete_image(image_key); txn.delete_image(image_key);
} }
@ -262,7 +263,7 @@ impl Example for App {
self.image_key = Some(image_key); self.image_key = Some(image_key);
} }
glutin::VirtualKeyCode::R => { winit::VirtualKeyCode::R => {
if let Some(image_key) = self.image_key.take() { if let Some(image_key) = self.image_key.take() {
txn.delete_image(image_key); txn.delete_image(image_key);
} }

View File

@ -5,6 +5,7 @@
extern crate gleam; extern crate gleam;
extern crate glutin; extern crate glutin;
extern crate webrender; extern crate webrender;
extern crate winit;
#[path = "common/boilerplate.rs"] #[path = "common/boilerplate.rs"]
mod boilerplate; mod boilerplate;
@ -176,7 +177,7 @@ impl Example for App {
fn on_event( fn on_event(
&mut self, &mut self,
_event: glutin::WindowEvent, _event: winit::WindowEvent,
_api: &RenderApi, _api: &RenderApi,
_document_id: DocumentId, _document_id: DocumentId,
) -> bool { ) -> bool {

View File

@ -211,18 +211,12 @@ impl ClipScrollNode {
self.children.push(child); 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 { match self.node_type {
NodeType::ScrollFrame(ref mut scrolling) => { NodeType::ScrollFrame(ref mut scrolling) => {
let scroll_sensitivity = scrolling.scroll_sensitivity; *scrolling = scrolling.combine_with_old_scroll_info(old_scroll_info);
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;
} }
_ if old_scrolling_state.offset != LayoutVector2D::zero() => { _ if old_scroll_info.offset != LayoutVector2D::zero() => {
warn!("Tried to scroll a non-scroll node.") warn!("Tried to scroll a non-scroll node.")
} }
_ => {} _ => {}
@ -768,6 +762,19 @@ impl ScrollFrameInfo {
ScrollSensitivity::Script => false, 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. /// Contains information about reference frames.

View File

@ -23,6 +23,7 @@ use std::path::PathBuf;
use std::ptr; use std::ptr;
use std::rc::Rc; use std::rc::Rc;
use std::slice; use std::slice;
use std::sync::Arc;
use std::thread; use std::thread;
#[derive(Debug, Copy, Clone, PartialEq, Ord, Eq, PartialOrd)] #[derive(Debug, Copy, Clone, PartialEq, Ord, Eq, PartialOrd)]
@ -575,7 +576,8 @@ pub struct VBOId(gl::GLuint);
#[derive(PartialEq, Eq, Hash, Debug, Copy, Clone)] #[derive(PartialEq, Eq, Hash, Debug, Copy, Clone)]
struct IBOId(gl::GLuint); 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 { pub struct ProgramSources {
renderer_name: String, renderer_name: String,
vs_source: String, vs_source: String,
@ -592,32 +594,58 @@ impl ProgramSources {
} }
} }
#[cfg_attr(feature = "serialize_program", derive(Deserialize, Serialize))]
pub struct ProgramBinary { pub struct ProgramBinary {
binary: Vec<u8>, binary: Vec<u8>,
format: gl::GLenum, format: gl::GLenum,
#[cfg(feature = "serialize_program")]
sources: ProgramSources,
} }
impl ProgramBinary { impl ProgramBinary {
fn new(binary: Vec<u8>, format: gl::GLenum) -> Self { #[allow(unused_variables)]
fn new(binary: Vec<u8>,
format: gl::GLenum,
sources: &ProgramSources) -> Self {
ProgramBinary { ProgramBinary {
binary, 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<ProgramBinary>);
fn notify_program_binary_failed(&self, program_binary: &Arc<ProgramBinary>);
}
pub struct ProgramCache { pub struct ProgramCache {
pub binaries: RefCell<FastHashMap<ProgramSources, ProgramBinary>>, binaries: RefCell<FastHashMap<ProgramSources, Arc<ProgramBinary>>>,
/// Optional trait object that allows the client
/// application to handle ProgramCache updating
program_cache_handler: Option<Box<ProgramCacheObserver>>,
} }
impl ProgramCache { impl ProgramCache {
pub fn new() -> Rc<Self> { pub fn new(program_cache_observer: Option<Box<ProgramCacheObserver>>) -> Rc<Self> {
Rc::new( Rc::new(
ProgramCache { ProgramCache {
binaries: RefCell::new(FastHashMap::default()), 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<ProgramBinary>) {
let sources = program_binary.sources.clone();
self.binaries.borrow_mut().insert(sources, program_binary);
}
} }
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
@ -1422,6 +1450,9 @@ impl Device {
self.renderer_name, self.renderer_name,
error_log error_log
); );
if let Some(ref program_cache_handler) = cached_programs.program_cache_handler {
program_cache_handler.notify_program_binary_failed(&binary);
}
} else { } else {
loaded = true; loaded = true;
} }
@ -1496,7 +1527,11 @@ impl Device {
if !cached_programs.binaries.borrow().contains_key(&sources) { if !cached_programs.binaries.borrow().contains_key(&sources) {
let (buffer, format) = self.gl.get_program_binary(pid); let (buffer, format) = self.gl.get_program_binary(pid);
if buffer.len() > 0 { 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);
} }
} }
} }

View File

@ -48,7 +48,7 @@ extern crate cfg_if;
extern crate lazy_static; extern crate lazy_static;
#[macro_use] #[macro_use]
extern crate log; extern crate log;
#[cfg(any(feature = "debugger", feature = "capture", feature = "replay"))] #[cfg(any(feature = "serde"))]
#[macro_use] #[macro_use]
extern crate serde; extern crate serde;
#[macro_use] #[macro_use]
@ -180,7 +180,8 @@ extern crate png;
pub extern crate webrender_api; pub extern crate webrender_api;
#[doc(hidden)] #[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::{AsyncPropertySampler, CpuProfile, DebugFlags, OutputImageHandler, RendererKind};
pub use renderer::{ExternalImage, ExternalImageHandler, ExternalImageSource, GpuProfile}; pub use renderer::{ExternalImage, ExternalImageHandler, ExternalImageSource, GpuProfile};
pub use renderer::{GraphicsApi, GraphicsApiInfo, PipelineInfo, Renderer, RendererOptions}; pub use renderer::{GraphicsApi, GraphicsApiInfo, PipelineInfo, Renderer, RendererOptions};

View File

@ -4020,6 +4020,10 @@ pub trait SceneBuilderHooks {
/// the updated epochs and pipelines removed in the new scene compared to /// the updated epochs and pipelines removed in the new scene compared to
/// the old scene. /// the old scene.
fn post_scene_swap(&self, info: PipelineInfo); 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 /// 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 /// 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 /// loop of the scene builder thread, but outside of any specific message

View File

@ -162,6 +162,7 @@ impl SceneBuilder {
_ => (None, None, None), _ => (None, None, None),
}; };
let has_resources_updates = !resource_updates.is_empty();
self.tx.send(SceneBuilderResult::Transaction { self.tx.send(SceneBuilderResult::Transaction {
document_id, document_id,
built_scene, 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 => { SceneBuilderRequest::Stop => {

View File

@ -1 +1 @@
63c71ca9bbe4dec0ebc9c9bc8ab65b06a6b40641 3829687ffbe8d55885d71a3d5e5e79216251548f

View File

@ -12,7 +12,7 @@ byteorder = "1.0"
env_logger = { version = "0.5", optional = true } env_logger = { version = "0.5", optional = true }
euclid = "0.17" euclid = "0.17"
gleam = "0.5" gleam = "0.5"
glutin = "0.13" glutin = "0.15"
app_units = "0.6" app_units = "0.6"
image = "0.18" image = "0.18"
clap = { version = "2", features = ["yaml"] } 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" } osmesa-src = { git = "https://github.com/jrmuizel/osmesa-src", optional = true, branch = "serialize" }
webrender = {path = "../webrender", features=["capture","replay","debugger","png","profiler"]} webrender = {path = "../webrender", features=["capture","replay","debugger","png","profiler"]}
webrender_api = {path = "../webrender_api", features=["serialize","deserialize"]} webrender_api = {path = "../webrender_api", features=["serialize","deserialize"]}
winit = "0.13"
serde = {version = "1.0", features = ["derive"] } serde = {version = "1.0", features = ["derive"] }
[target.'cfg(target_os = "macos")'.dependencies] [target.'cfg(target_os = "macos")'.dependencies]

View File

@ -2,8 +2,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use glutin; use glutin::{self, ContextBuilder, CreationError};
use glutin::{WindowBuilder, ContextBuilder, EventsLoop, Window, CreationError}; use winit::{EventsLoop, Window, WindowBuilder};
#[cfg(not(windows))] #[cfg(not(windows))]
pub enum Context {} pub enum Context {}
@ -27,7 +27,7 @@ impl Context {
context_builder: ContextBuilder, context_builder: ContextBuilder,
events_loop: &EventsLoop, events_loop: &EventsLoop,
) -> Result<(Window, Self), CreationError> { ) -> 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 // FIXME: &context_builder.pf_reqs https://github.com/tomaka/glutin/pull/1002
let pf_reqs = &glutin::PixelFormatRequirements::default(); let pf_reqs = &glutin::PixelFormatRequirements::default();

View File

@ -54,7 +54,7 @@ impl Context {
let display = unsafe { egl::GetDisplay(ptr::null_mut()) }; let display = unsafe { egl::GetDisplay(ptr::null_mut()) };
if display.is_null() { 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 { let egl_version = unsafe {

View File

@ -37,6 +37,7 @@ extern crate serde;
extern crate serde_json; extern crate serde_json;
extern crate time; extern crate time;
extern crate webrender; extern crate webrender;
extern crate winit;
extern crate yaml_rust; extern crate yaml_rust;
mod angle; mod angle;
@ -61,7 +62,7 @@ mod cgfont_to_data;
use binary_frame_reader::BinaryFrameReader; use binary_frame_reader::BinaryFrameReader;
use gleam::gl; use gleam::gl;
use glutin::{GlContext, VirtualKeyCode}; use glutin::GlContext;
use perf::PerfHarness; use perf::PerfHarness;
use png::save_flipped; use png::save_flipped;
use rawtest::RawtestHarness; use rawtest::RawtestHarness;
@ -78,6 +79,7 @@ use std::rc::Rc;
use std::sync::mpsc::{channel, Sender, Receiver}; use std::sync::mpsc::{channel, Sender, Receiver};
use webrender::DebugFlags; use webrender::DebugFlags;
use webrender::api::*; use webrender::api::*;
use winit::VirtualKeyCode;
use wrench::{Wrench, WrenchThing}; use wrench::{Wrench, WrenchThing};
use yaml_frame_reader::YamlFrameReader; use yaml_frame_reader::YamlFrameReader;
@ -163,7 +165,7 @@ impl HeadlessContext {
pub enum WindowWrapper { pub enum WindowWrapper {
Window(glutin::GlWindow, Rc<gl::Gl>), Window(glutin::GlWindow, Rc<gl::Gl>),
Angle(glutin::Window, angle::Context, Rc<gl::Gl>), Angle(winit::Window, angle::Context, Rc<gl::Gl>),
Headless(HeadlessContext, Rc<gl::Gl>), Headless(HeadlessContext, Rc<gl::Gl>),
} }
@ -181,13 +183,13 @@ impl WindowWrapper {
fn get_inner_size(&self) -> DeviceUintSize { fn get_inner_size(&self) -> DeviceUintSize {
//HACK: `winit` needs to figure out its hidpi story... //HACK: `winit` needs to figure out its hidpi story...
#[cfg(target_os = "macos")] #[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 (w, h) = window.get_inner_size().unwrap();
let factor = window.hidpi_factor(); let factor = window.hidpi_factor();
((w as f32 * factor) as _, (h as f32 * factor) as _) ((w as f32 * factor) as _, (h as f32 * factor) as _)
} }
#[cfg(not(target_os = "macos"))] #[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() window.get_inner_size().unwrap()
} }
let (w, h) = match *self { let (w, h) = match *self {
@ -243,7 +245,7 @@ fn make_window(
size: DeviceUintSize, size: DeviceUintSize,
dp_ratio: Option<f32>, dp_ratio: Option<f32>,
vsync: bool, vsync: bool,
events_loop: &Option<glutin::EventsLoop>, events_loop: &Option<winit::EventsLoop>,
angle: bool, angle: bool,
) -> WindowWrapper { ) -> WindowWrapper {
let wrapper = match *events_loop { let wrapper = match *events_loop {
@ -254,7 +256,7 @@ fn make_window(
opengles_version: (3, 0), opengles_version: (3, 0),
}) })
.with_vsync(vsync); .with_vsync(vsync);
let window_builder = glutin::WindowBuilder::new() let window_builder = winit::WindowBuilder::new()
.with_title("WRech") .with_title("WRech")
.with_multitouch() .with_multitouch()
.with_dimensions(size.width, size.height); .with_dimensions(size.width, size.height);
@ -401,7 +403,7 @@ fn main() {
let mut events_loop = if args.is_present("headless") { let mut events_loop = if args.is_present("headless") {
None None
} else { } else {
Some(glutin::EventsLoop::new()) Some(winit::EventsLoop::new())
}; };
let mut window = make_window( let mut window = make_window(
@ -510,7 +512,7 @@ fn main() {
wrench.update(dim); wrench.update(dim);
thing.do_frame(&mut wrench); 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 let Some(window_title) = wrench.take_title() {
if !cfg!(windows) { //TODO: calling `set_title` from inside the `run_forever` loop is illegal... if !cfg!(windows) { //TODO: calling `set_title` from inside the `run_forever` loop is illegal...
window.set_title(&window_title); window.set_title(&window_title);
@ -521,31 +523,31 @@ fn main() {
let mut do_render = false; let mut do_render = false;
match global_event { match global_event {
glutin::Event::Awakened => { winit::Event::Awakened => {
do_render = true; do_render = true;
} }
glutin::Event::WindowEvent { event, .. } => match event { winit::Event::WindowEvent { event, .. } => match event {
glutin::WindowEvent::Closed => { winit::WindowEvent::CloseRequested => {
return glutin::ControlFlow::Break; return winit::ControlFlow::Break;
} }
glutin::WindowEvent::Refresh | winit::WindowEvent::Refresh |
glutin::WindowEvent::Focused(..) => { winit::WindowEvent::Focused(..) => {
do_render = true; 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); cursor_position = WorldPoint::new(x as f32, y as f32);
do_render = true; do_render = true;
} }
glutin::WindowEvent::KeyboardInput { winit::WindowEvent::KeyboardInput {
input: glutin::KeyboardInput { input: winit::KeyboardInput {
state: glutin::ElementState::Pressed, state: winit::ElementState::Pressed,
virtual_keycode: Some(vk), virtual_keycode: Some(vk),
.. ..
}, },
.. ..
} => match vk { } => match vk {
VirtualKeyCode::Escape => { VirtualKeyCode::Escape => {
return glutin::ControlFlow::Break; return winit::ControlFlow::Break;
} }
VirtualKeyCode::P => { VirtualKeyCode::P => {
wrench.renderer.toggle_debug_flags(DebugFlags::PROFILER_DBG); 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(); let dim = window.get_inner_size();
@ -660,12 +662,12 @@ fn main() {
} }
} }
glutin::ControlFlow::Continue winit::ControlFlow::Continue
}; };
match events_loop { match events_loop {
None => { 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 rect = DeviceUintRect::new(DeviceUintPoint::zero(), size);
let pixels = wrench.renderer.read_pixels_rgba8(rect); let pixels = wrench.renderer.read_pixels_rgba8(rect);
save_flipped("screenshot.png", pixels, size); save_flipped("screenshot.png", pixels, size);

View File

@ -10,7 +10,7 @@ use crossbeam::sync::chase_lev;
use dwrote; use dwrote;
#[cfg(any(target_os = "linux", target_os = "macos"))] #[cfg(any(target_os = "linux", target_os = "macos"))]
use font_loader::system_fonts; use font_loader::system_fonts;
use glutin::EventsLoopProxy; use winit::EventsLoopProxy;
use json_frame_writer::JsonFrameWriter; use json_frame_writer::JsonFrameWriter;
use ron_frame_writer::RonFrameWriter; use ron_frame_writer::RonFrameWriter;
use std::collections::HashMap; use std::collections::HashMap;