add CopyVideoInfoToSharedRes method in GAL engine for PROCS and calling this method to copy the video info to shared resource segment when the process is the server

This commit is contained in:
Vincent Wei
2020-03-16 17:38:50 +08:00
parent 072ac4e166
commit f8ced41de6
8 changed files with 60 additions and 19 deletions

View File

@@ -971,6 +971,11 @@ BYTE* gal_PutPixelKeyAlpha (GAL_Surface* dst,
#define mg_TerminateGAL GAL_VideoQuit
#ifdef _MGRM_PROCESSES
/* Since 5.0.0: copy video information to the shared resource */
BOOL GAL_CopyVideoInfoToSharedRes (void);
#endif /* _MGRM_PROCESSES */
#ifdef _MGGAL_DRM
/* functions implemented in DRM engine. */
BOOL __drm_get_surface_info (GAL_Surface *surface, DrmSurfaceInfo* info);

View File

@@ -106,7 +106,6 @@ typedef struct tagG_RES {
Uint32 video_rmask, video_gmask, video_bmask, video_amask;
#ifdef _MGGAL_DRM
char video_exdriver [LEN_EXDRIVER_NAME + 1];
// char video_fourcc [LEN_FOURCC_FORMAT + 1];
Uint32 video_drm_format;
Uint32 video_dbl_buff:1;
#endif
@@ -172,7 +171,6 @@ typedef G_RES* PG_RES;
#define SHAREDRES_VIDEO_ENGINE (((PG_RES)mgSharedRes)->video_engine)
#define SHAREDRES_VIDEO_MODE (((PG_RES)mgSharedRes)->video_mode)
#define SHAREDRES_VIDEO_DEVICE (((PG_RES)mgSharedRes)->video_device)
// #define SHAREDRES_VIDEO_FOURCC (((PG_RES)mgSharedRes)->video_fourcc)
#define SHAREDRES_VIDEO_DPI (((PG_RES)mgSharedRes)->video_dpi)
#define SHAREDRES_VIDEO_HRES (((PG_RES)mgSharedRes)->video_hres)
#define SHAREDRES_VIDEO_VRES (((PG_RES)mgSharedRes)->video_vres)
@@ -214,7 +212,7 @@ typedef G_RES* PG_RES;
# define SHAREDRES_SEMID_SHARED_SURF (((PG_RES)mgSharedRes)->semid_shared_surf)
#endif
#define SHAREDRES_NR_GLOBALS (((PG_RES)mgSharedRes)->nr_globals)
#define SHAREDRES_NR_GLOBALS (((PG_RES)mgSharedRes)->nr_globals)
#define SHAREDRES_DEF_NR_TOPMOSTS (((PG_RES)mgSharedRes)->def_nr_topmosts)
#define SHAREDRES_DEF_NR_NORMALS (((PG_RES)mgSharedRes)->dev_nr_normals)

View File

@@ -3677,9 +3677,7 @@ static int srvDesktopCommand (int id)
unlock_zi_for_read (__mg_zorder_info);
}
else if (id == IDM_ENDSESSION) {
if (SERVER_HAS_NO_MAINWINDOW()) {
ExitGUISafely (-1);
}
SendMessage (HWND_DESKTOP, MSG_ENDSESSION, 0, 0);
}
#ifdef _MGHAVE_MENU
else if (id >= IDM_FIRSTWINDOW && id < IDM_SWITCH_LAYER) {
@@ -4094,10 +4092,8 @@ static int srvSesseionMessageHandler (int message, WPARAM wParam, LPARAM lParam)
break;
case MSG_ERASEDESKTOP:
if (dsk_ops->paint_desktop)
dsk_ops->paint_desktop(dt_context, hDesktopDC, (PRECT)lParam);
break;
case MSG_DT_KEYLONGPRESS:
@@ -4114,6 +4110,7 @@ static int srvSesseionMessageHandler (int message, WPARAM wParam, LPARAM lParam)
#ifdef _MGHAVE_MENU
case MSG_DT_RBUTTONUP:
if (sg_DesktopMenu)
srvUpdateDesktopMenu ();
#endif
case MSG_DT_LBUTTONDOWN:

View File

@@ -501,6 +501,8 @@ int InitGUI (int argc, const char* agr[])
SHAREDRES_VIDEO_GMASK = __gal_screen->format->Gmask;
SHAREDRES_VIDEO_BMASK = __gal_screen->format->Bmask;
SHAREDRES_VIDEO_AMASK = __gal_screen->format->Amask;
GAL_CopyVideoInfoToSharedRes();
}
else {
_DBG_PRINTF("Engien info from shared resource: %s %s %d\n",

View File

@@ -86,6 +86,9 @@ static int DRM_SetColors(_THIS, int firstcolor, int ncolors, GAL_Color *colors);
static void DRM_VideoQuit(_THIS);
static int DRM_Suspend(_THIS);
static int DRM_Resume(_THIS);
#ifdef _MGRM_PROCESSES
static void DRM_CopyVideoInfoToSharedRes(_THIS);
#endif
/* DRM engine methods for dumb buffer */
static GAL_Surface *DRM_SetVideoMode(_THIS, GAL_Surface *current,
@@ -225,7 +228,6 @@ static uint32_t get_drm_format_from_etc(int* bpp)
format = fourcc_code(fourcc[0], fourcc[1], fourcc[2], fourcc[3]);
}
#ifdef _MGRM_PROCESSES
SHAREDRES_VIDEO_DRM_FORMAT = format;
}
else {
format = SHAREDRES_VIDEO_DRM_FORMAT;
@@ -850,6 +852,12 @@ static void DRM_DeleteDevice(GAL_VideoDevice *device)
{
drm_cleanup(device->hidden);
if (device->hidden->dev_name)
free (device->hidden->dev_name);
if (device->hidden->ex_driver)
free (device->hidden->ex_driver);
if (device->hidden->driver && device->hidden->driver_ops) {
device->hidden->driver_ops->destroy_driver(device->hidden->driver);
}
@@ -925,9 +933,8 @@ static DrmDriverOps* load_external_driver (DrmVideoData* vdata,
filename = buff;
}
vdata->ex_driver = strdup(filename);
#ifdef _MGRM_PROCESSES
strncpy (SHAREDRES_VIDEO_EXDRIVER, filename, LEN_EXDRIVER_NAME);
SHAREDRES_VIDEO_EXDRIVER[LEN_EXDRIVER_NAME] = 0;
}
else {
filename = SHAREDRES_VIDEO_EXDRIVER;
@@ -1032,11 +1039,12 @@ static int open_drm_device(GAL_VideoDevice *device)
static GAL_VideoDevice *DRM_CreateDevice(int devindex)
{
char dev_name [LEN_DEVICE_NAME + 1];
GAL_VideoDevice *device;
/* Initialize all variables that we clean on shutdown */
device = (GAL_VideoDevice *)malloc(sizeof(GAL_VideoDevice));
if ( device ) {
if (device) {
memset(device, 0, (sizeof (*device)));
device->hidden = (struct GAL_PrivateVideoData *)
calloc(1, (sizeof (*device->hidden)));
@@ -1053,14 +1061,12 @@ static GAL_VideoDevice *DRM_CreateDevice(int devindex)
#ifdef _MGRM_PROCESSES
if (mgIsServer) {
#endif
if (GetMgEtcValue ("drm", "device",
device->hidden->dev_name, LEN_DEVICE_NAME) < 0) {
strcpy(device->hidden->dev_name, "/dev/dri/card0");
if (GetMgEtcValue ("drm", "device", dev_name, LEN_DEVICE_NAME) < 0) {
strcpy(dev_name, "/dev/dri/card0");
_WRN_PRINTF("No drm.device defined, use default '/dev/dri/card0'\n");
}
device->hidden->dev_name = strdup(dev_name);
#ifdef _MGRM_PROCESSES
// copy to shared resource segment
strcpy (SHAREDRES_VIDEO_DEVICE, device->hidden->dev_name);
}
else {
memcpy(device->hidden->dev_name, SHAREDRES_VIDEO_DEVICE, LEN_DEVICE_NAME);
@@ -1095,7 +1101,6 @@ static GAL_VideoDevice *DRM_CreateDevice(int devindex)
device->hidden->dbl_buff = 1;
}
# if IS_SHAREDFB_SCHEMA_PROCS
SHAREDRES_VIDEO_DBL_BUFF = device->hidden->dbl_buff;
}
else {
device->hidden->dbl_buff = SHAREDRES_VIDEO_DBL_BUFF;
@@ -1126,6 +1131,7 @@ static GAL_VideoDevice *DRM_CreateDevice(int devindex)
}
# endif /* not defined _MGSCHEMA_COMPOSITING */
device->RequestHWSurface = NULL; // always be NULL
device->CopyVideoInfoToSharedRes = DRM_CopyVideoInfoToSharedRes;
#endif /* defined _MGRM_PROCESSES */
device->AllocHWSurface = DRM_AllocHWSurface_Accl;
@@ -1152,6 +1158,7 @@ static GAL_VideoDevice *DRM_CreateDevice(int devindex)
# endif /* not defined _MGSCHEMA_COMPOSITING */
device->RequestHWSurface = NULL; // always be NULL
device->CopyVideoInfoToSharedRes = DRM_CopyVideoInfoToSharedRes;
#endif /* defined _MGRM_PROCESSES */
device->AllocHWSurface = DRM_AllocDumbSurface;
device->FreeHWSurface = DRM_FreeDumbSurface;
@@ -1535,6 +1542,24 @@ static int DRM_Suspend(_THIS)
return ret;
}
#ifdef _MGRM_PROCESSES
static void DRM_CopyVideoInfoToSharedRes(_THIS)
{
DrmVideoData* vdata = this->hidden;
SHAREDRES_VIDEO_DRM_FORMAT =
((DrmSurfaceBuffer*)vdata->real_screen->hwdata)->drm_format;
strncpy (SHAREDRES_VIDEO_EXDRIVER, vdata->ex_driver, LEN_EXDRIVER_NAME);
SHAREDRES_VIDEO_EXDRIVER[LEN_EXDRIVER_NAME] = 0;
strncpy (SHAREDRES_VIDEO_DEVICE, vdata->dev_name, LEN_DEVICE_NAME);
SHAREDRES_VIDEO_EXDRIVER[LEN_DEVICE_NAME] = 0;
SHAREDRES_VIDEO_DBL_BUFF = vdata->dbl_buff;
}
#endif /* _MGRM_PROCESSES */
#if 0 /* deprecated code */
/*
* drm_create_dumb_fb(vdata, width, height, bpp):

View File

@@ -77,7 +77,8 @@ typedef struct GAL_PrivateVideoData {
uint32_t real_name, shadow_name;
#endif /* not defined _MGSCHEMA_COMPOSITING */
char dev_name[LEN_DEVICE_NAME + 1];
char* dev_name;
char* ex_driver;
int dev_fd;
/* capabilities */

View File

@@ -143,6 +143,8 @@ struct GAL_VideoDevice {
GAL_VideoInfo info;
#ifdef _MGRM_PROCESSES
/* Copy video information to shared resource segment */
void (*CopyVideoInfoToSharedRes)(_THIS);
/* Request a surface in video memory */
void (*RequestHWSurface)(_THIS, const REQ_HWSURFACE* request,
REP_HWSURFACE* reply);

View File

@@ -1548,3 +1548,14 @@ int GAL_SuspendVideo(void)
return 0;
}
#ifdef _MGRM_PROCESSES
BOOL GAL_CopyVideoInfoToSharedRes (void)
{
if (__mg_current_video && __mg_current_video->CopyVideoInfoToSharedRes) {
__mg_current_video->CopyVideoInfoToSharedRes(__mg_current_video);
return TRUE;
}
return FALSE;
}
#endif /* _MGRM_PROCESSES */