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

Move code to the new transaction API. #2298

Merged
merged 3 commits into from Jan 18, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Begin moving to the transaction API.

  • Loading branch information
nical committed Jan 18, 2018
commit 47f05c70f5c9e6866441f9f11022a442199a9dbc
@@ -177,17 +177,18 @@ pub fn main_wrapper<E: Example>(
pipeline_id,
document_id,
);
api.set_display_list(
document_id,
let mut txn = Transaction::new();
txn.set_display_list(
epoch,
None,
layout_size,
builder.finalize(),
true,
resources,
);
api.set_root_pipeline(document_id, pipeline_id);
api.generate_frame(document_id, None);
txn.update_resources(resources);
txn.set_root_pipeline(pipeline_id);
txn.generate_frame();
api.send_transaction(document_id, txn);

println!("Entering event loop");
'outer: for event in window.wait_events() {
@@ -298,16 +299,17 @@ pub fn main_wrapper<E: Example>(
pipeline_id,
document_id,
);
api.set_display_list(
document_id,
let mut txn = Transaction::new();
txn.set_display_list(
epoch,
None,
layout_size,
builder.finalize(),
true,
resources,
);
api.generate_frame(document_id, None);
txn.update_resources(resources);
txn.generate_frame();
api.send_transaction(document_id, txn);
}
}
}
@@ -127,17 +127,16 @@ impl Example for App {
);
builder.pop_stacking_context();

