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

Remove some of the old APIs.

  • Loading branch information
nical committed Jan 18, 2018
commit 075eb8d100d8b96ba0e07c6602619a8e2afef80c
@@ -92,9 +92,9 @@ impl Example for App {
let new_transform = self.transform
.pre_rotate(0.0, 0.0, 1.0, Angle::radians(angle))
.post_translate(LayoutVector3D::new(offset_x, offset_y, 0.0));
api.generate_frame(
document_id,
Some(DynamicProperties {
let mut txn = Transaction::new();
txn.update_dynamic_properties(
DynamicProperties {
transforms: vec![
PropertyValue {
key: self.property_key,
@@ -107,8 +107,10 @@ impl Example for App {
value: self.opacity,
}
],
}),
},
);
txn.generate_frame();
api.send_transaction(document_id, txn);
self.transform = new_transform;
}
_ => (),
@@ -355,21 +355,25 @@ impl Example for App {
}

fn on_event(&mut self, event: glutin::Event, api: &RenderApi, document_id: DocumentId) -> bool {
let mut txn = Transaction::new();
match event {
glutin::Event::Touch(touch) => match self.touch_state.handle_event(touch) {
TouchResult::Pan(pan) => {
api.set_pan(document_id, pan);
api.generate_frame(document_id, None);
txn.set_pan(pan);
}
TouchResult::Zoom(zoom) => {
api.set_pinch_zoom(document_id, ZoomFactor::new(zoom));
api.generate_frame(document_id, None);
txn.set_pinch_zoom(ZoomFactor::new(zoom));
}
TouchResult::None => {}
},
_ => (),
}

if !txn.is_empty() {
txn.generate_frame();
api.send_transaction(document_id, txn);
}

false
}
}
@@ -196,6 +196,7 @@ pub fn main_wrapper<E: Example>(
events.push(event);
events.extend(window.poll_events());

let mut txn = Transaction::new();
for event in events {
match event {
glutin::Event::Closed |
@@ -249,8 +250,7 @@ pub fn main_wrapper<E: Example>(
_,
Some(glutin::VirtualKeyCode::Key1),
) => {
api.set_window_parameters(
document_id,
txn.set_window_parameters(
framebuffer_size,
DeviceUintRect::new(DeviceUintPoint::zero(), framebuffer_size),
1.0
@@ -261,8 +261,7 @@ pub fn main_wrapper<E: Example>(
_,
Some(glutin::VirtualKeyCode::Key2),
) => {
api.set_window_parameters(
document_id,
txn.set_window_parameters(
framebuffer_size,
DeviceUintRect::new(DeviceUintPoint::zero(), framebuffer_size),
2.0
@@ -299,7 +298,6 @@ pub fn main_wrapper<E: Example>(
pipeline_id,
document_id,
);
let mut txn = Transaction::new();
txn.set_display_list(
epoch,
None,
@@ -309,10 +307,10 @@ pub fn main_wrapper<E: Example>(
);
txn.update_resources(resources);
txn.generate_frame();
api.send_transaction(document_id, txn);
}
}
}
api.send_transaction(document_id, txn);

renderer.update();
renderer.render(framebuffer_size).unwrap();
@@ -67,12 +67,10 @@ impl App {
let bounds = DeviceUintRect::new(offset, size);

let document_id = api.add_document(size, layer);
api.set_window_parameters(document_id,
framebuffer_size,
bounds,
1.0
);
api.set_root_pipeline(document_id, pipeline_id);
let mut txn = Transaction::new();
txn.set_window_parameters(framebuffer_size, bounds, 1.0);
txn.set_root_pipeline(pipeline_id);
api.send_transaction(document_id, txn);

self.documents.push(Document {
id: document_id,
@@ -88,8 +88,6 @@ impl App {
let bounds = DeviceUintRect::new(DeviceUintPoint::zero(), framebuffer_size);
let document_id = api.add_document(framebuffer_size, layer);

api.set_root_pipeline(document_id, pipeline_id);

let document = Document {
id: document_id,
pipeline_id,
@@ -117,6 +115,7 @@ impl App {
builder.pop_stacking_context();

let mut txn = Transaction::new();
txn.set_root_pipeline(pipeline_id);
txn.enable_frame_output(document.pipeline_id, true);
txn.update_resources(resources);
txn.set_display_list(
@@ -100,8 +100,10 @@ impl Example for App {
ImageData::new(image_data),
None,
);
api.update_resources(updates);
api.generate_frame(document_id, None);
let mut txn = Transaction::new();
txn.update_resources(updates);
txn.generate_frame();
api.send_transaction(document_id, txn);
}
_ => {}
}
@@ -137,6 +137,7 @@ impl Example for App {
}

fn on_event(&mut self, event: glutin::Event, api: &RenderApi, document_id: DocumentId) -> bool {
let mut txn = Transaction::new();
match event {
glutin::Event::KeyboardInput(glutin::ElementState::Pressed, _, Some(key)) => {
let offset = match key {
@@ -147,8 +148,7 @@ impl Example for App {
_ => return false,
};

api.scroll(
document_id,
txn.scroll(
ScrollLocation::Delta(LayoutVector2D::new(offset.0, offset.1)),
self.cursor_position,
ScrollEventPhase::Start,
@@ -168,8 +168,7 @@ impl Example for App {
glutin::MouseScrollDelta::PixelDelta(dx, dy) => (dx, dy),
};

api.scroll(
document_id,
txn.scroll(
ScrollLocation::Delta(LayoutVector2D::new(dx, dy)),
self.cursor_position,
ScrollEventPhase::Start,
@@ -178,6 +177,8 @@ impl Example for App {
_ => (),
}

api.send_transaction(document_id, txn);

false
}
}
@@ -241,21 +241,25 @@ impl Example for App {
}

fn on_event(&mut self, event: glutin::Event, api: &RenderApi, document_id: DocumentId) -> bool {
let mut txn = Transaction::new();
match event {
glutin::Event::Touch(touch) => match self.touch_state.handle_event(touch) {
TouchResult::Pan(pan) => {
api.set_pan(document_id, pan);
api.generate_frame(document_id, None);
txn.set_pan(pan);
}
TouchResult::Zoom(zoom) => {
api.set_pinch_zoom(document_id, ZoomFactor::new(zoom));
api.generate_frame(document_id, None);
txn.set_pinch_zoom(ZoomFactor::new(zoom));
}
TouchResult::None => {}
},
_ => (),
}

if !txn.is_empty() {
txn.generate_frame();
api.send_transaction(document_id, txn);
}

false
}
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.