From 9ec3e9f7e67affd17f947a42d9d4733a387cb9d0 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Sat, 20 Aug 2022 16:21:15 +0800 Subject: [PATCH] support for double buffering for fbcon --- src/newgal/fbcon/fbvideo.c | 44 ++++++++++++++++++++++---------------- src/newgal/fbcon/fbvideo.h | 20 ++++++++--------- 2 files changed, 35 insertions(+), 29 deletions(-) diff --git a/src/newgal/fbcon/fbvideo.c b/src/newgal/fbcon/fbvideo.c index 27c143dd..598014c2 100644 --- a/src/newgal/fbcon/fbvideo.c +++ b/src/newgal/fbcon/fbvideo.c @@ -102,8 +102,6 @@ static void FB_FreeHWSurface(_THIS, GAL_Surface *surface); static void FB_WaitVBL(_THIS); static void FB_WaitIdle(_THIS); -#ifdef _MGSCHEMA_COMPOSITING - #include "../shadow-screen.h" #include "debug.h" @@ -133,13 +131,6 @@ static BOOL FB_SyncUpdate (_THIS) return FALSE; } -#endif /* _MGSCHEMA_COMPOSITING */ - -#if 0 -static int FB_LockHWSurface(_THIS, GAL_Surface *surface); -static void FB_UnlockHWSurface(_THIS, GAL_Surface *surface); -static int FB_FlipHWSurface(_THIS, GAL_Surface *surface); -#endif /* Internal palette functions */ static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo, @@ -169,11 +160,9 @@ static int FB_Available(void) static void FB_DeleteDevice(GAL_VideoDevice *device) { -#ifdef _MGSCHEMA_COMPOSITING if (device->hidden->shadow_screen) { GAL_FreeSurface (device->hidden->real_screen); } -#endif /* _MGSCHEMA_COMPOSITING */ free(device->hidden); free(device); @@ -609,6 +598,7 @@ static GAL_Surface *FB_SetVideoMode(_THIS, GAL_Surface *current, Uint32 Amask; char *surfaces_mem; int surfaces_len; + BOOL dblbuff = FALSE; #ifdef __TARGET_STB810__ bpp = 32; @@ -793,6 +783,23 @@ static GAL_Surface *FB_SetVideoMode(_THIS, GAL_Surface *current, // allocate hardware surface first. GAL_PublicSurface = current; + dblbuff = TRUE; + } + else { + // client never call SetVideoMode + assert (0); + } +#elif !IS_SHAREDFB_SCHEMA_PROC + { + char tmp [8]; + if (GetMgEtcValue ("fbcon", "double_buffering", tmp, 8) >= 0 && + (strcasecmp (tmp, "true") == 0 || strcasecmp (tmp, "yes") == 0)) { + dblbuff = TRUE; + } + } +#endif /* _MGSCHEMA_COMPOSITING */ + + if (dblbuff) { /* create shadow screen */ this->hidden->shadow_screen = GAL_CreateRGBSurface (GAL_HWSURFACE, current->w, current->h, @@ -801,10 +808,12 @@ static GAL_Surface *FB_SetVideoMode(_THIS, GAL_Surface *current, current->format->Bmask, current->format->Amask); if (this->hidden->shadow_screen) { +#if IS_COMPOSITING_SCHEMA this->info.hw_cursor = 1; this->hidden->cursor = NULL; this->SetCursor = shadowScreen_SetCursor; this->MoveCursor = shadowScreen_MoveCursor; +#endif this->UpdateRects = shadowScreen_UpdateRects; this->SyncUpdate = FB_SyncUpdate; @@ -821,10 +830,9 @@ static GAL_Surface *FB_SetVideoMode(_THIS, GAL_Surface *current, } } else { - // client never call SetVideoMode - assert (0); + this->hidden->real_screen = current; + this->hidden->shadow_screen = NULL; } -#endif /* _MGSCHEMA_COMPOSITING */ /* We're done */ return (current); @@ -1042,8 +1050,8 @@ static int FB_AllocHWSurface (_THIS, GAL_Surface *surface) REQUEST req; #ifdef _MGSCHEMA_COMPOSITING - if (!mgIsServer) - return -1; + if (!mgIsServer) + return -1; #endif req.id = REQID_HWSURFACE; req.data = &request; @@ -1296,11 +1304,9 @@ static void FB_VideoQuit(_THIS) } } -#ifdef _MGSCHEMA_COMPOSITING - if (mgIsServer && this->hidden->shadow_screen) { + if (this->hidden->shadow_screen) { GAL_FreeSurface (this->hidden->shadow_screen); } -#endif /* Clean up the memory bucket list */ #ifdef _MGRM_PROCESSES diff --git a/src/newgal/fbcon/fbvideo.h b/src/newgal/fbcon/fbvideo.h index ed572e56..0b52a0c8 100644 --- a/src/newgal/fbcon/fbvideo.h +++ b/src/newgal/fbcon/fbvideo.h @@ -68,19 +68,26 @@ typedef struct vidmem_bucket { /* Private display data */ struct GAL_PrivateVideoData { - /* For compositing schema, we force to use double buffering */ -#ifdef _MGSCHEMA_COMPOSITING + /* When double buffering supported, the real surface represents the ultimate + * scan-out frame buffer, and the shadow screen represents the rendering + * surface. When double buffering disabled, shadow_screen is NULL. + * + * For compositing schema, we force to use double buffering. + * For threads and standalone mode, controlled by `fbcon.double_buffering` + * run-time option. Not supported for processes mode. + */ /* start of header for shadow screen */ int magic, version; GAL_Surface *real_screen, *shadow_screen; RECT dirty_rc; +#if IS_COMPOSITING_SCHEMA /* Used to simulate the hardware cursor. */ GAL_Surface *cursor; int csr_x, csr_y; int hot_x, hot_y; +#endif /* end of header for shadow screen */ -#endif /* _MGSCHEMA_COMPOSITING */ int console_fd; struct fb_var_screeninfo cache_vinfo; @@ -104,13 +111,6 @@ struct GAL_PrivateVideoData { void (*wait_vbl)(_THIS); void (*wait_idle)(_THIS); - -#if 0 /* deprecated code */ - int flip_page; - char *flip_address[2]; -#define flip_page (this->hidden->flip_page) -#define flip_address (this->hidden->flip_address) -#endif }; /* Old variable names */