diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index f6ae912a..ed202472 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,5 +1,7 @@ # Release Notes +- [Version 5.2.0](#version-520) + + [What's new in version 5.2.0](#whats-new-in-version-520) - [Version 5.0.13](#version-5013) + [What's new in version 5.0.13](#whats-new-in-version-5013) - [Version 5.0.12](#version-5012) @@ -32,6 +34,17 @@ + [Changes leading to incompatibility](#changes-leading-to-incompatibility) + [Deprecated APIs](#deprecated-apis) +## Version 5.2.0 + +On Nov. 30, 2023, FMSoft announces the availability of MiniGUI 5.2.0, +which is an mainline release with some major enhancements: + +* ENHANCEMENTS: + - Optimize NEWGAL engines: `shadow`, `drm`, and `fbcon` for large resolution. + - New APIs: `GetWindowSurfaceBufferFD()` and `CreateMemDCFromSurfaceBufferFD()` for compositing schema. +* CHANGES: + - The operations for DRM userland driver changed. + ## Version 5.0.13 On Aug. 31, 2023, FMSoft announces the availability of MiniGUI 5.0.13, diff --git a/include/gdi.h b/include/gdi.h index d69e85ff..35f78d81 100644 --- a/include/gdi.h +++ b/include/gdi.h @@ -1704,6 +1704,27 @@ MG_EXPORT BOOL GUIAPI IsScreenDC (HDC hdc); */ MG_EXPORT BOOL GUIAPI IsWindowDC (HDC hdc); +#ifdef _MGSCHEMA_COMPOSITING +/** + * \fn HDC GUIAPI CreateMemDCFromSurfaceBufferFD (int fd); + * \brief Creates a memory DC from a file descriptor of a surface buffer. + * + * This function creates a memory DC from the specified file descriptor \a fd, + * which represents a surface buffer. + * + * \param fd The file descriptor which represents a surface buffer. + * + * \return The handle to a new memory DC, HDC_INVALID indicates an error. + * + * \note This function only available when _MGSCHEMA_COMPOSITING is defined. + * + * \sa GetWindowSurfaceBufferFD + * + * Since 5.0.13 + */ +MG_EXPORT HDC GUIAPI CreateMemDCFromSurfaceBufferFD (int fd); +#endif /* _MGSCHEMA_COMPOSITING */ + /** * \fn HDC GUIAPI CreateMemDCEx (int width, int height, int depth, DWORD flags, \ Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask, diff --git a/include/window.h b/include/window.h index 6220926c..4651a4f1 100644 --- a/include/window.h +++ b/include/window.h @@ -7237,6 +7237,29 @@ MG_EXPORT BOOL GUIAPI SetMainWindowGestureFlags (HWND hWnd, DWORD dwFlags); #ifdef _MGSCHEMA_COMPOSITING +/** + * \fn int GUIAPI GetWindowSurfaceBufferFD (HWND hwnd) + * \brief Gets the file descriptor of the surface buffer for a window or + * the main window it locates. + * + * This function gets the file descriptor of the surface buffer for + * the specified window if it is a main window or the main window it locates. + * Note that if the window is a control that has the style `WS_EX_CTRLASMAINWIN`, + * the window will have a separate surface buffer. + * + * \param hwnd The handle to the window. + * + * \return An integer larger than or equal to 0 for a valid file descriptor, + * otherwise a negative value. + * + * \note This function only available when _MGSCHEMA_COMPOSITING is defined. + * + * \sa CreateMemDCFromSurfaceBufferFD + * + * Since 5.0.13 + */ +MG_EXPORT int GUIAPI GetWindowSurfaceBufferFD (HWND hWnd); + /** * \fn BOOL GUIAPI SetMainWindowCompositing (HWND hWnd, int type, DWORD arg) diff --git a/src/gui/window.c b/src/gui/window.c index b594b16a..24a4c45a 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -6066,6 +6066,19 @@ error: return HWND_INVALID; } +#ifdef _MGSCHEMA_COMPOSITING +int GUIAPI GetWindowSurfaceBufferFD (HWND hWnd) +{ + MG_CHECK_RET (MG_IS_APP_WINDOW (hWnd), -1); + + PMAINWIN pWin = (PMAINWIN)hWnd; + if (pWin->surf->shared_header) + return pWin->surf->shared_header->fd; + + return -1; +} +#endif /* _MGSCHEMA_COMPOSITING */ + BOOL GUIAPI DestroyWindow (HWND hWnd) { PCONTROL pCtrl; diff --git a/src/newgdi/gdi.c b/src/newgdi/gdi.c index b2f056a2..44dd90d5 100644 --- a/src/newgdi/gdi.c +++ b/src/newgdi/gdi.c @@ -3391,6 +3391,29 @@ struct GAL_Surface* GetSurfaceFromDC (HDC hdc) return pdc->surface; } +#ifdef _MGSCHEMA_COMPOSITING +HDC GUIAPI CreateMemDCFromSurfaceBufferFD (int fd) +{ + HDC memdc = HDC_INVALID; + GAL_Surface* surf; + + surf = GAL_AttachSharedRGBSurface (fd, 0, GAL_HWSURFACE, TRUE); + if (surf) { + memdc = CreateMemDCFromSurface (surf); + if (memdc == HDC_INVALID) { + GAL_FreeSurface(surf); + + _ERR_PRINTF("failed to create memory dc from surface: %p\n", surf); + } + } + else { + _ERR_PRINTF("failed to attach to surface buffer via fd: %d\n", fd); + } + + return memdc; +} +#endif /* _MGSCHEMA_COMPOSITING */ + HDC GUIAPI CreateSubMemDC (HDC parent, int off_x, int off_y, int width, int height, BOOL comp_to_parent) {