Enhance mg_InitGAL to use GAL engine info from shared resource for MiniGUI-Processes

This commit is contained in:
Vincent Wei
2020-01-07 09:35:51 +08:00
parent 797b4aa83f
commit e4260b79eb
4 changed files with 84 additions and 27 deletions
+1 -1
View File
@@ -757,7 +757,7 @@ extern GAL_Surface* __gal_screen;
#define GAL_BMask(surface) (surface->format->Bmask)
#define GAL_AMask(surface) (surface->format->Amask)
extern int mg_InitGAL (char* engine);
extern int mg_InitGAL (char* engine, char* mode);
/* Since 4.0.0; suspend/resume video device, for switching virtual terminals */
extern int GAL_SuspendVideo(void);
+5 -4
View File
@@ -109,6 +109,7 @@ void kernel_ShowCursorForGDI(BOOL fShow, void* pdc)
int InitGUI (int argc, const char* agr[])
{
char engine [LEN_ENGINE_NAME + 1];
char mode [LEN_VIDEO_MODE + 1];
int step = 1;
__mg_quiting_stage = _MG_QUITING_STAGE_RUNNING;
@@ -136,7 +137,7 @@ int InitGUI (int argc, const char* agr[])
step++;
/* Init GAL engine. */
switch (mg_InitGAL (engine)) {
switch (mg_InitGAL (engine, mode)) {
case ERR_CONFIG_FILE:
err_message (step, "Reading configuration failure!");
return step;
@@ -313,6 +314,7 @@ BOOL IsServer(void)
int InitGUI (int argc, const char* agr[])
{
char engine [LEN_ENGINE_NAME + 1];
char mode [LEN_VIDEO_MODE + 1];
int step = 1;
__mg_quiting_stage = _MG_QUITING_STAGE_RUNNING;
@@ -390,7 +392,7 @@ int InitGUI (int argc, const char* agr[])
#endif
/* Init GAL engine. */
switch (mg_InitGAL (engine)) {
switch (mg_InitGAL (engine, mode)) {
case ERR_CONFIG_FILE:
err_message (step, "Reading configuration failure!");
return step;
@@ -460,8 +462,7 @@ int InitGUI (int argc, const char* agr[])
* Copy the video engine information to the shared resource segement
*/
strncpy (SHAREDRES_VIDEO_ENGINE, engine, LEN_ENGINE_NAME);
if (GetMgEtcValue (engine, "defaultmode", SHAREDRES_VIDEO_MODE, LEN_DEVICE_NAME) < 0)
*SHAREDRES_VIDEO_MODE = 0;
strncpy (SHAREDRES_VIDEO_MODE, mode, LEN_VIDEO_MODE);
if (GetMgEtcValue (engine, "device", SHAREDRES_VIDEO_DEVICE, LEN_DEVICE_NAME) < 0)
*SHAREDRES_VIDEO_DEVICE = 0;
if (GetMgEtcValue (engine, "pixelformat", SHAREDRES_VIDEO_FOURCC, LEN_FOURCC_FORMAT) < 0)
+2 -1
View File
@@ -420,6 +420,7 @@ static BOOL InstallSEGVHandler (void)
int GUIAPI InitGUI (int args, const char *agr[])
{
char engine [LEN_ENGINE_NAME + 1];
char mode [LEN_VIDEO_MODE + 1];
int step = 0;
__mg_quiting_stage = _MG_QUITING_STAGE_RUNNING;
@@ -465,7 +466,7 @@ int GUIAPI InitGUI (int args, const char *agr[])
}
step++;
switch (mg_InitGAL (engine)) {
switch (mg_InitGAL (engine, mode)) {
case ERR_CONFIG_FILE:
fprintf (stderr,
"KERNEL>InitGUI: Reading configuration failure!\n");
+76 -21
View File
@@ -85,19 +85,11 @@ BOOL GAL_ParseVideoMode (const char* mode, int* w, int* h, int* depth)
return TRUE;
}
int mg_InitGAL (char* engine)
static void get_engine_from_etc (char* engine)
{
int i;
int w, h, depth;
char mode [LEN_VIDEO_MODE + 1];
#if defined (WIN32) || !defined(__NOUNIX__)
char* env_value;
#endif
LICENSE_CHECK_CUSTIMER_ID ();
#ifndef __NOUNIX__
if ((env_value = getenv ("MG_GAL_ENGINE"))) {
strncpy (engine, env_value, LEN_ENGINE_NAME);
engine [LEN_ENGINE_NAME] = '\0';
@@ -106,7 +98,7 @@ int mg_InitGAL (char* engine)
#endif
#ifndef _MG_MINIMALGDI
if (GetMgEtcValue ("system", "gal_engine", engine, LEN_ENGINE_NAME) < 0) {
return ERR_CONFIG_FILE;
engine [0] = '\0';
}
#else /* _MG_MINIMALGDI */
# ifdef _MGGAL_PCXVFB
@@ -115,14 +107,13 @@ int mg_InitGAL (char* engine)
strcpy(engine, "dummy");
# endif
#endif /* _MG_MINIMALGDI */
}
if (GAL_VideoInit (engine, 0)) {
GAL_VideoQuit ();
fprintf (stderr, "NEWGAL: Does not find matched engine: %s.\n", engine);
return ERR_NO_MATCH;
}
static void get_mode_from_etc (const char* engine, char* mode)
{
#if defined (WIN32) || !defined(__NOUNIX__)
char* env_value;
if ((env_value = getenv ("MG_DEFAULTMODE"))) {
strncpy (mode, env_value, LEN_VIDEO_MODE);
mode [LEN_VIDEO_MODE] = '\0';
@@ -131,7 +122,65 @@ int mg_InitGAL (char* engine)
#endif
if (GetMgEtcValue (engine, "defaultmode", mode, LEN_VIDEO_MODE) < 0)
if (GetMgEtcValue ("system", "defaultmode", mode, LEN_VIDEO_MODE) < 0)
return ERR_CONFIG_FILE;
mode [0] = '\0';
}
static int get_dpi_from_etc (const char* engine)
{
int dpi;
if (GetMgEtcIntValue (engine, "dpi", &dpi) < 0)
dpi = GDCAP_DPI_DEFAULT;
else if (dpi < GDCAP_DPI_MINIMAL)
dpi = GDCAP_DPI_MINIMAL;
return dpi;
}
int mg_InitGAL (char* engine, char* mode)
{
int i;
int w, h, depth;
LICENSE_CHECK_CUSTIMER_ID ();
#ifdef _MGRM_PROCESSES
if (IsServer()) {
get_engine_from_etc (engine);
}
else {
strncpy (engine, SHAREDRES_VIDEO_ENGINE, LEN_ENGINE_NAME);
engine [LEN_ENGINE_NAME] = '\0';
}
#else
get_engine_from_etc (engine);
#endif /* _MGRM_PROCESSES */
if (engine[0] == 0) {
return ERR_CONFIG_FILE;
}
if (GAL_VideoInit (engine, 0)) {
GAL_VideoQuit ();
fprintf (stderr, "NEWGAL: Does not find matched engine: %s.\n", engine);
return ERR_NO_MATCH;
}
#ifdef _MGRM_PROCESSES
if (IsServer()) {
get_mode_from_etc (engine, mode);
}
else {
strncpy (mode, SHAREDRES_VIDEO_MODE, LEN_VIDEO_MODE);
mode [LEN_VIDEO_MODE] = '\0';
}
#else
get_mode_from_etc (engine, mode);
#endif /* _MGRM_PROCESSES */
if (mode[0] == 0) {
return ERR_CONFIG_FILE;
}
if (!GAL_ParseVideoMode (mode, &w, &h, &depth)) {
GAL_VideoQuit ();
@@ -156,10 +205,16 @@ int mg_InitGAL (char* engine)
}
#endif
if (GetMgEtcIntValue (engine, "dpi", &__gal_screen->dpi) < 0)
__gal_screen->dpi = GDCAP_DPI_DEFAULT;
else if (__gal_screen->dpi < GDCAP_DPI_MINIMAL)
__gal_screen->dpi = GDCAP_DPI_MINIMAL;
#ifdef _MGRM_PROCESSES
if (IsServer()) {
__gal_screen->dpi = get_dpi_from_etc (engine);
}
else {
__gal_screen->dpi = SHAREDRES_VIDEO_DPI;
}
#else
__gal_screen->dpi = get_dpi_from_etc (engine);
#endif /* _MGRM_PROCESSES */
for (i = 0; i < 17; i++) {
SysPixelIndex [i] = GAL_MapRGB (__gal_screen->format,