Commit 809d8dd0 authored by robbycerantola's avatar robbycerantola

benchmark bigger image

parent cdf9d19d
......@@ -24,6 +24,6 @@ no_std = []
name = "orbclient"
path = "src/lib.rs"
[target.'cfg(all(not(feature="no_std"), not(target_os="redox")))'.dependencies]
sdl2 = "0.30.0"
sdl2 = "0.31.0"
[target.'cfg(all(not(feature="no_std"), target_os="redox"))'.dependencies]
redox_syscall = "0.1.31"
......@@ -6,27 +6,27 @@ use orbclient::{Color, Window, Renderer, EventOption};
const TIMES:i32 = 10;
fn main() {
let (width, height) = orbclient::get_display_size().unwrap();
//let (width, height) = orbclient::get_display_size().unwrap();
let mut window = Window::new((width as i32)/4,
(height as i32)/4,
width/2,
height/2,
let mut window = Window::new(10,
10,
800,
600,
"IMAGE BENCHMARK")
.unwrap();
window.set(Color::rgb(255,255,255));
//create image data : a green square
let data = vec![Color::rgba(100,200,10,20);200000];
let data2 = vec![Color::rgba(200,100,10,20);200000];
let data = vec![Color::rgba(100,200,10,20);412500];
let data2 = vec![Color::rgba(200,100,10,20);412500];
//draw image benchmarking
println!("Benchmarking implementations to draw an image on window:");
let mut t = time::now();
for _i in 0..TIMES {
window.image(10,10,500,400, &data[..]);
window.image(10,10,750,550, &data[..]);
}
let mut t2 = time::now();
let dt = (t2-t)/TIMES;
......@@ -35,7 +35,7 @@ fn main() {
t = time::now();
for _i in 0..TIMES {
window.image_fast(40,40,500,400, &data2[..]);
window.image_fast(40,40,750,550, &data2[..]);
}
t2 = time::now();
let dt2 = (t2-t)/TIMES;
......
......@@ -307,6 +307,7 @@ pub trait Renderer {
}
}
// Speed improved, but image has to be all inside of window boundary
fn image_fast (&mut self, start_x: i32, start_y: i32, w: u32, _h: u32, image_data: &[Color]) {
let window_w = self.width() as usize;
let window_len = self.data().len();
......@@ -320,7 +321,7 @@ pub trait Renderer {
let y = y0 + start_y;
let x = start_x + i-(y0*w) ;
let window_index = y * window_w + x;
if window_index <= window_len {
if window_index < window_len {
let new = image_data[i].data;
let alpha = (new >> 24) & 0xFF;
if alpha > 0 {
......
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