host_flush_shadow_screen moved from mutiple frontends to refresh.cpp

This commit is contained in:
Wolfgang Thaller 2018-01-10 19:42:32 +01:00
parent cba86f86a7
commit 8eca1e6b6b
8 changed files with 34 additions and 140 deletions

View File

@ -550,35 +550,3 @@ int Executor::host_set_cursor_visible(int show_p)
window->setCursor(Qt::BlankCursor);
return true;
}
/* shadow buffer; created on demand */
unsigned char *vdriver_shadow_fbuf = NULL;
void Executor::host_flush_shadow_screen(void)
{
int top_long, left_long, bottom_long, right_long;
/* Lazily allocate a shadow screen. We won't be doing refresh that often,
* so don't waste the memory unless we need it. Note: memory never reclaimed
*/
if(vdriver_shadow_fbuf == NULL)
{
vdriver_shadow_fbuf = (uint8_t *)malloc(vdriver_row_bytes * vdriver_height);
memcpy(vdriver_shadow_fbuf, vdriver_fbuf,
vdriver_row_bytes * vdriver_height);
vdriver_update_screen(0, 0, vdriver_height, vdriver_width, false);
}
else if(find_changed_rect_and_update_shadow((uint32_t *)vdriver_fbuf,
(uint32_t *)vdriver_shadow_fbuf,
(vdriver_row_bytes
/ sizeof(uint32_t)),
vdriver_height,
&top_long, &left_long,
&bottom_long, &right_long))
{
vdriver_update_screen(top_long, (left_long * 32) >> vdriver_log2_bpp,
bottom_long,
(right_long * 32) >> vdriver_log2_bpp, false);
}
}

View File

@ -253,36 +253,3 @@ void Executor::vdriver_shutdown(void)
{
SDL_Quit();
}
/* host functions that should go away */
/* shadow buffer; created on demand */
unsigned char *vdriver_shadow_fbuf = NULL;
void Executor::host_flush_shadow_screen(void)
{
int top_long, left_long, bottom_long, right_long;
/* Lazily allocate a shadow screen. We won't be doing refresh that often,
* so don't waste the memory unless we need it. Note: memory never reclaimed
*/
if(vdriver_shadow_fbuf == NULL)
{
vdriver_shadow_fbuf = (uint8_t *)malloc(vdriver_row_bytes * vdriver_height);
memcpy(vdriver_shadow_fbuf, vdriver_fbuf,
vdriver_row_bytes * vdriver_height);
vdriver_update_screen(0, 0, vdriver_height, vdriver_width, false);
}
else if(find_changed_rect_and_update_shadow((uint32_t *)vdriver_fbuf,
(uint32_t *)vdriver_shadow_fbuf,
(vdriver_row_bytes
/ sizeof(uint32_t)),
vdriver_height,
&top_long, &left_long,
&bottom_long, &right_long))
{
vdriver_update_screen(top_long, (left_long * 32) >> vdriver_log2_bpp,
bottom_long,
(right_long * 32) >> vdriver_log2_bpp, false);
}
}

View File

