From 6baa5900fc80402298f285c7c9a2932028fbf7ee Mon Sep 17 00:00:00 2001 From: Surma Date: Fri, 15 Feb 2019 19:36:28 +0100 Subject: [PATCH] Implement tiling --- codecs/rotate/rotate.rs | 18 ++++++++++++------ codecs/rotate/rotate.wasm | Bin 462 -> 738 bytes 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/codecs/rotate/rotate.rs b/codecs/rotate/rotate.rs index d1b19f01..73317eea 100644 --- a/codecs/rotate/rotate.rs +++ b/codecs/rotate/rotate.rs @@ -22,6 +22,8 @@ impl HardUnwrap for Option { } } +const TILE_SIZE: usize = 64; + #[no_mangle] fn rotate(width: usize, height: usize, rotate: usize) { let num_pixels = width * height; @@ -41,12 +43,16 @@ fn rotate(width: usize, height: usize, rotate: usize) { 90 => { let new_width = height; let _new_height = width; - for y in 0..height { - for x in 0..width { - let new_x = (new_width - 1) - y; - let new_y = x; - *out_b.get_mut(new_y * new_width + new_x).unwrap_hard() = - *in_b.get(y * width + x).unwrap_hard(); + for y_start in (0..height).step_by(TILE_SIZE) { + for x_start in (0..width).step_by(TILE_SIZE) { + for y in y_start..(y_start + TILE_SIZE).min(height) { + for x in x_start..(x_start + TILE_SIZE).min(width) { + let new_x = (new_width - 1) - y; + let new_y = x; + *out_b.get_mut(new_y * new_width + new_x).unwrap_hard() = + *in_b.get(y * width + x).unwrap_hard(); + } + } } } } diff --git a/codecs/rotate/rotate.wasm b/codecs/rotate/rotate.wasm index d7514e8e5e89a47fedca3eee56b49c0ca385168f..9977d58f8286fad73675f7ac6afcdc1647331ae4 100755 GIT binary patch literal 738 zcmY+B&2G~`6ov2HnIw)UcATHafo$%0#foLObQUd&0QC`EqeenQLQCTf5|SexfT!sL z^fh41o@d}p2n!T>{&Ma)-`t^Qzf(k{QobR&(OuV(HkuTfp1M~`^|Yd*|4etv9}Z7s zJNkbfyfppYW_S1Sg~`_ShfQ-|zi;*%tZe7e=#f4FO#c7vSXMnn0_s6{7A zXj^H|txtk8eDU`u?0?YPj4=PC*BJ{z;d-Lt)EDEw1~>5J7+<1~MUbk`mncd6t56w9 z))i+)jHqi&3dc_rgjZN%yI#4W7?+Hcl_W|u1S+_p{U?P5bZ=HJ6?kqPbiUiWkqofl z_M^*?o#PuvIKtXUDY#6D^L{}65}DOfChLr>g$o7bO{Evy zRA#=5Ec5tKb6G^?LQ*Kv2^%lRR)%PQtYo~e#>=6XrB56K3h_GfU=ThraAW||2_;&V dqL1NYnD|F^g$uI(&R5TE@$GOp5LrVQ{s3;QY^DGJ delta 249 zcmXX=F>b>!5R*=lV@o>w3%m?P^MTIR;Gsjue&WU=V*tOPK#P2*Z)o?9eMwG8mm>-A zNdBeo@bQ*^DUd5a$-Kmb@W1E!PN(4>b^W4;8z9CctpET3