Tune layout of struct _SharedSurfaceHeader; Change interface of GetWindowSharedSurfaceFD()

This commit is contained in:
Vincent Wei
2023-08-29 12:50:58 +08:00
parent 50aafa3faa
commit 96ecf5e9b7
4 changed files with 31 additions and 20 deletions

View File

@@ -1905,11 +1905,10 @@ MG_EXPORT BOOL GUIAPI LockSharedSurfaceIfDirty (HSURF surf,
/**
* \fn BOOL GUIAPI UnlockSharedSurface (HSURF surf, BOOL clear_dirty)
* \brief Unocks the shared surface and clears the dirty information.
* \brief Unlocks the shared surface and clears the dirty information.
*
* This function compares the dirty age of the shared surface with the value
* containing in \a dirty_age, and lock the shared surface if it has
* a larger dirty age value.
* This function unlocks the shared surface \a surf, and clears its dirty
* information if \a clear_dirty is TRUE.
*
* \param surf The handle to the shared surface.
* \param clear_dirty A boolean value indicates whether to clear the dirty

View File

@@ -7238,7 +7238,8 @@ MG_EXPORT BOOL GUIAPI SetMainWindowGestureFlags (HWND hWnd, DWORD dwFlags);
#ifdef _MGSCHEMA_COMPOSITING
/**
* \fn int GUIAPI GetWindowSharedSurfaceFD (HWND hwnd)
* \fn int GUIAPI GetWindowSharedSurfaceFD (HWND hwnd, size_t *map_size,
* DWORD *flags)
* \brief Gets the file descriptor of the surface buffer for a window or
* the main window it locates.
*
@@ -7258,7 +7259,8 @@ MG_EXPORT BOOL GUIAPI SetMainWindowGestureFlags (HWND hWnd, DWORD dwFlags);
*
* Since 5.0.13
*/
MG_EXPORT int GUIAPI GetWindowSharedSurfaceFD (HWND hWnd);
MG_EXPORT int GUIAPI GetWindowSharedSurfaceFD (HWND hWnd, size_t *map_size,
DWORD *flags);
/**
* \fn BOOL GUIAPI SetMainWindowCompositing (HWND hWnd,

View File

@@ -6067,13 +6067,22 @@ error:
}
#ifdef _MGSCHEMA_COMPOSITING
int GUIAPI GetWindowSharedSurfaceFD (HWND hWnd)
int GUIAPI GetWindowSharedSurfaceFD (HWND hWnd, size_t *map_size, DWORD *flags)
{
MG_CHECK_RET (MG_IS_APP_WINDOW (hWnd), -1);
PMAINWIN pWin = (PMAINWIN)hWnd;
if (pWin->surf->shared_header)
if (pWin->surf->shared_header) {
if (map_size)
*map_size = pWin->surf->shared_header->map_size;
if (flags) {
*flags = MEMDC_FLAG_SWSURFACE;
if (pWin->surf->shared_header->byhw)
*flags |= MEMDC_FLAG_HWSURFACE;
}
return pWin->surf->shared_header->fd;
}
return -1;
}

View File

@@ -139,20 +139,26 @@ typedef struct _DirtyInfo {
* than the creator.
*/
typedef struct _SharedSurfaceHeader {
/* the name of the shared surface; since 5.2.0. */
char name[NAME_MAX + 1];
/* The pid of the creator */
pid_t creator;
/* the size of the whole buffer */
size_t map_size;
/* the offset of pixels data */
off_t pixels_off;
/* The number of semphore for this surface.
The SysV semaphore set id for synchronizing this shared surface:
SHAREDRES_SEMID_SHARED_SURF. */
int sem_num;
/* The pid of the creator */
pid_t creator;
/* The file descriptor in context of the creator. */
int fd;
/* Not zero for hardware surface. */
int byhw;
/* The dirty information */
GAL_DirtyInfo dirty_info;
/* the size of the surface */
int width, height;
/* the pitch of the surface */
@@ -162,13 +168,8 @@ typedef struct _SharedSurfaceHeader {
/* the RGBA masks */
Uint32 Rmask, Gmask, Bmask, Amask;
/* the size of the whole buffer */
size_t map_size;
/* the offset of pixels data */
off_t pixels_off;
/* the name of the shared surface. */
char name[NAME_MAX + 1];
/* The dirty information */
GAL_DirtyInfo dirty_info;
} GAL_SharedSurfaceHeader;
#endif /* IS_COMPOSITING_SCHEMA */