Skip to content

Commit 3656b55

Browse files
JeffLi01phip1611
authored andcommitted
uefi-test-runner: speed up ploting of sierpinski triangle by updating changed pixel only
Signed-off-by: Jeff Li <[email protected]>
1 parent e7fe63f commit 3656b55

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

uefi-test-runner/examples/sierpinski.rs

+21-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,23 @@ impl Buffer {
5555
dims: (self.width, self.height),
5656
})
5757
}
58+
59+
/// Update only a pixel to the framebuffer.
60+
fn blit_pixel(
61+
&self,
62+
gop: &mut GraphicsOutput,
63+
coords: (usize, usize),
64+
) -> Result {
65+
gop.blt(BltOp::BufferToVideo {
66+
buffer: &self.pixels,
67+
src: BltRegion::SubRectangle {
68+
coords,
69+
px_stride: self.width,
70+
},
71+
dest: coords,
72+
dims: (1, 1),
73+
})
74+
}
5875
}
5976
// ANCHOR_END: buffer
6077

@@ -90,6 +107,9 @@ fn draw_sierpinski(bt: &BootServices) -> Result {
90107
}
91108
}
92109

110+
// Draw background.
111+
buffer.blit(&mut gop)?;
112+
93113
let size = Point::new(width as f32, height as f32);
94114

95115
// Define the vertices of a big triangle.
@@ -119,7 +139,7 @@ fn draw_sierpinski(bt: &BootServices) -> Result {
119139
pixel.blue = 0;
120140

121141
// Draw the buffer to the screen.
122-
buffer.blit(&mut gop)?;
142+
buffer.blit_pixel(&mut gop, (p.x as usize, p.y as usize))?;
123143
}
124144
}
125145

0 commit comments

Comments
 (0)