Commit e71af723 authored by robbycerantola's avatar robbycerantola

image wrapper

parent 809d8dd0
......@@ -26,7 +26,7 @@ fn main() {
let mut t = time::now();
for _i in 0..TIMES {
window.image(10,10,750,550, &data[..]);
window.image_legacy(10,10,750,550, &data[..]);
}
let mut t2 = time::now();
let dt = (t2-t)/TIMES;
......
......@@ -294,8 +294,18 @@ pub trait Renderer {
}
/// Display an image
// TODO: Improve speed
fn image(&mut self, start_x: i32, start_y: i32, w: u32, h: u32, data: &[Color]) {
//check if image is inside window
if (w + start_x as u32) > self.width() && h > 100 {
self.image_legacy(start_x, start_y, w, h, data);
}else{
self.image_fast(start_x, start_y, w, h, data);
}
}
// TODO: Improve speed
fn image_legacy(&mut self, start_x: i32, start_y: i32, w: u32, h: u32, data: &[Color]) {
let mut i = 0;
for y in start_y..start_y + h as i32 {
for x in start_x..start_x + w as i32 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment