Use IpcBytesReceiver to send Display list data

This commit is contained in:
Wu Yu Wei 2022-03-10 17:51:53 +08:00
parent 34b3dafab8
commit 2cffbd7527
2 changed files with 28 additions and 20 deletions

View file

@ -626,25 +626,28 @@ impl<Window: WindowMethods + ?Sized> IOCompositor<Window> {
size, size,
pipeline, pipeline,
size2, size2,
data, receiver,
descriptor, descriptor,
)) => { )) => match receiver.recv() {
self.waiting_on_pending_frame = true; Ok(data) => {
let mut txn = webrender_api::Transaction::new(); self.waiting_on_pending_frame = true;
txn.set_display_list( let mut txn = webrender_api::Transaction::new();
epoch, txn.set_display_list(
None, epoch,
size, None,
( size,
pipeline, (
size2, pipeline,
webrender_api::BuiltDisplayList::from_data(data, descriptor), size2,
), webrender_api::BuiltDisplayList::from_data(data, descriptor),
true, ),
); true,
txn.generate_frame(); );
self.webrender_api txn.generate_frame();
.send_transaction(self.webrender_document, txn); self.webrender_api
.send_transaction(self.webrender_document, txn);
},
Err(e) => warn!("error receiving display data: {:?}", e),
}, },
WebrenderMsg::Layout(script_traits::WebrenderMsg::HitTest( WebrenderMsg::Layout(script_traits::WebrenderMsg::HitTest(

View file

@ -1123,7 +1123,7 @@ pub enum WebrenderMsg {
LayoutSize, LayoutSize,
webrender_api::PipelineId, webrender_api::PipelineId,
LayoutSize, LayoutSize,
Vec<u8>, ipc::IpcBytesReceiver,
BuiltDisplayListDescriptor, BuiltDisplayListDescriptor,
), ),
/// Perform a hit test operation. The result will be returned via /// Perform a hit test operation. The result will be returned via
@ -1181,16 +1181,21 @@ impl WebrenderIpcSender {
(pipeline, size2, list): (webrender_api::PipelineId, LayoutSize, BuiltDisplayList), (pipeline, size2, list): (webrender_api::PipelineId, LayoutSize, BuiltDisplayList),
) { ) {
let (data, descriptor) = list.into_data(); let (data, descriptor) = list.into_data();
let (sender, receiver) = ipc::bytes_channel().unwrap();
if let Err(e) = self.0.send(WebrenderMsg::SendDisplayList( if let Err(e) = self.0.send(WebrenderMsg::SendDisplayList(
webrender_api::Epoch(epoch.0), webrender_api::Epoch(epoch.0),
size, size,
pipeline, pipeline,
size2, size2,
data, receiver,
descriptor, descriptor,
)) { )) {
warn!("Error sending display list: {}", e); warn!("Error sending display list: {}", e);
} }
if let Err(e) = sender.send(&data) {
warn!("Error sending display data: {}", e);
}
} }
/// Perform a hit test operation. Blocks until the operation is complete and /// Perform a hit test operation. Blocks until the operation is complete and