Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async scene building. #2362

Merged
merged 18 commits into from Feb 22, 2018
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Wake the render backend up after building the scene.

  • Loading branch information
nical committed Feb 21, 2018
commit a481a202a19bebcc8657143be733db8c9efe4714
@@ -10,6 +10,7 @@ use api::{DocumentId, DocumentLayer, DocumentMsg, HitTestResult, IdNamespace, Pi
use api::RenderNotifier;
use api::channel::{MsgReceiver, PayloadReceiver, PayloadReceiverHelperMethods};
use api::channel::{PayloadSender, PayloadSenderHelperMethods};
use api::channel::MsgSender;
#[cfg(feature = "capture")]
use api::CaptureBits;
#[cfg(feature = "replay")]
@@ -595,6 +596,7 @@ impl RenderBackend {


match msg {
ApiMsg::WakeUp => {}
ApiMsg::UpdateResources(updates) => {
self.resource_cache
.update_resources(updates, &mut profile_counters.resources);
@@ -1137,17 +1139,19 @@ pub struct BuiltScene {
pub struct SceneBuilder {
rx: Receiver<SceneBuilderMsg>,
tx: Sender<BuiltScene>,
api_tx: MsgSender<ApiMsg>,
config: FrameBuilderConfig,
}

impl SceneBuilder {
pub fn new(config: FrameBuilderConfig) -> (Self, Sender<SceneBuilderMsg>, Receiver<BuiltScene>) {
pub fn new(config: FrameBuilderConfig, api_tx: MsgSender<ApiMsg>) -> (Self, Sender<SceneBuilderMsg>, Receiver<BuiltScene>) {
let (in_tx, in_rx) = channel();
let (out_tx, out_rx) = channel();
(
SceneBuilder {
rx: in_rx,
tx: out_tx,
api_tx,
config,
},
in_tx,
@@ -1184,6 +1188,7 @@ impl SceneBuilder {
document_id,
render,
}).unwrap();
let _ = self.api_tx.send(ApiMsg::WakeUp);
}
SceneBuilderMsg::Stop => { return false; }
}
@@ -1201,6 +1206,6 @@ impl SceneBuilder {
// Here will go other things that could be offloaded from the render backend
// like some of the rasterization that we know we'd have to do in the next frame.

(frame_builder, clip_scroll_tree)
(frame_builder, clip_scroll_tree)
}
}
@@ -2236,7 +2236,7 @@ impl Renderer {
blob_image_renderer,
)?;

let (scene_builder, scene_tx, scene_rx) = SceneBuilder::new(config);
let (scene_builder, scene_tx, scene_rx) = SceneBuilder::new(config, api_tx.clone());
try! {
thread::Builder::new().name(scene_thread_name.clone()).spawn(move || {
register_thread_with_profiler(scene_thread_name.clone());
@@ -509,6 +509,9 @@ pub enum ApiMsg {
MemoryPressure,
/// Change debugging options.
DebugCommand(DebugCommand),
/// Wakes the render backend's event loop up. Needed when an event is communicated
/// through another channel.
WakeUp,
ShutDown,
}

@@ -527,6 +530,7 @@ impl fmt::Debug for ApiMsg {
ApiMsg::MemoryPressure => "ApiMsg::MemoryPressure",
ApiMsg::DebugCommand(..) => "ApiMsg::DebugCommand",
ApiMsg::ShutDown => "ApiMsg::ShutDown",
ApiMsg::WakeUp => "ApiMsg::WakeUp",
})
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.