commit 74d218d77e26876e7e2ecd4d6babba3c0dba5098
Author: Nicolas Silva <nical@fastmail.com>
Date: Tue Aug 28 11:20:15 2018 +0200
Expose low priority transactions in the API.
diff --git a/webrender/src/render_backend.rs b/webrender/src/render_backend.rs
index ccc779c9..215cd10d 100644
@@ -763,6 +763,7 @@ impl RenderBackend {
resource_updates,
generate_frame: render,
use_scene_builder_thread: false,
+ low_priority: false,
};
self.resource_cache.add_rasterized_blob_images(rasterized_blobs);
@@ -1033,6 +1034,12 @@ impl RenderBackend {
let scene_id = self.make_unique_scene_id();
let doc = self.documents.get_mut(&document_id).unwrap();
+ let tx = if transaction_msg.low_priority {
+ &self.low_priority_scene_tx
+ } else {
+ &self.scene_tx
+ };
+
doc.forward_transaction_to_scene_builder(
transaction_msg,
blob_requests,
@@ -1040,7 +1047,7 @@ impl RenderBackend {
document_id,
scene_id,
&mut self.resource_cache,
- &self.scene_tx,
+ tx,
);
return;
diff --git a/webrender_api/src/api.rs b/webrender_api/src/api.rs
index 8debdd35..505aaf5c 100644
@@ -56,6 +56,8 @@ pub struct Transaction {
use_scene_builder_thread: bool,
generate_frame: bool,
+
+ low_priority: bool,
}
impl Transaction {
@@ -67,6 +69,7 @@ impl Transaction {
payloads: Vec::new(),
use_scene_builder_thread: false, // TODO: make this true by default.
generate_frame: false,
+ low_priority: false,
}
}
@@ -256,6 +259,7 @@ impl Transaction {
resource_updates: self.resource_updates,
use_scene_builder_thread: self.use_scene_builder_thread,
generate_frame: self.generate_frame,
+ low_priority: self.low_priority,
},
self.payloads,
)
@@ -337,6 +341,14 @@ impl Transaction {
self.resource_updates.push(ResourceUpdate::DeleteFontInstance(key));
}
+ // A hint that this transaction can be processed at a lower priority. High-
+ // priority transactions can jump ahead of regular-priority transactions,
+ // but both high- and regular-priority transactions are processed in order
+ // relative to other transactions of the same priority.
+ pub fn mark_low_priority(&mut self) {
+ self.low_priority = true;
+ }
+
pub fn merge(&mut self, mut other: Vec<ResourceUpdate>) {
self.resource_updates.append(&mut other);
}
@@ -354,6 +366,7 @@ pub struct TransactionMsg {
pub resource_updates: Vec<ResourceUpdate>,
pub generate_frame: bool,
pub use_scene_builder_thread: bool,
+ pub low_priority: bool,
}
impl TransactionMsg {
@@ -372,6 +385,7 @@ impl TransactionMsg {
resource_updates: Vec::new(),
generate_frame: false,
use_scene_builder_thread: false,
+ low_priority: false,
}
}
@@ -382,6 +396,7 @@ impl TransactionMsg {
resource_updates: Vec::new(),
generate_frame: false,
use_scene_builder_thread: false,
+ low_priority: false,
}
}
}