api.set_display_list(
doc.id,
let mut txn = Transaction::new();
txn.set_display_list(
Epoch(0),
None,
doc.content_rect.size,
builder.finalize(),
true,
ResourceUpdates::new(),
);

api.generate_frame(doc.id, None);
txn.generate_frame();
api.send_transaction(doc.id, txn);
}
}
}
@@ -116,18 +116,18 @@ impl App {
builder.push_rect(&info, ColorF::new(1.0, 1.0, 0.0, 1.0));
builder.pop_stacking_context();

api.enable_frame_output(document.id, document.pipeline_id, true);
api.set_display_list(
document.id,
let mut txn = Transaction::new();
txn.enable_frame_output(document.pipeline_id, true);
txn.update_resources(resources);
txn.set_display_list(
Epoch(0),
Some(document.color),
document.content_rect.size,
builder.finalize(),
true,
resources,
);

api.generate_frame(document.id, None);
txn.generate_frame();
api.send_transaction(document.id, txn);
self.output_document = Some(document);
}
}
@@ -50,15 +50,15 @@ impl Example for App {
sub_builder.push_rect(&info, ColorF::new(0.0, 1.0, 0.0, 1.0));
sub_builder.pop_stacking_context();

api.set_display_list(
document_id,
let mut txn = Transaction::new();
txn.set_display_list(
Epoch(0),
None,
sub_bounds.size,
sub_builder.finalize(),
true,
ResourceUpdates::new(),
);
api.send_transaction(document_id, txn);

// And this is for the root pipeline
builder.push_stacking_context(
@@ -298,14 +298,7 @@ impl RenderBackend {
content_size,
list_descriptor,
preserve_frame_state,
resources,
} => {
// TODO: this will be removed from the SetDisplayList message soon.
self.resource_cache.update_resources(
resources,
&mut profile_counters.resources
);

profile_scope!("SetDisplayList");

let mut data;
@@ -379,17 +372,6 @@ impl RenderBackend {
doc.frame_ctx.update_epoch(pipeline_id, epoch);
DocumentOps::nop()
}
DocumentMsg::UpdatePipelineResources { resources, pipeline_id, epoch } => {
profile_scope!("UpdateResources");

self.resource_cache
.update_resources(resources, &mut profile_counters.resources);

doc.scene.update_epoch(pipeline_id, epoch);
doc.frame_ctx.update_epoch(pipeline_id, epoch);

DocumentOps::nop()
}
DocumentMsg::SetRootPipeline(pipeline_id) => {
profile_scope!("SetRootPipeline");

@@ -193,8 +193,6 @@ impl Transaction {
/// * `preserve_frame_state`: If a previous frame exists which matches this pipeline
/// id, this setting determines if frame state (such as scrolling
/// position) should be preserved for this new display list.
/// * `resources`: A set of resource updates that must be applied at the same time as the
/// display list.
///
/// [notifier]: trait.RenderNotifier.html#tymethod.new_frame_ready
pub fn set_display_list(
@@ -215,7 +213,6 @@ impl Transaction {
content_size,
list_descriptor,
preserve_frame_state,
resources: ResourceUpdates::new(),
}
);
self.payloads.push(Payload { epoch, pipeline_id, display_list_data });
@@ -288,6 +285,12 @@ impl Transaction {
pub fn update_dynamic_properties(&mut self, properties: DynamicProperties) {
self.ops.push(DocumentMsg::UpdateDynamicProperties(properties));
}

/// Enable copying of the output of this pipeline id to
/// an external texture for callers to consume.
pub fn enable_frame_output(&mut self, pipeline_id: PipelineId, enable: bool) {
self.ops.push(DocumentMsg::EnableFrameOutput(pipeline_id, enable));
}
}


@@ -365,15 +368,8 @@ pub enum DocumentMsg {
viewport_size: LayoutSize,
content_size: LayoutSize,
preserve_frame_state: bool,
resources: ResourceUpdates,
},
UpdateResources(ResourceUpdates),
// TODO(nical): Remove this once gecko doesn't use it anymore.
UpdatePipelineResources {
resources: ResourceUpdates,
pipeline_id: PipelineId,
epoch: Epoch,
},
UpdateEpoch(PipelineId, Epoch),
SetPageZoom(ZoomFactor),
SetPinchZoom(ZoomFactor),
@@ -398,7 +394,6 @@ impl fmt::Debug for DocumentMsg {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(match *self {
DocumentMsg::SetDisplayList { .. } => "DocumentMsg::SetDisplayList",
DocumentMsg::UpdatePipelineResources { .. } => "DocumentMsg::UpdatePipelineResources",
DocumentMsg::HitTest(..) => "DocumentMsg::HitTest",
DocumentMsg::SetPageZoom(..) => "DocumentMsg::SetPageZoom",
DocumentMsg::SetPinchZoom(..) => "DocumentMsg::SetPinchZoom",
@@ -692,24 +687,6 @@ impl RenderApi {
.unwrap();
}

/// Add/remove/update resources such as images and fonts.
///
/// This is similar to update_resources with the addition that it allows updating
/// a pipeline's epoch.
pub fn update_pipeline_resources(
&self,
resources: ResourceUpdates,
document_id: DocumentId,
pipeline_id: PipelineId,
epoch: Epoch,
) {
self.send(document_id, DocumentMsg::UpdatePipelineResources {
resources,
pipeline_id,
epoch,
});
}

pub fn send_external_event(&self, evt: ExternalEvent) {
let msg = ApiMsg::ExternalEvent(evt);
self.api_sender.send(msg).unwrap();
@@ -816,8 +793,6 @@ impl RenderApi {
/// * `preserve_frame_state`: If a previous frame exists which matches this pipeline
/// id, this setting determines if frame state (such as scrolling
/// position) should be preserved for this new display list.
/// * `resources`: A set of resource updates that must be applied at the same time as the
/// display list.
///
/// [notifier]: trait.RenderNotifier.html#tymethod.new_document_ready
pub fn set_display_list(
@@ -828,7 +803,6 @@ impl RenderApi {
viewport_size: LayoutSize,
(pipeline_id, content_size, display_list): (PipelineId, LayoutSize, BuiltDisplayList),
preserve_frame_state: bool,
resources: ResourceUpdates, // TODO: this will be removed soon.
) {
// TODO(nical) set_display_list uses the epoch to match the displaylist and the payload
// coming from different channels when receiving in the render backend.
@@ -847,7 +821,6 @@ impl RenderApi {
content_size,
list_descriptor,
preserve_frame_state,
resources,
},
);

@@ -860,7 +833,7 @@ impl RenderApi {
.unwrap();
}

pub fn send_transaction(&mut self, document_id: DocumentId, transaction: Transaction) {
pub fn send_transaction(&self, document_id: DocumentId, transaction: Transaction) {
for payload in transaction.payloads {
self.payload_sender.send_payload(payload).unwrap();
}
@@ -290,10 +290,8 @@ impl webrender::ApiRecordingReceiver for JsonFrameWriter {
ref background,
ref viewport_size,
ref list_descriptor,
ref resources,
..
} => {
self.update_resources(resources);
self.begin_write_display_list(
epoch,
pipeline_id,
@@ -60,19 +60,22 @@ impl<'a> RawtestHarness<'a> {
builder: DisplayListBuilder,
resources: Option<ResourceUpdates>
) {
let mut txn = Transaction::new();
let root_background_color = Some(ColorF::new(1.0, 1.0, 1.0, 1.0));
self.wrench.api.set_display_list(
self.wrench.document_id,
if let Some(resources) = resources {
txn.update_resources(resources);
}
txn.set_display_list(
*epoch,
root_background_color,
layout_size,
builder.finalize(),
false,
resources.unwrap_or(ResourceUpdates::new()),
);
epoch.0 += 1;

self.wrench.api.generate_frame(self.wrench.document_id, None);
txn.generate_frame();
self.wrench.api.send_transaction(self.wrench.document_id, txn);
}

fn test_tile_decomposition(&mut self) {
@@ -514,17 +517,19 @@ impl<'a> RawtestHarness<'a> {
image,
);

self.wrench.api.set_display_list(
self.wrench.document_id,
let mut txn = Transaction::new();

txn.set_display_list(
Epoch(0),
Some(ColorF::new(1.0, 1.0, 1.0, 1.0)),
layout_size,
builder.finalize(),
false,
resources,
);
txn.generate_frame();

self.wrench.api.send_transaction(self.wrench.document_id, txn);

self.wrench.api.generate_frame(self.wrench.document_id, None);
let pixels0 = self.render_and_get_pixels(window_rect);

// 2. capture it
@@ -536,15 +541,15 @@ impl<'a> RawtestHarness<'a> {

builder = DisplayListBuilder::new(self.wrench.root_pipeline_id, layout_size);

self.wrench.api.set_display_list(
self.wrench.document_id,
let mut txn = Transaction::new();
txn.set_display_list(
Epoch(1),
Some(ColorF::new(1.0, 0.0, 0.0, 1.0)),
layout_size,
builder.finalize(),
false,
ResourceUpdates::new(),
);
self.wrench.api.send_transaction(self.wrench.document_id, txn);

// 4. load the first one

@@ -168,10 +168,8 @@ impl webrender::ApiRecordingReceiver for RonFrameWriter {
ref background,
ref viewport_size,
ref list_descriptor,
ref resources,
..
} => {
self.update_resources(resources);
self.begin_write_display_list(
epoch,
pipeline_id,
@@ -506,7 +506,6 @@ impl Wrench {
self.window_size_f32(),
display_list,
false,
ResourceUpdates::new(),
);
}

@@ -1133,10 +1133,8 @@ impl webrender::ApiRecordingReceiver for YamlFrameWriterReceiver {
ref background,
ref viewport_size,
ref list_descriptor,
ref resources,
..
} => {
self.frame_writer.update_resources(resources);
self.frame_writer.begin_write_display_list(
&mut self.scene,
epoch,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.