Commit d4a2dd48 authored by robbycerantola's avatar robbycerantola

image wrapper: useless condition erased

parent 178f05c4
......@@ -3,7 +3,7 @@ extern crate time;
use orbclient::{Color, Window, Renderer, EventOption};
const TIMES:i32 = 10;
const TIMES:i32 = 100;
fn main() {
//let (width, height) = orbclient::get_display_size().unwrap();
......@@ -20,6 +20,7 @@ fn main() {
//create image data : a green square
let data = vec![Color::rgba(100,200,10,20);412500];
let data2 = vec![Color::rgba(200,100,10,20);412500];
let data3 = vec![Color::rgba(10,100,200,20);800];
//draw image benchmarking
println!("Benchmarking implementations to draw an image on window:");
......@@ -30,7 +31,7 @@ fn main() {
}
let mut t2 = time::now();
let dt = (t2-t)/TIMES;
println!(" image {:?}",dt );
println!("image_legacy {:?}",dt );
t = time::now();
......@@ -42,6 +43,17 @@ fn main() {
println!("image_fast {:?}",dt2);
println!("-------------------------");
println!("difference {:?}", dt-dt2);
t = time::now();
for _i in 0..TIMES {
window.image(0,0,800,1, &data3[..]);
}
t2 = time::now();
let dt3 = (t2-t)/TIMES;
println!("image wrapper {:?}",dt3);
window.sync();
'events: loop {
......
......@@ -296,7 +296,7 @@ pub trait Renderer {
/// Display an image
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 {
if (w + start_x as u32) > self.width() {
self.image_legacy(start_x, start_y, w, h, data);
}else{
self.image_fast(start_x, start_y, w, h, data);
......
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