@ -212,10 +212,6 @@ void Executor::vdriver_shutdown(void)
{
}
void Executor::host_flush_shadow_screen(void)
{
}
static bool ConfirmQuit()
{
const SDL_MessageBoxButtonData buttons[] = {

View File

@ -56,36 +56,3 @@ void Win_Message(FILE *stream, const char *fmt, ...)
fprintf(stream, "%s", buffer);
va_end(ap);
}
/* host functions that should go away */
/* shadow buffer; created on demand */
unsigned char *vdriver_shadow_fbuf = NULL;
void host_flush_shadow_screen(void)
{
int top_long, left_long, bottom_long, right_long;
/* Lazily allocate a shadow screen. We won't be doing refresh that often,
* so don't waste the memory unless we need it. Note: memory never reclaimed
*/
if(vdriver_shadow_fbuf == NULL)
{
vdriver_shadow_fbuf = malloc(vdriver_row_bytes * vdriver_height);
memcpy(vdriver_shadow_fbuf, vdriver_fbuf,
vdriver_row_bytes * vdriver_height);
vdriver_update_screen(0, 0, vdriver_height, vdriver_width, false);
}
else if(find_changed_rect_and_update_shadow((uint32_t *)vdriver_fbuf,
(uint32_t *)vdriver_shadow_fbuf,
(vdriver_row_bytes
/ sizeof(uint32_t)),
vdriver_height,
&top_long, &left_long,
&bottom_long, &right_long))
{
vdriver_update_screen(top_long, (left_long * 32) >> vdriver_log2_bpp,
bottom_long,
(right_long * 32) >> vdriver_log2_bpp, false);
}
}

View File

@ -129,9 +129,6 @@ static XImage *x_image;
/* bytes per row of internal frame buffer */
static int fbuf_allocated_row_bytes;
/* shadow buffer; created on demand */
static unsigned char *shadow_fbuf;
static XImage *x_x_image;
static unsigned char *x_fbuf;
static int x_fbuf_bpp;
@ -2482,32 +2479,3 @@ void Executor::querypointerX(int *xp, int *yp, int *modp)
xp, yp, &mods);
*modp = X_TO_MAC_STATE(mods);
}
/* host functions that should go away */
void Executor::host_flush_shadow_screen(void)
{
int top_long, left_long, bottom_long, right_long;
/* Lazily allocate a shadow screen. We won't be doing refresh that often,
* so don't waste the memory unless we need it.
*/
if(shadow_fbuf == NULL)
{
shadow_fbuf = (unsigned char *)malloc(fbuf_size);
memcpy(shadow_fbuf, vdriver_fbuf, vdriver_row_bytes * vdriver_height);
vdriver_update_screen(0, 0, vdriver_height, vdriver_width, false);
}
else if(find_changed_rect_and_update_shadow((uint32_t *)vdriver_fbuf,
(uint32_t *)shadow_fbuf,
(vdriver_row_bytes
/ sizeof(uint32_t)),
vdriver_height,
&top_long, &left_long,
&bottom_long, &right_long))
{
vdriver_update_screen(top_long, (left_long * 32) >> vdriver_log2_bpp,
bottom_long,
(right_long * 32) >> vdriver_log2_bpp, false);
}
}

View File

@ -81,7 +81,6 @@ void Executor::dirty_rect_accrue(int top, int left, int bottom, int right)
{
unsigned long best_area_added;
int ndr, i, best;
bool done;
if(bottom <= top || right <= left
|| ROMlib_refresh
@ -105,7 +104,7 @@ void Executor::dirty_rect_accrue(int top, int left, int bottom, int right)
}
/* Otherwise, glom away! */
for(done = false; !done;)
for(bool done = false; !done;)
{
int new_area;

View File

@ -13,6 +13,5 @@ extern int host_set_cursor_visible(int show_p);
extern bool host_hide_cursor_if_intersects(int top, int left,
int bottom, int right);
extern void host_beep_at_user(void);
extern void host_flush_shadow_screen(void);
}
#endif /* !__HOST__ */

View File

@ -20,6 +20,7 @@ using namespace Executor;
static TMTask refresh_tm_task;
static bool refresh_tm_task_installed_p = false;
static void flush_shadow_screen();
void Executor::C_handle_refresh()
{
@ -51,7 +52,7 @@ void Executor::C_handle_refresh()
PrimeTime((QElemPtr)&refresh_tm_task, ROMlib_refresh * 1000 / 60);
if(!old_busy_p)
host_flush_shadow_screen();
flush_shadow_screen();
busy_p = old_busy_p;
}
}
@ -79,9 +80,9 @@ void Executor::set_refresh_rate(int new1)
new1 = 0;
#if defined(VDRIVER_SUPPORTS_REAL_SCREEN_BLITS)
if(!last_refresh_set && new)
if(!last_refresh_set && new1)
vdriver_set_up_internal_screen();
else if(last_refresh_set && !new)
else if(last_refresh_set && !new1)
dirty_rect_update_screen();
#endif /* VDRIVER_SUPPORTS_REAL_SCREEN_BLITS */
@ -288,3 +289,32 @@ found_rect:
return true;
}
static void flush_shadow_screen()
{
int top_long, left_long, bottom_long, right_long;
static unsigned char *shadow_fbuf = NULL;
/* Lazily allocate a shadow screen. We won't be doing refresh that often,
* so don't waste the memory unless we need it. Note: memory never reclaimed
*/
if(shadow_fbuf == NULL)
{
shadow_fbuf = (uint8_t *)malloc(vdriver_row_bytes * vdriver_height);
memcpy(shadow_fbuf, vdriver_fbuf,
vdriver_row_bytes * vdriver_height);
vdriver_update_screen(0, 0, vdriver_height, vdriver_width, false);
}
else if(find_changed_rect_and_update_shadow((uint32_t *)vdriver_fbuf,
(uint32_t *)shadow_fbuf,
(vdriver_row_bytes
/ sizeof(uint32_t)),
vdriver_height,
&top_long, &left_long,
&bottom_long, &right_long))
{
vdriver_update_screen(top_long, (left_long * 32) >> vdriver_log2_bpp,
bottom_long,
(right_long * 32) >> vdriver_log2_bpp, false);
}
}