Update extrautils, more efficient font drawing

This commit is contained in:
Jeremy Soller 2016-09-29 13:44:34 -06:00
parent ca97b3d2b3
commit 84331819f7
2 changed files with 4 additions and 4 deletions

View file

@ -91,7 +91,7 @@ impl Display {
#[cfg(not(feature="rusttype"))] #[cfg(not(feature="rusttype"))]
pub fn char(&mut self, x: usize, y: usize, character: char, color: u32, _bold: bool, _italic: bool) { pub fn char(&mut self, x: usize, y: usize, character: char, color: u32, _bold: bool, _italic: bool) {
if x + 8 <= self.width && y + 16 <= self.height { if x + 8 <= self.width && y + 16 <= self.height {
let mut dst = unsafe { self.offscreen.as_mut_ptr().offset((y * self.width + x) as isize) }; let mut dst = self.offscreen.as_mut_ptr() as usize + (y * self.width + x) * 4;
let font_i = 16 * (character as usize); let font_i = 16 * (character as usize);
if font_i + 16 <= FONT.len() { if font_i + 16 <= FONT.len() {
@ -99,10 +99,10 @@ impl Display {
let row_data = FONT[font_i + row]; let row_data = FONT[font_i + row];
for col in 0..8 { for col in 0..8 {
if (row_data >> (7 - col)) & 1 == 1 { if (row_data >> (7 - col)) & 1 == 1 {
unsafe { *dst.offset(col) = color; } unsafe { *((dst + col * 4) as *mut u32) = color; }
} }
} }
dst = unsafe { dst.offset(self.width as isize) }; dst += self.width * 4;
} }
} }
} }

@ -1 +1 @@
Subproject commit 049f539aa40af8d1b0f93898a5967437c852d6ce Subproject commit 5fa43c7df5b495562f86af10883b22cf1728c757