mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
wallet: make sure we reset the viewport between each draw call since children draw calls can modify the view too.
This commit is contained in:
@@ -303,6 +303,51 @@ impl App {
|
||||
|
||||
sg.link(node_id, layer_node_id).unwrap();
|
||||
|
||||
// Debugging tool
|
||||
let node_id = create_mesh(&mut sg, "debugtool");
|
||||
|
||||
let node = sg.get_node_mut(node_id).unwrap();
|
||||
let prop = node.get_property("rect").unwrap();
|
||||
prop.set_f32(0, 0.).unwrap();
|
||||
let code =
|
||||
vec![Op::Div((Box::new(Op::LoadVar("h".to_string())), Box::new(Op::ConstFloat32(2.))))];
|
||||
prop.set_expr(1, code).unwrap();
|
||||
let code = vec![Op::LoadVar("w".to_string())];
|
||||
prop.set_expr(2, code).unwrap();
|
||||
prop.set_f32(3, 5.).unwrap();
|
||||
|
||||
node.set_property_u32("z_index", 2).unwrap();
|
||||
|
||||
// Setup the pimpl
|
||||
let (x1, y1) = (0., 0.);
|
||||
let (x2, y2) = (1., 1.);
|
||||
let verts = vec![
|
||||
// top left
|
||||
Vertex { pos: [x1, y1], color: [0., 1., 0., 1.], uv: [0., 0.] },
|
||||
// top right
|
||||
Vertex { pos: [x2, y1], color: [0., 1., 0., 1.], uv: [1., 0.] },
|
||||
// bottom left
|
||||
Vertex { pos: [x1, y2], color: [0., 1., 0., 1.], uv: [0., 1.] },
|
||||
// bottom right
|
||||
Vertex { pos: [x2, y2], color: [0., 1., 0., 1.], uv: [1., 1.] },
|
||||
];
|
||||
let indices = vec![0, 2, 1, 1, 2, 3];
|
||||
drop(sg);
|
||||
let pimpl = Mesh::new(
|
||||
self.ex.clone(),
|
||||
self.sg.clone(),
|
||||
node_id,
|
||||
self.render_api.clone(),
|
||||
verts,
|
||||
indices,
|
||||
)
|
||||
.await;
|
||||
let mut sg = self.sg.lock().await;
|
||||
let node = sg.get_node_mut(node_id).unwrap();
|
||||
node.pimpl = pimpl;
|
||||
|
||||
sg.link(node_id, layer_node_id).unwrap();
|
||||
|
||||
// Create KING GNU!
|
||||
let node_id = create_image(&mut sg, "king");
|
||||
|
||||
|
||||
@@ -270,8 +270,6 @@ struct RenderContext<'a> {
|
||||
draw_calls: &'a HashMap<u64, DrawCall>,
|
||||
uniforms_data: [u8; 128],
|
||||
white_texture: TextureId,
|
||||
// Used for implementing a push/pop for viewport
|
||||
current_view: Rectangle,
|
||||
}
|
||||
|
||||
impl<'a> RenderContext<'a> {
|
||||
@@ -310,7 +308,6 @@ impl<'a> RenderContext<'a> {
|
||||
debug!(target: "gfx", "{}apply_viewport({:?})", ws, view);
|
||||
}
|
||||
prev_view = Some(view.clone());
|
||||
self.current_view = view.clone();
|
||||
self.apply_view(view);
|
||||
}
|
||||
DrawInstruction::ApplyMatrix(model) => {
|
||||
@@ -354,15 +351,14 @@ impl<'a> RenderContext<'a> {
|
||||
|
||||
for dc in draw_calls {
|
||||
self.draw_call(dc, indent + 1);
|
||||
}
|
||||
|
||||
// Reset view back again
|
||||
if let Some(view) = prev_view {
|
||||
if DEBUG_RENDER {
|
||||
debug!(target: "gfx", "{}reset viewport to {:?}", ws, view);
|
||||
// Reset view back again in case the draw call changed it
|
||||
if let Some(view) = &prev_view {
|
||||
if DEBUG_RENDER {
|
||||
debug!(target: "gfx", "{}reset viewport to {:?}", ws, view);
|
||||
}
|
||||
self.apply_view(view);
|
||||
}
|
||||
self.apply_view(&view);
|
||||
self.current_view = view;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -827,7 +823,6 @@ impl EventHandler for Stage {
|
||||
draw_calls: &self.draw_calls,
|
||||
uniforms_data,
|
||||
white_texture: self.white_texture,
|
||||
current_view: default_view,
|
||||
};
|
||||
render_ctx.draw();
|
||||
|
||||
|
||||
@@ -1210,9 +1210,6 @@ impl EditBox {
|
||||
panic!("Node {:?} bad rect property", node);
|
||||
};
|
||||
|
||||
rect.x += parent_rect.x;
|
||||
rect.y += parent_rect.y;
|
||||
|
||||
// draw will recalc this when it's None
|
||||
let render_info = self.regen_mesh(rect.clone()).await;
|
||||
let old_render_info =
|
||||
|
||||
@@ -152,9 +152,6 @@ impl Image {
|
||||
panic!("Node {:?} bad rect property", node);
|
||||
};
|
||||
|
||||
rect.x += parent_rect.x;
|
||||
rect.y += parent_rect.x;
|
||||
|
||||
// draw will recalc this when it's None
|
||||
let mesh = self.regen_mesh(rect.clone()).await;
|
||||
let old_mesh = std::mem::replace(&mut *self.mesh.lock().unwrap(), Some(mesh.clone()));
|
||||
|
||||
@@ -215,9 +215,6 @@ impl Text {
|
||||
panic!("Node {:?} bad rect property", node);
|
||||
};
|
||||
|
||||
rect.x += parent_rect.x;
|
||||
rect.y += parent_rect.x;
|
||||
|
||||
let off_x = rect.x / parent_rect.w;
|
||||
let off_y = rect.y / parent_rect.h;
|
||||
let scale_x = 1. / parent_rect.w;
|
||||
|
||||
Reference in New Issue
Block a user