mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
graphics-server: minifb: use iterators for drawing the screen
This removes the bounds checks that were being performed, and goes for a pure iterator approach. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
e12a02b1c5
commit
147100fa38
1 changed files with 9 additions and 17 deletions
|
|
@ -76,27 +76,19 @@ impl XousDisplay {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn emulated_to_native(&mut self) {
|
fn emulated_to_native(&mut self) {
|
||||||
for y in 0..HEIGHT {
|
for (dest_row, src_row) in self
|
||||||
for x in 0..WIDTH {
|
.native_buffer
|
||||||
// print!("({}, {}): {} @ {}: ", x, y, (x + y * 44 * 8) / 8, self.emulated_buffer.len());
|
.chunks_mut(WIDTH as _)
|
||||||
// println!("{:08x}", self.emulated_buffer[(x + y * 44 * 8) / 8]);
|
.zip(self.emulated_buffer.chunks(WIDTH_WORDS as _))
|
||||||
if ((x + y * 11 * 32) / 32) >= self.emulated_buffer.len() {
|
{
|
||||||
panic!(
|
for (dest_cell, src_cell) in dest_row.chunks_mut(32).zip(src_row) {
|
||||||
"Value exceeds src buffer ({}, {}) @ {}",
|
for (bit, dest) in dest_cell.iter_mut().enumerate() {
|
||||||
x,
|
*dest = if src_cell & (1 << bit) != 0 {
|
||||||
y,
|
|
||||||
self.emulated_buffer.len()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
if (x + y * WIDTH) > self.native_buffer.len() {
|
|
||||||
panic!("Value exceeds dest buffer");
|
|
||||||
}
|
|
||||||
self.native_buffer[x + y * WIDTH] =
|
|
||||||
if ((self.emulated_buffer[(x + y * 11 * 32) / 32] >> (x % 32)) & 1) > 0 {
|
|
||||||
DARK_COLOUR
|
DARK_COLOUR
|
||||||
} else {
|
} else {
|
||||||
LIGHT_COLOUR
|
LIGHT_COLOUR
|
||||||
};
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue