add visual tests for the new blending RgbaBitmap blit methods

note that we're not testing all of the different blend combinations
for each blit method. specific BlendFunction visual tests will be added
This commit is contained in:
Gered 2023-03-26 13:15:56 -04:00
parent 0345571851
commit 48a76a59e0
7 changed files with 440 additions and 0 deletions

View file

@ -17,6 +17,18 @@ fn setup() -> RgbaBitmap {
RgbaBitmap::new(SCREEN_WIDTH, SCREEN_HEIGHT).unwrap()
}
fn setup_for_blending() -> RgbaBitmap {
let (texture, _) = RgbaBitmap::load_file(test_assets_file(Path::new("texture.lbm")).as_path()).unwrap();
let mut screen = RgbaBitmap::new(SCREEN_WIDTH, SCREEN_HEIGHT).unwrap();
//screen.clear(LIGHTER_BACKGROUND);
for y in 0..(SCREEN_HEIGHT as f32 / texture.height() as f32).ceil() as i32 {
for x in 0..(SCREEN_WIDTH as f32 / texture.width() as f32).ceil() as i32 {
screen.blit(RgbaBlitMethod::Solid, &texture, x * texture.width() as i32, y * texture.height() as i32);
}
}
screen
}
fn verify_visual(screen: &RgbaBitmap, source: &Path) -> bool {
let (source_bmp, _) = RgbaBitmap::load_file(source).unwrap();
*screen == source_bmp
@ -366,6 +378,40 @@ fn generate_bitmap(width: i32, height: i32) -> RgbaBitmap {
bitmap
}
fn generate_bitmap_with_varied_alpha(width: i32, height: i32) -> RgbaBitmap {
let x_third = width / 3;
let y_third = height / 3;
let mut bitmap = RgbaBitmap::new(width as u32, height as u32).unwrap();
bitmap.clear(0); // alpha=0
bitmap.filled_rect(0, 0, x_third, y_third, 0x330000aa);
bitmap.filled_rect(x_third * 2 + 1, y_third * 2 + 1, width - 1, height - 1, 0x6600aa00);
bitmap.filled_rect(0, y_third * 2 + 1, x_third, height - 1, 0x9900aaaa);
bitmap.filled_rect(x_third * 2 + 1, 0, width - 1, y_third, 0xccaa0000);
bitmap.filled_rect(x_third, y_third, x_third * 2 + 1, y_third * 2 + 1, COLOR_MAGENTA);
bitmap.rect(0, 0, width - 1, height - 1, COLOR_BROWN);
bitmap
}
fn generate_solid_bitmap_with_varied_alpha(width: i32, height: i32) -> RgbaBitmap {
let x_third = width / 3;
let y_third = height / 3;
let mut bitmap = RgbaBitmap::new(width as u32, height as u32).unwrap();
bitmap.clear(to_argb32(255, 0, 0, 0));
bitmap.filled_rect(0, 0, x_third, y_third, 0x330000aa);
bitmap.filled_rect(x_third * 2 + 1, y_third * 2 + 1, width - 1, height - 1, 0x6600aa00);
bitmap.filled_rect(0, y_third * 2 + 1, x_third, height - 1, 0x9900aaaa);
bitmap.filled_rect(x_third * 2 + 1, 0, width - 1, y_third, 0xccaa0000);
bitmap.filled_rect(x_third, y_third, x_third * 2 + 1, y_third * 2 + 1, COLOR_MAGENTA);
bitmap.rect(0, 0, width - 1, height - 1, COLOR_BROWN);
bitmap
}
#[test]
fn solid_blits() {
use RgbaBlitMethod::*;
@ -433,6 +479,72 @@ fn solid_blits() {
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
}
#[test]
fn blended_solid_blits() {
use RgbaBlitMethod::*;
let mut screen = setup_for_blending();
let bmp16 = generate_solid_bitmap_with_varied_alpha(16, 16);
let bmp12 = generate_solid_bitmap_with_varied_alpha(12, 12);
let bmp21 = generate_solid_bitmap_with_varied_alpha(21, 21);
let bmp3 = generate_solid_bitmap_with_varied_alpha(3, 3);
let x = 40;
let y = 20;
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, x + 16, y + 48);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp12, x + 80, y + 48);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp21, x + 144, y + 48);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp3, x + 208, y + 48);
let x = 40;
let y = 110;
unsafe {
screen.blit_unchecked(SolidBlended(BlendFunction::Blend), &bmp16, x + 16, y + 48);
screen.blit_unchecked(SolidBlended(BlendFunction::Blend), &bmp12, x + 80, y + 48);
screen.blit_unchecked(SolidBlended(BlendFunction::Blend), &bmp21, x + 144, y + 48);
screen.blit_unchecked(SolidBlended(BlendFunction::Blend), &bmp3, x + 208, y + 48);
}
//////
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, -3, 46);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, -4, 76);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, -8, 106);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, -12, 136);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, -13, 166);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, -14, 196);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, -16, 226);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 46, -3);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 76, -4);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 106, -8);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 136, -12);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 166, -13);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 196, -14);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 226, -16);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 307, 46);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 308, 76);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 312, 106);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 316, 136);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 317, 166);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 318, 196);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 320, 226);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 46, 227);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 76, 228);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 106, 232);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 136, 236);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 166, 237);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 196, 238);
screen.blit(SolidBlended(BlendFunction::Blend), &bmp16, 226, 240);
let path = reference_file(Path::new("blended_solid_blits.png"));
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
}
#[test]
fn solid_flipped_blits() {
use RgbaBlitMethod::*;
@ -497,6 +609,69 @@ fn solid_flipped_blits() {
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
}
#[test]
fn blended_solid_flipped_blits() {
use RgbaBlitMethod::*;
let mut screen = setup_for_blending();
let bmp = generate_solid_bitmap_with_varied_alpha(16, 16);
let x = 40;
let y = 20;
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, x + 16, y + 48);
screen.blit(SolidFlippedBlended { horizontal_flip: true, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, x + 80, y + 48);
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, x + 144, y + 48);
screen.blit(SolidFlippedBlended { horizontal_flip: true, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, x + 208, y + 48);
let x = 40;
let y = 110;
unsafe {
screen.blit_unchecked(SolidFlippedBlended { horizontal_flip: false, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, x + 16, y + 48);
screen.blit_unchecked(SolidFlippedBlended { horizontal_flip: true, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, x + 80, y + 48);
screen.blit_unchecked(SolidFlippedBlended { horizontal_flip: false, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, x + 144, y + 48);
screen.blit_unchecked(SolidFlippedBlended { horizontal_flip: true, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, x + 208, y + 48);
}
//////
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, -3, 46);
screen.blit(SolidFlippedBlended { horizontal_flip: true, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, -4, 76);
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, -8, 106);
screen.blit(SolidFlippedBlended { horizontal_flip: true, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, -12, 136);
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, -13, 166);
screen.blit(SolidFlippedBlended { horizontal_flip: true, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, -14, 196);
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, -16, 226);
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, 46, -3);
screen.blit(SolidFlippedBlended { horizontal_flip: true, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, 76, -4);
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, 106, -8);
screen.blit(SolidFlippedBlended { horizontal_flip: true, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, 136, -12);
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, 166, -13);
screen.blit(SolidFlippedBlended { horizontal_flip: true, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, 196, -14);
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, 226, -16);
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, 307, 46);
screen.blit(SolidFlippedBlended { horizontal_flip: true, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, 308, 76);
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, 312, 106);
screen.blit(SolidFlippedBlended { horizontal_flip: true, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, 316, 136);
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, 317, 166);
screen.blit(SolidFlippedBlended { horizontal_flip: true, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, 318, 196);
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, 320, 226);
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, 46, 227);
screen.blit(SolidFlippedBlended { horizontal_flip: true, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, 76, 228);
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, 106, 232);
screen.blit(SolidFlippedBlended { horizontal_flip: true, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, 136, 236);
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, 166, 237);
screen.blit(SolidFlippedBlended { horizontal_flip: true, vertical_flip: false, blend: BlendFunction::Blend }, &bmp, 196, 238);
screen.blit(SolidFlippedBlended { horizontal_flip: false, vertical_flip: true, blend: BlendFunction::Blend }, &bmp, 226, 240);
let path = reference_file(Path::new("blended_solid_flipped_blits.png"));
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
}
#[test]
fn transparent_blits() {
use RgbaBlitMethod::*;
@ -566,6 +741,74 @@ fn transparent_blits() {
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
}
#[test]
fn blended_transparent_blits() {
use RgbaBlitMethod::*;
let mut screen = setup_for_blending();
let bmp16 = generate_solid_bitmap_with_varied_alpha(16, 16);
let bmp12 = generate_solid_bitmap_with_varied_alpha(12, 12);
let bmp21 = generate_solid_bitmap_with_varied_alpha(21, 21);
let bmp3 = generate_solid_bitmap_with_varied_alpha(3, 3);
let transparent_color = to_argb32(255, 0, 0, 0);
let x = 40;
let y = 20;
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, x + 16, y + 48);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp12, x + 80, y + 48);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp21, x + 144, y + 48);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp3, x + 208, y + 48);
let x = 40;
let y = 110;
unsafe {
screen.blit_unchecked(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, x + 16, y + 48);
screen.blit_unchecked(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp12, x + 80, y + 48);
screen.blit_unchecked(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp21, x + 144, y + 48);
screen.blit_unchecked(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp3, x + 208, y + 48);
}
//////
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, -3, 46);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, -4, 76);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, -8, 106);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, -12, 136);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, -13, 166);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, -14, 196);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, -16, 226);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 46, -3);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 76, -4);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 106, -8);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 136, -12);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 166, -13);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 196, -14);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 226, -16);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 307, 46);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 308, 76);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 312, 106);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 316, 136);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 317, 166);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 318, 196);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 320, 226);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 46, 227);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 76, 228);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 106, 232);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 136, 236);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 166, 237);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 196, 238);
screen.blit(TransparentBlended { transparent_color, blend: BlendFunction::Blend }, &bmp16, 226, 240);
let path = reference_file(Path::new("blended_transparent_blits.png"));
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
}
#[test]
fn transparent_flipped_blits() {
use RgbaBlitMethod::*;
@ -632,6 +875,72 @@ fn transparent_flipped_blits() {
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
}
#[test]
fn blended_transparent_flipped_blits() {
use RgbaBlitMethod::*;
let mut screen = setup_for_blending();
let bmp = generate_solid_bitmap_with_varied_alpha(16, 16);
let transparent_color = to_argb32(255, 0, 0, 0);
let blend = BlendFunction::Blend;
let x = 40;
let y = 20;
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: false, blend }, &bmp, x + 16, y + 48);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: true, vertical_flip: false, blend }, &bmp, x + 80, y + 48);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: true, blend }, &bmp, x + 144, y + 48);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: true, vertical_flip: true, blend }, &bmp, x + 208, y + 48);
let x = 40;
let y = 110;
unsafe {
screen.blit_unchecked(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: false, blend }, &bmp, x + 16, y + 48);
screen.blit_unchecked(TransparentFlippedBlended { transparent_color, horizontal_flip: true, vertical_flip: false, blend }, &bmp, x + 80, y + 48);
screen.blit_unchecked(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: true, blend }, &bmp, x + 144, y + 48);
screen.blit_unchecked(TransparentFlippedBlended { transparent_color, horizontal_flip: true, vertical_flip: true, blend }, &bmp, x + 208, y + 48);
}
//////
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: false, blend }, &bmp, -3, 46);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: true, vertical_flip: false, blend }, &bmp, -4, 76);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: true, blend }, &bmp, -8, 106);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: true, vertical_flip: true, blend }, &bmp, -12, 136);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: true, blend }, &bmp, -13, 166);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: true, vertical_flip: false, blend }, &bmp, -14, 196);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: true, blend }, &bmp, -16, 226);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: false, blend }, &bmp, 46, -3);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: true, vertical_flip: false, blend }, &bmp, 76, -4);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: true, blend }, &bmp, 106, -8);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: true, vertical_flip: true, blend }, &bmp, 136, -12);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: false, blend }, &bmp, 166, -13);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: true, vertical_flip: false, blend }, &bmp, 196, -14);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: true, blend }, &bmp, 226, -16);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: false, blend }, &bmp, 307, 46);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: true, vertical_flip: false, blend }, &bmp, 308, 76);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: true, blend }, &bmp, 312, 106);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: true, vertical_flip: true, blend }, &bmp, 316, 136);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: false, blend }, &bmp, 317, 166);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: true, vertical_flip: false, blend }, &bmp, 318, 196);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: true, blend }, &bmp, 320, 226);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: false, blend }, &bmp, 46, 227);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: true, vertical_flip: false, blend }, &bmp, 76, 228);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: true, blend }, &bmp, 106, 232);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: true, vertical_flip: true, blend }, &bmp, 136, 236);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: false, blend }, &bmp, 166, 237);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: true, vertical_flip: false, blend }, &bmp, 196, 238);
screen.blit(TransparentFlippedBlended { transparent_color, horizontal_flip: false, vertical_flip: true, blend }, &bmp, 226, 240);
let path = reference_file(Path::new("blended_transparent_flipped_blits.png"));
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
}
#[test]
fn transparent_single_blits() {
use RgbaBlitMethod::*;
@ -828,6 +1137,71 @@ fn rotozoom_blits() {
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
}
#[test]
fn blended_rotozoom_blits() {
use RgbaBlitMethod::*;
let mut screen = setup_for_blending();
let bmp = generate_bitmap_with_varied_alpha(16, 16);
let blend = BlendFunction::Blend;
let x = 40;
let y = 20;
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, x + 16, y + 48);
screen.blit(RotoZoomBlended { angle: 0.3, scale_x: 1.5, scale_y: 1.0, blend }, &bmp, x + 80, y + 48);
screen.blit(RotoZoomBlended { angle: 0.6, scale_x: 1.0, scale_y: 1.5, blend }, &bmp, x + 144, y + 48);
screen.blit(RotoZoomBlended { angle: 2.0, scale_x: 0.7, scale_y: 0.7, blend }, &bmp, x + 208, y + 48);
let x = 40;
let y = 110;
unsafe {
screen.blit_unchecked(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, x + 16, y + 48);
screen.blit_unchecked(RotoZoomBlended { angle: 0.3, scale_x: 1.5, scale_y: 1.0, blend }, &bmp, x + 80, y + 48);
screen.blit_unchecked(RotoZoomBlended { angle: 0.6, scale_x: 1.0, scale_y: 1.5, blend }, &bmp, x + 144, y + 48);
screen.blit_unchecked(RotoZoomBlended { angle: 2.0, scale_x: 0.7, scale_y: 0.7, blend }, &bmp, x + 208, y + 48);
}
//////
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, -3, 46);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, -4, 76);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, -8, 106);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, -12, 136);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, -13, 166);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, -14, 196);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, -16, 226);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 46, -3);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 76, -4);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 106, -8);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 136, -12);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 166, -13);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 196, -14);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 226, -16);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 307, 46);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 308, 76);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 312, 106);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 316, 136);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 317, 166);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 318, 196);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 320, 226);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 46, 227);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 76, 228);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 106, 232);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 136, 236);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 166, 237);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 196, 238);
screen.blit(RotoZoomBlended { angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 226, 240);
let path = reference_file(Path::new("blended_rotozoom_blits.png"));
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
}
#[test]
fn rotozoom_transparent_blits() {
use RgbaBlitMethod::*;
@ -893,3 +1267,69 @@ fn rotozoom_transparent_blits() {
//screen.to_png_file(path.as_path()).unwrap();
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
}
#[test]
fn blended_rotozoom_transparent_blits() {
use RgbaBlitMethod::*;
let mut screen = setup_for_blending();
let bmp = generate_solid_bitmap_with_varied_alpha(16, 16);
let transparent_color = to_argb32(255, 0, 0, 0);
let blend = BlendFunction::Blend;
let x = 40;
let y = 20;
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, x + 16, y + 48);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 0.3, scale_x: 1.5, scale_y: 1.0, blend }, &bmp, x + 80, y + 48);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 0.6, scale_x: 1.0, scale_y: 1.5, blend }, &bmp, x + 144, y + 48);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 2.0, scale_x: 0.7, scale_y: 0.7, blend }, &bmp, x + 208, y + 48);
let x = 40;
let y = 110;
unsafe {
screen.blit_unchecked(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, x + 16, y + 48);
screen.blit_unchecked(RotoZoomTransparentBlended { transparent_color, angle: 0.3, scale_x: 1.5, scale_y: 1.0, blend }, &bmp, x + 80, y + 48);
screen.blit_unchecked(RotoZoomTransparentBlended { transparent_color, angle: 0.6, scale_x: 1.0, scale_y: 1.5, blend }, &bmp, x + 144, y + 48);
screen.blit_unchecked(RotoZoomTransparentBlended { transparent_color, angle: 2.0, scale_x: 0.7, scale_y: 0.7, blend }, &bmp, x + 208, y + 48);
}
//////
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, -3, 46);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, -4, 76);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, -8, 106);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, -12, 136);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, -13, 166);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, -14, 196);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, -16, 226);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 46, -3);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 76, -4);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 106, -8);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 136, -12);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 166, -13);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 196, -14);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 226, -16);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 307, 46);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 308, 76);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 312, 106);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 316, 136);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 317, 166);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 318, 196);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 320, 226);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 46, 227);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 76, 228);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 106, 232);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 136, 236);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 166, 237);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 196, 238);
screen.blit(RotoZoomTransparentBlended { transparent_color, angle: 1.3, scale_x: 1.0, scale_y: 1.0, blend }, &bmp, 226, 240);
let path = reference_file(Path::new("blended_rotozoom_transparent_blits.png"));
//screen.to_png_file(path.as_path(), PngFormat::RGBA).unwrap();
assert!(verify_visual(&screen, &path), "bitmap differs from source image: {:?}", path);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB