зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1320320 - handle pipeline epoch in WR binding. r=mchang?
move the epoch counting from gecko to WR binding MozReview-Commit-ID: 8bc6Cy4HDYS
This commit is contained in:
Родитель
e0f89688a5
Коммит
5de4daa857
|
@ -72,7 +72,6 @@ WebRenderBridgeParent::WebRenderBridgeParent(CompositorBridgeParentBase* aCompos
|
||||||
, mParentLayerObserverEpoch(0)
|
, mParentLayerObserverEpoch(0)
|
||||||
, mPendingTransactionId(0)
|
, mPendingTransactionId(0)
|
||||||
, mDestroyed(false)
|
, mDestroyed(false)
|
||||||
, mWREpoch(0)
|
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(mGLContext);
|
MOZ_ASSERT(mGLContext);
|
||||||
MOZ_ASSERT(mCompositor);
|
MOZ_ASSERT(mCompositor);
|
||||||
|
@ -315,7 +314,7 @@ WebRenderBridgeParent::ProcessWebrenderCommands(InfallibleTArray<WebRenderComman
|
||||||
NS_RUNTIMEABORT("not reached");
|
NS_RUNTIMEABORT("not reached");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wr_dp_end(mWRWindowState, mWRState, mWREpoch++);
|
wr_dp_end(mWRWindowState, mWRState);
|
||||||
ScheduleComposition();
|
ScheduleComposition();
|
||||||
DeleteOldImages();
|
DeleteOldImages();
|
||||||
|
|
||||||
|
@ -503,7 +502,7 @@ WebRenderBridgeParent::ClearResources()
|
||||||
mExternalImageIds.Clear();
|
mExternalImageIds.Clear();
|
||||||
|
|
||||||
if (mWRState) {
|
if (mWRState) {
|
||||||
wr_destroy(mWRState);
|
wr_destroy(mWRWindowState, mWRState);
|
||||||
mWRState = nullptr;
|
mWRState = nullptr;
|
||||||
}
|
}
|
||||||
if (mCompositorScheduler) {
|
if (mCompositorScheduler) {
|
||||||
|
|
|
@ -139,7 +139,6 @@ private:
|
||||||
uint64_t mPendingTransactionId;
|
uint64_t mPendingTransactionId;
|
||||||
|
|
||||||
bool mDestroyed;
|
bool mDestroyed;
|
||||||
uint32_t mWREpoch;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace layers
|
} // namespace layers
|
||||||
|
|
|
@ -9,6 +9,7 @@ webrender_traits = {path = "../webrender_traits", version = "0.11.0"}
|
||||||
euclid = "0.10"
|
euclid = "0.10"
|
||||||
app_units = "0.3"
|
app_units = "0.3"
|
||||||
gleam = "0.2"
|
gleam = "0.2"
|
||||||
|
fnv="1.0"
|
||||||
|
|
||||||
[dependencies.webrender]
|
[dependencies.webrender]
|
||||||
path = "../webrender"
|
path = "../webrender"
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
|
use fnv::FnvHasher;
|
||||||
|
use std::collections::HashMap;
|
||||||
use std::ffi::CStr;
|
use std::ffi::CStr;
|
||||||
|
use std::hash::BuildHasherDefault;
|
||||||
use std::{mem, slice};
|
use std::{mem, slice};
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
use gleam::gl;
|
use gleam::gl;
|
||||||
|
@ -212,8 +215,8 @@ pub struct WrWindowState {
|
||||||
_gl_library: GlLibrary,
|
_gl_library: GlLibrary,
|
||||||
root_pipeline_id: PipelineId,
|
root_pipeline_id: PipelineId,
|
||||||
size: Size2D<u32>,
|
size: Size2D<u32>,
|
||||||
epoch: Epoch,
|
|
||||||
render_notifier_lock: Arc<(Mutex<bool>, Condvar)>,
|
render_notifier_lock: Arc<(Mutex<bool>, Condvar)>,
|
||||||
|
pipeline_epoch_map: HashMap<PipelineId, Epoch, BuildHasherDefault<FnvHasher>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct WrState {
|
pub struct WrState {
|
||||||
|
@ -338,8 +341,8 @@ pub extern fn wr_init_window(root_pipeline_id: u64,
|
||||||
_gl_library: library,
|
_gl_library: library,
|
||||||
root_pipeline_id: pipeline_id,
|
root_pipeline_id: pipeline_id,
|
||||||
size: Size2D::new(0, 0),
|
size: Size2D::new(0, 0),
|
||||||
epoch: Epoch(0),
|
|
||||||
render_notifier_lock: notification_lock_clone,
|
render_notifier_lock: notification_lock_clone,
|
||||||
|
pipeline_epoch_map: HashMap::with_hasher(Default::default()),
|
||||||
});
|
});
|
||||||
Box::into_raw(state)
|
Box::into_raw(state)
|
||||||
}
|
}
|
||||||
|
@ -362,6 +365,7 @@ pub extern fn wr_create(window: &mut WrWindowState, width: u32, height: u32, lay
|
||||||
window.size = Size2D::new(width, height);
|
window.size = Size2D::new(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.pipeline_epoch_map.insert(pipeline_id, Epoch(0));
|
||||||
Box::into_raw(state)
|
Box::into_raw(state)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -433,28 +437,34 @@ pub fn wr_composite_window(window: &mut WrWindowState) {
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern fn wr_dp_end(window: &mut WrWindowState,
|
pub extern fn wr_dp_end(window: &mut WrWindowState,
|
||||||
state: &mut WrState,
|
state: &mut WrState) {
|
||||||
epoch: Epoch) {
|
|
||||||
assert!( unsafe { is_in_compositor_thread() });
|
assert!( unsafe { is_in_compositor_thread() });
|
||||||
let root_background_color = ColorF::new(0.3, 0.0, 0.0, 1.0);
|
let root_background_color = ColorF::new(0.3, 0.0, 0.0, 1.0);
|
||||||
let pipeline_id = state.pipeline_id;
|
let pipeline_id = state.pipeline_id;
|
||||||
let (width, height) = state.size;
|
let (width, height) = state.size;
|
||||||
window.epoch = epoch;
|
|
||||||
|
|
||||||
// Should be the root one
|
if let Some(epoch) = window.pipeline_epoch_map.get_mut(&pipeline_id) {
|
||||||
assert!(state.frame_builder.dl_builder.len() == 1);
|
(*epoch).0 += 1;
|
||||||
let mut dl = state.frame_builder.dl_builder.pop().unwrap();
|
|
||||||
state.frame_builder.root_dl_builder.list.append(&mut dl.list);
|
|
||||||
|
|
||||||
state.frame_builder.root_dl_builder.pop_stacking_context();
|
// Should be the root one
|
||||||
|
assert!(state.frame_builder.dl_builder.len() == 1);
|
||||||
|
let mut dl = state.frame_builder.dl_builder.pop().unwrap();
|
||||||
|
state.frame_builder.root_dl_builder.list.append(&mut dl.list);
|
||||||
|
|
||||||
let fb = mem::replace(&mut state.frame_builder, WebRenderFrameBuilder::new(pipeline_id));
|
state.frame_builder.root_dl_builder.pop_stacking_context();
|
||||||
|
|
||||||
//let (dl_builder, aux_builder) = fb.root_dl_builder.finalize();
|
let fb = mem::replace(&mut state.frame_builder, WebRenderFrameBuilder::new(pipeline_id));
|
||||||
window.api.set_root_display_list(root_background_color,
|
|
||||||
epoch,
|
//let (dl_builder, aux_builder) = fb.root_dl_builder.finalize();
|
||||||
Size2D::new(width as f32, height as f32),
|
window.api.set_root_display_list(root_background_color,
|
||||||
fb.root_dl_builder);
|
*epoch,
|
||||||
|
Size2D::new(width as f32, height as f32),
|
||||||
|
fb.root_dl_builder);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
panic!("Could not find epoch for pipeline_id:({},{})", pipeline_id.0, pipeline_id.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
@ -562,9 +572,11 @@ pub extern fn wr_dp_push_image(state:&mut WrState, bounds: WrRect, clip : WrRect
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern fn wr_destroy(state:*mut WrState) {
|
pub extern fn wr_destroy(window: &mut WrWindowState, state:*mut WrState) {
|
||||||
assert!( unsafe { is_in_compositor_thread() });
|
assert!( unsafe { is_in_compositor_thread() });
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
|
window.pipeline_epoch_map.remove(&((*state).pipeline_id));
|
||||||
Box::from_raw(state);
|
Box::from_raw(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -579,33 +591,12 @@ fn wait_for_render_notification(notifier: &Arc<(Mutex<bool>, Condvar)>) {
|
||||||
*finished = false;
|
*finished = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn force_sync_composite(window: &mut WrWindowState) {
|
|
||||||
assert!( unsafe { is_in_compositor_thread() });
|
|
||||||
let last_frame_epoch = window.epoch;
|
|
||||||
|
|
||||||
loop {
|
|
||||||
wait_for_render_notification(&window.render_notifier_lock);
|
|
||||||
wr_composite_window(window);
|
|
||||||
|
|
||||||
let rendered_epoch = window.renderer.current_epoch(window.root_pipeline_id);
|
|
||||||
match rendered_epoch {
|
|
||||||
Some(epoch) => {
|
|
||||||
if epoch == last_frame_epoch {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
None => panic!("Could not get an epoch from the renderer"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gl::flush();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern fn wr_readback_into_buffer(window: &mut WrWindowState, width: u32, height: u32,
|
pub extern fn wr_readback_into_buffer(window: &mut WrWindowState, width: u32, height: u32,
|
||||||
dst_buffer: *mut u8, buffer_size: usize) {
|
dst_buffer: *mut u8, buffer_size: usize) {
|
||||||
assert!( unsafe { is_in_compositor_thread() });
|
assert!( unsafe { is_in_compositor_thread() });
|
||||||
force_sync_composite(window);
|
wr_composite_window(window);
|
||||||
|
gl::flush();
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
let mut slice = slice::from_raw_parts_mut(dst_buffer, buffer_size);
|
let mut slice = slice::from_raw_parts_mut(dst_buffer, buffer_size);
|
||||||
|
|
|
@ -7,6 +7,7 @@ extern crate webrender_traits;
|
||||||
extern crate euclid;
|
extern crate euclid;
|
||||||
extern crate app_units;
|
extern crate app_units;
|
||||||
extern crate gleam;
|
extern crate gleam;
|
||||||
|
extern crate fnv;
|
||||||
|
|
||||||
#[cfg(target_os="macos")]
|
#[cfg(target_os="macos")]
|
||||||
extern crate core_foundation;
|
extern crate core_foundation;
|
||||||
|
|
|
@ -107,7 +107,7 @@ wr_create(wrwindowstate* wrWindow, uint32_t width, uint32_t height, uint64_t lay
|
||||||
WR_FUNC;
|
WR_FUNC;
|
||||||
|
|
||||||
WR_INLINE void
|
WR_INLINE void
|
||||||
wr_destroy(wrstate* wrstate)
|
wr_destroy(wrwindowstate* wrWindow, wrstate* wrstate)
|
||||||
WR_FUNC;
|
WR_FUNC;
|
||||||
|
|
||||||
WR_INLINE WRImageKey
|
WR_INLINE WRImageKey
|
||||||
|
@ -151,7 +151,7 @@ wr_dp_begin(wrwindowstate* wrWindow, wrstate* wrState, uint32_t width, uint32_t
|
||||||
WR_FUNC;
|
WR_FUNC;
|
||||||
|
|
||||||
WR_INLINE void
|
WR_INLINE void
|
||||||
wr_dp_end(wrwindowstate* wrWindow, wrstate* wrState, uint32_t epoch)
|
wr_dp_end(wrwindowstate* wrWindow, wrstate* wrState)
|
||||||
WR_FUNC;
|
WR_FUNC;
|
||||||
|
|
||||||
WR_INLINE void
|
WR_INLINE void
|
||||||
|
|
|
@ -495,6 +495,7 @@ dependencies = [
|
||||||
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gleam 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gleam 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"webrender 0.11.0",
|
"webrender 0.11.0",
|
||||||
|
|
|
@ -482,6 +482,7 @@ dependencies = [
|
||||||
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"app_units 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"euclid 0.10.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"gleam 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
"gleam 0.2.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"webrender 0.11.0",
|
"webrender 0.11.0",
|
||||||
|
|
Загрузка…
Ссылка в новой задаче