mirror of
https://github.com/86Box/86Box.git
synced 2025-01-23 17:52:01 -05:00
Removed the useless double-buffering in video/video.c, improves performance and reduces RAM usage.
This commit is contained in:
parent
7163f3a4c1
commit
13dc05cfd2
5 changed files with 21 additions and 21 deletions
|
@ -84,7 +84,7 @@ typedef rgb_t PALETTE[256];
|
||||||
extern int changeframecount;
|
extern int changeframecount;
|
||||||
|
|
||||||
extern volatile int screenshots;
|
extern volatile int screenshots;
|
||||||
extern bitmap_t *buffer32, *render_buffer;
|
extern bitmap_t *buffer32;
|
||||||
extern PALETTE cgapal,
|
extern PALETTE cgapal,
|
||||||
cgapal_mono[6];
|
cgapal_mono[6];
|
||||||
extern uint32_t pal_lookup[256];
|
extern uint32_t pal_lookup[256];
|
||||||
|
|
|
@ -74,7 +74,6 @@
|
||||||
|
|
||||||
volatile int screenshots = 0;
|
volatile int screenshots = 0;
|
||||||
bitmap_t *buffer32 = NULL;
|
bitmap_t *buffer32 = NULL;
|
||||||
bitmap_t *render_buffer = NULL;
|
|
||||||
uint8_t fontdat[2048][8]; /* IBM CGA font */
|
uint8_t fontdat[2048][8]; /* IBM CGA font */
|
||||||
uint8_t fontdatm[2048][16]; /* IBM MDA font */
|
uint8_t fontdatm[2048][16]; /* IBM MDA font */
|
||||||
uint8_t fontdatw[512][32]; /* Wyse700 font */
|
uint8_t fontdatw[512][32]; /* Wyse700 font */
|
||||||
|
@ -364,7 +363,7 @@ video_take_screenshot(const char *fn, int startx, int starty, int y1, int y2, in
|
||||||
for (y = 0; y < h; ++y) {
|
for (y = 0; y < h; ++y) {
|
||||||
b_rgb[y] = (png_byte *) malloc(png_get_rowbytes(png_ptr, info_ptr));
|
b_rgb[y] = (png_byte *) malloc(png_get_rowbytes(png_ptr, info_ptr));
|
||||||
for (x = 0; x < w; ++x) {
|
for (x = 0; x < w; ++x) {
|
||||||
temp = render_buffer->dat[(y * w) + x];
|
temp = buffer32->line[starty + y][startx + x];
|
||||||
|
|
||||||
b_rgb[y][(x) * 3 + 0] = (temp >> 16) & 0xff;
|
b_rgb[y][(x) * 3 + 0] = (temp >> 16) & 0xff;
|
||||||
b_rgb[y][(x) * 3 + 1] = (temp >> 8) & 0xff;
|
b_rgb[y][(x) * 3 + 1] = (temp >> 8) & 0xff;
|
||||||
|
@ -436,19 +435,16 @@ void blit_thread(void *param)
|
||||||
thread_reset_event(blit_data.wake_blit_thread);
|
thread_reset_event(blit_data.wake_blit_thread);
|
||||||
MTR_BEGIN("video", "blit_thread");
|
MTR_BEGIN("video", "blit_thread");
|
||||||
|
|
||||||
if (blit_data.y2 > 0) {
|
if ((video_grayscale || invert_display) && blit_data.y2 > 0) {
|
||||||
for (yy = blit_data.y1; yy < blit_data.y2; yy++) {
|
for (yy = blit_data.y1; yy < blit_data.y2; yy++) {
|
||||||
if (((blit_data.y + yy) >= 0) && ((blit_data.y + yy) < buffer32->h)) {
|
if (((blit_data.y + yy) >= 0) && ((blit_data.y + yy) < buffer32->h)) {
|
||||||
if (video_grayscale || invert_display)
|
video_transform_copy(&(buffer32->line[blit_data.y + yy][blit_data.x]), &(buffer32->line[blit_data.y + yy][blit_data.x]), blit_data.w);
|
||||||
video_transform_copy(&(render_buffer->dat)[yy * blit_data.w], &(buffer32->line[blit_data.y + yy][blit_data.x]), blit_data.w);
|
|
||||||
else
|
|
||||||
memcpy(&(render_buffer->dat)[yy * blit_data.w], &(buffer32->line[blit_data.y + yy][blit_data.x]), blit_data.w << 2);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (screenshots) {
|
if (screenshots) {
|
||||||
if (render_buffer != NULL)
|
if (buffer32 != NULL)
|
||||||
video_screenshot(blit_data.x, blit_data.y, blit_data.y1, blit_data.y2, blit_data.w, blit_data.h);
|
video_screenshot(blit_data.x, blit_data.y, blit_data.y1, blit_data.y2, blit_data.w, blit_data.h);
|
||||||
screenshots--;
|
screenshots--;
|
||||||
video_log("screenshot taken, %i left\n", screenshots);
|
video_log("screenshot taken, %i left\n", screenshots);
|
||||||
|
@ -833,7 +829,6 @@ video_init(void)
|
||||||
|
|
||||||
/* Account for overscan. */
|
/* Account for overscan. */
|
||||||
buffer32 = create_bitmap(2048 + 64, 2048 + 64);
|
buffer32 = create_bitmap(2048 + 64, 2048 + 64);
|
||||||
render_buffer = create_bitmap(2048 + 64, 2048 + 64);
|
|
||||||
|
|
||||||
for (c = 0; c < 64; c++) {
|
for (c = 0; c < 64; c++) {
|
||||||
cgapal[c + 64].r = (((c & 4) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21;
|
cgapal[c + 64].r = (((c & 4) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21;
|
||||||
|
@ -902,7 +897,6 @@ video_close(void)
|
||||||
free(video_8togs);
|
free(video_8togs);
|
||||||
free(video_6to8);
|
free(video_6to8);
|
||||||
|
|
||||||
destroy_bitmap(render_buffer);
|
|
||||||
destroy_bitmap(buffer32);
|
destroy_bitmap(buffer32);
|
||||||
|
|
||||||
if (fontdatksc5601) {
|
if (fontdatksc5601) {
|
||||||
|
|
|
@ -176,7 +176,7 @@ vnc_blit(int x, int y, int y1, int y2, int w, int h)
|
||||||
p = (uint32_t *)&(((uint32_t *)rfb->frameBuffer)[yy*VNC_MAX_X]);
|
p = (uint32_t *)&(((uint32_t *)rfb->frameBuffer)[yy*VNC_MAX_X]);
|
||||||
|
|
||||||
if ((y+yy) >= 0 && (y+yy) < VNC_MAX_Y)
|
if ((y+yy) >= 0 && (y+yy) < VNC_MAX_Y)
|
||||||
memcpy(p, &(render_buffer->dat[yy * w]), w*4);
|
memcpy(p, &(buffer32->line[yy]), w*4);
|
||||||
}
|
}
|
||||||
|
|
||||||
video_blit_complete();
|
video_blit_complete();
|
||||||
|
|
|
@ -810,14 +810,20 @@ static void opengl_main(void* param)
|
||||||
|
|
||||||
static void opengl_blit(int x, int y, int y1, int y2, int w, int h)
|
static void opengl_blit(int x, int y, int y1, int y2, int w, int h)
|
||||||
{
|
{
|
||||||
if (y1 == y2 || h <= 0 || render_buffer == NULL || thread == NULL ||
|
int yy;
|
||||||
|
|
||||||
|
if (y1 == y2 || h <= 0 || buffer32 == NULL || thread == NULL ||
|
||||||
atomic_flag_test_and_set(&blit_info[write_pos].in_use))
|
atomic_flag_test_and_set(&blit_info[write_pos].in_use))
|
||||||
{
|
{
|
||||||
video_blit_complete();
|
video_blit_complete();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(blit_info[write_pos].buffer, &(render_buffer->dat)[y1 * w], w * (y2 - y1) * sizeof(uint32_t));
|
for (yy = y1; yy < y2; yy++) {
|
||||||
|
if ((y + yy) >= 0 && (y + yy) < buffer32->h)
|
||||||
|
memcpy(blit_info[write_pos].buffer + (yy * w * 4),
|
||||||
|
&(((uint32_t *) buffer32->line[y + yy])[x]), w * 4);
|
||||||
|
}
|
||||||
|
|
||||||
video_blit_complete();
|
video_blit_complete();
|
||||||
|
|
||||||
|
|
|
@ -234,24 +234,24 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h)
|
||||||
SDL_Rect r_src;
|
SDL_Rect r_src;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!sdl_enabled || (y1 == y2) || (h <= 0) || (render_buffer == NULL) || (sdl_render == NULL) || (sdl_tex == NULL)) {
|
if (!sdl_enabled || (y1 == y2) || (h <= 0) || (buffer32 == NULL) || (sdl_render == NULL) || (sdl_tex == NULL)) {
|
||||||
video_blit_complete();
|
video_blit_complete();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LockMutex(sdl_mutex);
|
SDL_LockMutex(sdl_mutex);
|
||||||
|
|
||||||
r_src.x = 0;
|
r_src.x = x;
|
||||||
r_src.y = y1;
|
r_src.y = y;
|
||||||
r_src.w = w;
|
r_src.w = w;
|
||||||
r_src.h = y2 - y1;
|
r_src.h = h;
|
||||||
SDL_UpdateTexture(sdl_tex, &r_src, &(render_buffer->dat)[y1 * w], w * 4);
|
SDL_UpdateTexture(sdl_tex, &r_src, &(buffer32->line[y][x]), (2048 + 64) * 4);
|
||||||
video_blit_complete();
|
video_blit_complete();
|
||||||
|
|
||||||
SDL_RenderClear(sdl_render);
|
SDL_RenderClear(sdl_render);
|
||||||
|
|
||||||
r_src.x = 0;
|
r_src.x = x;
|
||||||
r_src.y = 0;
|
r_src.y = y;
|
||||||
r_src.w = w;
|
r_src.w = w;
|
||||||
r_src.h = h;
|
r_src.h = h;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue