add GDCAP_DPI for GetGDCapability

This commit is contained in:
Vincent Wei
2019-01-10 17:31:50 +08:00
parent 1c2b4a893a
commit b18cd49398
8 changed files with 58 additions and 13 deletions

View File

@@ -11,6 +11,11 @@ Please report any bugs and incompatibilities in
### What's new in this version
* ENHANCEMENTS:
1. Add a new key `dpi` for NEWGAL engine to define the DPI of the screen.
If it is absent, use 96 as the default DPI.
1. Add an item for `GetGDCapability` to return DPI of the DC.
1. New API `InitSlaveScreenEx` to specify the DPI of slave screen.
Define `InitSlaveScreen` as an inline function calling `InitSlaveScreenEx`.
1. New API: `SyncUpdateDC`. You can use this function to synchronize
the update rectangles of a surface to screen, if the surface
represents the shadow frame buffer of the screen.

View File

@@ -28,10 +28,10 @@ mtype=IMPS2
[fbcon]
defaultmode=1024x768-16bpp
[qvfb]
defaultmode=640x480-16bpp
display=0
# The resolution of the display
# It is defined in dots (physical pixels) per inch
# The default value is 96.
dpi=96
#{{ifdef _MGGAL_PCXVFB
[pc_xvfb]

View File

@@ -1138,6 +1138,9 @@ MG_EXPORT BOOL GUIAPI InitPolygonRegion (PCLIPRGN dst,
#define GDCAP_BMASK 10
#define GDCAP_AMASK 11
#define GDCAP_PITCH 12
#define GDCAP_DPI 13
#define GDCAP_DPI_DEFAULT 96
#define GDCAP_DPI_MINIMAL 36
/**
* \fn unsigned int GUIAPI GetGDCapability (HDC hdc, int iItem)
@@ -1181,6 +1184,8 @@ MG_EXPORT BOOL GUIAPI InitPolygonRegion (PCLIPRGN dst,
* Tell \a GetGDCapability to return the pixel alpha color mask for the DC.
* - GDCAP_PITCH\n
* Tell \a GetGDCapability to return the pitch (the bytes of one scan line) of the DC.
* - GDCAP_DPI\n
* Tell \a GetGDCapability to return the DPI (the dots per inch) of the DC.
*
* \return The capbility.
*/
@@ -7635,7 +7640,7 @@ MG_EXPORT BOOL GUIAPI mlsGetSlaveScreenInfo (HDC dc_mls, DWORD mask, int* offset
*
* This function is used to enable or diable a MLShadow slave screen.
* After creating a slave screen by \a InitSlaveScreen successfully, its
* default status is diabled.
* default status is disabled.
*
* \param dc_mls The handle of MLShadow slave screen.
* \param enable Whether to enable the MLShadow slave screen.
@@ -7650,7 +7655,7 @@ MG_EXPORT BOOL GUIAPI mlsEnableSlaveScreen (HDC dc_mls, BOOL enable);
#define ERR_BMP_UNKNOWN_TYPE -2
#define ERR_BMP_CANT_READ -3
#define ERR_BMP_CANT_SAVE -4
#define ERR_BMP_NOT_SUPPORTED -5
#define ERR_BMP_NOT_SUPPORTED -5
#define ERR_BMP_MEM -6
#define ERR_BMP_LOAD -7
#define ERR_BMP_FILEIO -8
@@ -7977,15 +7982,31 @@ MG_EXPORT BOOL GUIAPI InitBitmap (HDC hdc, Uint32 w, Uint32 h, Uint32 pitch,
BYTE* bits, PBITMAP bmp);
/**
* \fn HDC GUIAPI InitSlaveScreen (const char* name, const char* mode)
* \fn HDC GUIAPI InitSlaveScreenEx (const char* name, const char* mode, int dpi)
* \brief Initializes slave screen.
*
*
* \param name The gal engine name.
* \param mode The display mode. For example : 640x480-16bpp.
* \param dpi The resolution of screen, should be a value larger than GDCAP_DPI_MINIMAL (36).
*
* \return Valid handle on success, HDC_INVALID on failure.
*
*/
MG_EXPORT HDC GUIAPI InitSlaveScreen (const char* name, const char* mode);
MG_EXPORT HDC GUIAPI InitSlaveScreenEx (const char* name, const char* mode, int dpi);
/**
* \fn HDC GUIAPI InitSlaveScreen (const char* name, const char* mode)
* \brief Initializes slave screen.
*
* \param name The gal engine name.
* \param mode The display mode. For example : 640x480-16bpp.
*
* \return Valid handle on success, HDC_INVALID on failure.
*/
inline HDC InitSlaveScreen (const char* name, const char* mode)
{
return InitSlaveScreenEx(name, mode, GDCAP_DPI_DEFAULT);
}
/**
* \fn void TerminateSlaveScreen (HDC hdc)

View File

@@ -103,6 +103,7 @@ typedef struct GAL_Surface {
int w, h; /* Read-only */
/* VW[2018-01-18]: For 64b, use signed int instead of Uint32 for pitch. */
int pitch; /* Read-only */
int dpi; /* Read-only */
void *pixels; /* Read-write */
int offset; /* Private */
@@ -191,7 +192,8 @@ extern int GAL_VideoInit (const char *driver_name, Uint32 flags);
extern void GAL_VideoQuit (void);
extern void gal_SlaveVideoQuit (GAL_Surface * surface);
extern GAL_Surface *gal_SlaveVideoInit(const char* driver_name, const char* mode);
extern GAL_Surface *gal_SlaveVideoInit(const char* driver_name,
const char* mode, int dpi);
/* This function fills the given character buffer with the name of the
* video driver, and returns a pointer to it if the video driver has

View File

@@ -147,6 +147,11 @@ int mg_InitGAL (void)
}
#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;
for (i = 0; i < 17; i++) {
SysPixelIndex [i] = GAL_MapRGB (__gal_screen->format,
SysPixelColor [i].r,

View File

@@ -121,6 +121,8 @@ GAL_Surface * GAL_CreateRGBSurface (Uint32 flags,
surface->pitch = GAL_CalculatePitch(surface);
surface->pixels = NULL;
surface->offset = 0;
// for off-screen surface, DPI always be the default value
surface->dpi = GDCAP_DPI_DEFAULT;
surface->hwdata = NULL;
surface->map = NULL;
surface->format_version = 0;

View File

@@ -1283,7 +1283,7 @@ static GAL_Surface * Slave_SetVideoMode (GAL_VideoDevice *device,
return surface;
}
GAL_Surface *gal_SlaveVideoInit(const char* driver_name, const char* mode)
GAL_Surface *gal_SlaveVideoInit(const char* driver_name, const char* mode, int dpi)
{
GAL_Surface* surface;
GAL_VideoDevice *video;
@@ -1326,6 +1326,12 @@ GAL_Surface *gal_SlaveVideoInit(const char* driver_name, const char* mode)
_DBG_PRINTF ("NEWGAL: Set video mode failure.\n");
return NULL;
}
if (dpi < GDCAP_DPI_MINIMAL)
surface->dpi = GDCAP_DPI_MINIMAL;
else
surface->dpi = dpi;
return surface;
}

View File

@@ -402,6 +402,10 @@ unsigned int GUIAPI GetGDCapability (HDC hdc, int iItem)
case GDCAP_MAXY:
iret = RECTH (pdc->DevRC) - 1;
break;
case GDCAP_DPI:
iret = pdc->surface->dpi;
break;
}
UNLOCK(&__mg_gdilock);
@@ -3369,7 +3373,7 @@ void GUIAPI DeleteMemDC (HDC hdc)
free (pmem_dc);
}
HDC GUIAPI InitSlaveScreen (const char* name, const char* mode)
HDC GUIAPI InitSlaveScreenEx (const char* name, const char* mode, int dpi)
{
PDC pmem_dc = NULL;
GAL_Surface* surface = NULL;
@@ -3378,7 +3382,7 @@ HDC GUIAPI InitSlaveScreen (const char* name, const char* mode)
if (!(pmem_dc = malloc (sizeof(DC))))
return HDC_INVALID;
if ((surface = gal_SlaveVideoInit(name, mode))) {
if ((surface = gal_SlaveVideoInit(name, mode, dpi))) {
dc_InitScreenDC (pmem_dc, surface);
return (HDC)pmem_dc;
}