mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2025-01-10 02:51:32 +11:00
parent
a48cffc2ac
commit
26e6eca208
|
@ -515,6 +515,41 @@ static void scale_4x(unsigned int* dest, unsigned int* source, int width, int he
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
#define write_8(offset) \
|
||||
dest[(width * offset) + 0] = t; \
|
||||
dest[(width * offset) + 1] = t; \
|
||||
dest[(width * offset) + 2] = t; \
|
||||
dest[(width * offset) + 3] = t; \
|
||||
dest[(width * offset) + 4] = t; \
|
||||
dest[(width * offset) + 5] = t; \
|
||||
dest[(width * offset) + 6] = t; \
|
||||
dest[(width * offset) + 7] = t;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void scale_8x(unsigned int* dest, unsigned int* source, int width, int height, int scale) {
|
||||
int x, y;
|
||||
for (y = 0; y < height; y += scale) {
|
||||
for (x = 0; x < width; x += scale) {
|
||||
const unsigned int t = *source++;
|
||||
|
||||
write_8(0);
|
||||
write_8(1);
|
||||
write_8(2);
|
||||
write_8(3);
|
||||
write_8(4);
|
||||
write_8(5);
|
||||
write_8(6);
|
||||
write_8(7);
|
||||
|
||||
dest += scale;
|
||||
}
|
||||
|
||||
dest += width * (scale - 1);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void mfb_update_with_buffer(void* window_info, void* buffer)
|
||||
|
@ -539,6 +574,11 @@ void mfb_update_with_buffer(void* window_info, void* buffer)
|
|||
scale_4x(info->draw_buffer, buffer, width, height, scale);
|
||||
break;
|
||||
}
|
||||
|
||||
case 8: {
|
||||
scale_8x(info->draw_buffer, buffer, width, height, scale);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
XPutImage(s_display, info->window, s_gc, info->ximage, 0, 0, 0, 0, width, height);
|
||||
|
|
|
@ -374,6 +374,7 @@ impl Window {
|
|||
Scale::X1 => 1,
|
||||
Scale::X2 => 2,
|
||||
Scale::X4 => 4,
|
||||
Scale::X8 => 8,
|
||||
Scale::FitScreen => {
|
||||
let wh: u32 = mfb_get_screen_size();
|
||||
let screen_x = (wh >> 16) as i32;
|
||||
|
@ -387,15 +388,15 @@ impl Window {
|
|||
let w = width as i32 * (scale + 1);
|
||||
let h = height as i32 * (scale + 1);
|
||||
|
||||
if w > screen_x || h > screen_y {
|
||||
if w >= screen_x || h >= screen_y {
|
||||
break;
|
||||
}
|
||||
|
||||
scale *= 2;
|
||||
}
|
||||
|
||||
if scale >= 4 {
|
||||
4
|
||||
if scale >= 8 {
|
||||
8
|
||||
} else {
|
||||
scale
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue