IS_SHAREDFB_SCHEMA -> IS_SHAREDFB_SCHEMA_PROCS; reflects for the changes of fields name and internal functions

This commit is contained in:
Vincent Wei
2020-03-14 19:03:57 +08:00
parent 4ea138ef19
commit 1bbd5ea4f1
19 changed files with 135 additions and 112 deletions

View File

@@ -172,5 +172,10 @@ tab2space() {
# sed -i 's/\<checkAndGetMainWindowPtrOfMainWin\>/checkAndGetMainWinIfMainWin/g' `grep '\<checkAndGetMainWindowPtrOfMainWin\>' -rl include/ src/` # sed -i 's/\<checkAndGetMainWindowPtrOfMainWin\>/checkAndGetMainWinIfMainWin/g' `grep '\<checkAndGetMainWindowPtrOfMainWin\>' -rl include/ src/`
# sed -i 's/\<checkAndGetMainWindowPtrOfControl\>/checkAndGetMainWinIfWindow/g' `grep '\<checkAndGetMainWindowPtrOfControl\>' -rl include/ src/` # sed -i 's/\<checkAndGetMainWindowPtrOfControl\>/checkAndGetMainWinIfWindow/g' `grep '\<checkAndGetMainWindowPtrOfControl\>' -rl include/ src/`
sed -i 's/\<mg_GetMsgQueueForThisThread\>/getMsgQueueForThisThread/g' `grep '\<mg_GetMsgQueueForThisThread\>' -rl include/ src/` # sed -i 's/\<mg_GetMsgQueueForThisThread\>/getMsgQueueForThisThread/g' `grep '\<mg_GetMsgQueueForThisThread\>' -rl include/ src/`
# sed -i 's/\<IS_SHAREDFB_SCHEMA\>/IS_SHAREDFB_SCHEMA_PROCS/g' `grep '\<IS_SHAREDFB_SCHEMA\>' -rl include/ src/`
sed -i 's/\<REQID_GETWPSURFACE\>/REQID_GETSHAREDSURFACE/g' `grep '\<REQID_GETWPSURFACE\>' -rl include/ src/`
exit 0 exit 0

View File

@@ -192,7 +192,7 @@ int GUIAPI ClientRequestEx2 (const REQUEST* request,
&& (__mg_client_id == 0 && request->id != REQID_JOINLAYER)) { && (__mg_client_id == 0 && request->id != REQID_JOINLAYER)) {
#elif defined(_MGSCHEMA_COMPOSITING) #elif defined(_MGSCHEMA_COMPOSITING)
if (__mg_client_id == 0 && request->id != REQID_JOINLAYER && if (__mg_client_id == 0 && request->id != REQID_JOINLAYER &&
request->id != REQID_GETWPSURFACE) { request->id != REQID_GETSHAREDSURFACE) {
#else #else
if (__mg_client_id == 0 && request->id != REQID_JOINLAYER) { if (__mg_client_id == 0 && request->id != REQID_JOINLAYER) {
#endif #endif

View File

@@ -101,8 +101,8 @@
#define REQID_COPYCURSOR 0x001B #define REQID_COPYCURSOR 0x001B
/* Since 5.0.0 */ /* Since 5.0.0 */
// Get global wallpaper pattern surface // Get shared surface
#define REQID_GETWPSURFACE 0x001C #define REQID_GETSHAREDSURFACE 0x001C
// Load cursor from PNG file // Load cursor from PNG file
#define REQID_LOADCURSOR_PNG 0x001D #define REQID_LOADCURSOR_PNG 0x001D
// Load cursor from in-memory PNG // Load cursor from in-memory PNG
@@ -117,6 +117,9 @@
// Calculate the position a main window with WS_EX_AUTOPOSITION // Calculate the position a main window with WS_EX_AUTOPOSITION
#define REQID_CALCPOSITION 0x0022 #define REQID_CALCPOSITION 0x0022
// Get the shared screen surface for client
#define REQID_CALCPOSITION 0x0022
#define REQID_SYS_LAST REQID_CALCPOSITION #define REQID_SYS_LAST REQID_CALCPOSITION
/* /*
@@ -135,8 +138,9 @@ MGUI_COMPILE_TIME_ASSERT(sys_request_id, MAX_SYS_REQID >= REQID_SYS_LAST);
/* Since 5.0.0 */ /* Since 5.0.0 */
typedef struct _SharedSurfInfo { typedef struct _SharedSurfInfo {
Uint32 flags; Uint32 flags; // the flags of the surface
size_t map_size; uint32_t name; // when use flinked name
size_t map_size; // whole size of the surface
} SHAREDSURFINFO; } SHAREDSURFINFO;
typedef struct JoinLayerInfo { typedef struct JoinLayerInfo {

View File

@@ -62,9 +62,9 @@
#endif #endif
#if defined(_MGRM_PROCESSES) && defined(_MGSCHEMA_SHAREDFB) #if defined(_MGRM_PROCESSES) && defined(_MGSCHEMA_SHAREDFB)
# define IS_SHAREDFB_SCHEMA 1 # define IS_SHAREDFB_SCHEMA_PROCS 1
#else #else
# define IS_SHAREDFB_SCHEMA 0 # define IS_SHAREDFB_SCHEMA_PROCS 0
#endif #endif
/* the maximal number of the dirty rects */ /* the maximal number of the dirty rects */

View File

@@ -357,8 +357,8 @@ static intptr_t cliAllocZOrderNode (PMAINWIN pWin, const COMPOSITINGINFO* ct_inf
assert (pWin->surf && pWin->surf->shared_header); assert (pWin->surf && pWin->surf->shared_header);
info.surf_flags = pWin->surf->flags; info.surf_flags = pWin->surf->flags;
info.surf_size = pWin->surf->shared_header->buf_size; info.surf_size = pWin->surf->shared_header->pixels_size;
info.surf_size += sizeof (*pWin->surf->shared_header); info.surf_size += pWin->surf->shared_header->pixels_off;
if (ct_info) { if (ct_info) {
info.ct = ct_info->type; info.ct = ct_info->type;
@@ -474,8 +474,8 @@ static intptr_t cliMoveWindow (PMAINWIN pWin, const RECT* rcWin, int fd)
#ifdef _MGSCHEMA_COMPOSITING #ifdef _MGSCHEMA_COMPOSITING
info.surf_flags = pWin->surf->flags; info.surf_flags = pWin->surf->flags;
info.surf_size = pWin->surf->shared_header->buf_size; info.surf_size = pWin->surf->shared_header->pixels_size;
info.surf_size += sizeof (*pWin->surf->shared_header); info.surf_size += pWin->surf->shared_header->pixels_off;
#endif #endif
if (ClientRequestEx2 (&req, NULL, 0, fd, if (ClientRequestEx2 (&req, NULL, 0, fd,
@@ -529,8 +529,8 @@ static intptr_t cliStartTrackPopupMenu (PTRACKMENUINFO ptmi)
assert (surf->shared_header); assert (surf->shared_header);
info.surf_flags = surf->flags; info.surf_flags = surf->flags;
info.surf_size = surf->shared_header->buf_size; info.surf_size = surf->shared_header->pixels_size;
info.surf_size += sizeof (*surf->shared_header); info.surf_size += surf->shared_header->pixels_off;
if (ClientRequestEx2 (&req, NULL, 0, surf->shared_header->fd, if (ClientRequestEx2 (&req, NULL, 0, surf->shared_header->fd,
&ret, sizeof (intptr_t), NULL) < 0) &ret, sizeof (intptr_t), NULL) < 0)
return -1; return -1;

View File

@@ -274,7 +274,7 @@ void __kernel_free_z_order_info (ZORDERINFO* zi)
} }
#if 0 /* deprecated code */ #if 0 /* deprecated code */
#if IS_SHAREDFB_SCHEMA #if IS_SHAREDFB_SCHEMA_PROCS
int __kernel_alloc_z_order_info (int nr_topmosts, int nr_normals) int __kernel_alloc_z_order_info (int nr_topmosts, int nr_normals)
{ {
@@ -299,7 +299,7 @@ int __kernel_alloc_z_order_info (int nr_topmosts, int nr_normals)
return zorder_shmid; return zorder_shmid;
} }
#else /* not IS_SHAREDFB_SCHEMA */ #else /* not IS_SHAREDFB_SCHEMA_PROCS */
ZORDERINFO* __kernel_alloc_z_order_info (int nr_topmosts, int nr_normals) ZORDERINFO* __kernel_alloc_z_order_info (int nr_topmosts, int nr_normals)
{ {
@@ -378,14 +378,14 @@ ZORDERINFO* __kernel_alloc_z_order_info (int nr_topmosts, int nr_normals)
return zi; return zi;
} }
#endif /* not IS_SHAREDFB_SCHEMA */ #endif /* not IS_SHAREDFB_SCHEMA_PROCS */
void __kernel_free_z_order_info (ZORDERINFO* zi) void __kernel_free_z_order_info (ZORDERINFO* zi)
{ {
#if IS_SHAREDFB_SCHEMA #if IS_SHAREDFB_SCHEMA_PROCS
if (shmdt (zi) < 0) if (shmdt (zi) < 0)
perror ("Detaches shared zorder nodes"); perror ("Detaches shared zorder nodes");
#else /* not IS_SHAREDFB_SCHEMA */ #else /* not IS_SHAREDFB_SCHEMA_PROCS */
#ifdef _MGRM_THREADS #ifdef _MGRM_THREADS
#ifndef __NOUNIX__ #ifndef __NOUNIX__
@@ -396,7 +396,7 @@ void __kernel_free_z_order_info (ZORDERINFO* zi)
#endif /* _MGRM_THREADS */ #endif /* _MGRM_THREADS */
free (zi); free (zi);
#endif /* not IS_SHAREDFB_SCHEMA */ #endif /* not IS_SHAREDFB_SCHEMA_PROCS */
} }
#endif /* deprecated code */ #endif /* deprecated code */

View File

@@ -117,7 +117,7 @@ GAL_FunctionTable mgGALFuncTable = {
DFB_SetColors, DFB_SetColors,
DFB_UpdateRects, DFB_UpdateRects,
DFB_VideoQuit, DFB_VideoQuit,
#if IS_SHAREDFB_SCHEMA #if IS_SHAREDFB_SCHEMA_PROCS
DFB_RequestHWSurface, DFB_RequestHWSurface,
#endif #endif
DFB_AllocHWSurface, DFB_AllocHWSurface,
@@ -167,7 +167,7 @@ static GAL_VideoDevice *DFB_CreateDevice (int devindex)
device->SetColors = DFB_SetColors; device->SetColors = DFB_SetColors;
device->VideoQuit = DFB_VideoQuit; device->VideoQuit = DFB_VideoQuit;
device->UpdateRects = DFB_UpdateRects; device->UpdateRects = DFB_UpdateRects;
#if IS_SHAREDFB_SCHEMA #if IS_SHAREDFB_SCHEMA_PROCS
device->RequestHWSurface = DFB_RequestHWSurface; device->RequestHWSurface = DFB_RequestHWSurface;
#endif #endif
device->AllocHWSurface = DFB_AllocHWSurface; device->AllocHWSurface = DFB_AllocHWSurface;

View File

@@ -85,6 +85,15 @@ typedef struct GAL_PrivateVideoData {
/* only valid when using DRM driver */ /* only valid when using DRM driver */
uint32_t console_buff_id; uint32_t console_buff_id;
/* Since 5.0.0.
* When double buffering supported, the real surface represents the ultimate
* scan-out frame buffer, and the shadow screen represents the rendering
* surface. When double buffering disabled, both are NULL. */
GAL_Surface *real_screen, *shadow_screen;
/* Since 5.0.0. The current dirty rectangle */
RECT dirty_rc;
} DrmVideoData; } DrmVideoData;
#endif /* _NEWGAL_DRIVIDEO_H */ #endif /* _NEWGAL_DRIVIDEO_H */

View File

@@ -236,7 +236,7 @@ static GAL_VideoDevice *HI3560A_CreateDevice(int devindex)
device->SetVideoMode = HI3560A_SetVideoMode; device->SetVideoMode = HI3560A_SetVideoMode;
device->SetColors = HI3560A_SetColors; device->SetColors = HI3560A_SetColors;
device->VideoQuit = HI3560A_VideoQuit; device->VideoQuit = HI3560A_VideoQuit;
#if IS_SHAREDFB_SCHEMA #if IS_SHAREDFB_SCHEMA_PROCS
device->RequestHWSurface = HI3560A_RequestHWSurface; device->RequestHWSurface = HI3560A_RequestHWSurface;
#endif #endif
device->AllocHWSurface = HI3560A_AllocHWSurface; device->AllocHWSurface = HI3560A_AllocHWSurface;

View File

@@ -1851,7 +1851,7 @@ static GAL_VideoDevice *HI3510_CreateDevice (int devindex)
this->SetVideoMode = HI3510_SetVideoMode; this->SetVideoMode = HI3510_SetVideoMode;
//this->SetColors = FB_SetColors; //this->SetColors = FB_SetColors;
this->VideoQuit = HI3510_VideoQuit; this->VideoQuit = HI3510_VideoQuit;
#if IS_SHAREDFB_SCHEMA #if IS_SHAREDFB_SCHEMA_PROCS
this->RequestHWSurface = HI3510_RequestHWSurface; this->RequestHWSurface = HI3510_RequestHWSurface;
#endif #endif
this->AllocHWSurface = HI3510_AllocHWSurface; this->AllocHWSurface = HI3510_AllocHWSurface;

View File

@@ -1843,7 +1843,7 @@ static GAL_VideoDevice *HI3560_CreateDevice (int devindex)
this->ListModes = HI3560_ListModes; this->ListModes = HI3560_ListModes;
this->SetVideoMode = HI3560_SetVideoMode; this->SetVideoMode = HI3560_SetVideoMode;
this->VideoQuit = HI3560_VideoQuit; this->VideoQuit = HI3560_VideoQuit;
#if IS_SHAREDFB_SCHEMA #if IS_SHAREDFB_SCHEMA_PROCS
this->RequestHWSurface = HI3560_RequestHWSurface; this->RequestHWSurface = HI3560_RequestHWSurface;
#endif #endif
this->AllocHWSurface = HI3560_AllocHWSurface; this->AllocHWSurface = HI3560_AllocHWSurface;

View File

@@ -230,18 +230,19 @@ static GAL_Surface* create_wp_surface(GAL_Surface* screen)
} }
else { else {
REQUEST req; REQUEST req;
GHANDLE handle = 0; // for wallpaper pattern, handle always be zero.
int fd = -1; int fd = -1;
SHAREDSURFINFO info; SHAREDSURFINFO info;
req.id = REQID_GETWPSURFACE; req.id = REQID_GETSHAREDSURFACE;
req.data = &fd; req.data = &handle;
req.len_data = sizeof(int); req.len_data = sizeof(GHANDLE);
if ((ClientRequestEx2 (&req, NULL, 0, -1, if ((ClientRequestEx2 (&req, NULL, 0, -1,
&info, sizeof (SHAREDSURFINFO), &fd) < 0) || (fd < 0)) &info, sizeof (SHAREDSURFINFO), &fd) < 0) || (fd < 0))
goto empty; goto empty;
_DBG_PRINTF ("REQID_GETWPSURFACE: map_size (%lu), flags (0x%x), fd: %d\n", _DBG_PRINTF ("REQID_GETSHAREDSURFACE: map_size (%lu), flags (0x%x), fd: %d\n",
info.map_size, info.flags, fd); info.map_size, info.flags, fd);
wp_surf = GAL_AttachSharedRGBSurface (fd, info.map_size, wp_surf = GAL_AttachSharedRGBSurface (fd, info.map_size,
info.flags, TRUE); info.flags, TRUE);

View File

@@ -190,7 +190,7 @@ static GAL_VideoDevice *S3C6410_CreateDevice(int devindex)
device->SetVideoMode = S3C6410_SetVideoMode; device->SetVideoMode = S3C6410_SetVideoMode;
device->SetColors = S3C6410_SetColors; device->SetColors = S3C6410_SetColors;
device->VideoQuit = S3C6410_VideoQuit; device->VideoQuit = S3C6410_VideoQuit;
#if IS_SHAREDFB_SCHEMA #if IS_SHAREDFB_SCHEMA_PROCS
device->RequestHWSurface = S3C6410_RequestHWSurface; device->RequestHWSurface = S3C6410_RequestHWSurface;
#endif #endif
device->AllocHWSurface = S3C6410_AllocHWSurface; device->AllocHWSurface = S3C6410_AllocHWSurface;

View File

@@ -847,7 +847,7 @@ static GAL_VideoDevice *STGFB_CreateDevice (int devindex)
this->SetColors = STGFB_SetColors; this->SetColors = STGFB_SetColors;
this->VideoQuit = STGFB_VideoQuit; this->VideoQuit = STGFB_VideoQuit;
this->UpdateRects = STGFB_UpdateRects; this->UpdateRects = STGFB_UpdateRects;
#if IS_SHAREDFB_SCHEMA #if IS_SHAREDFB_SCHEMA_PROCS
this->RequestHWSurface = STGFB_RequestHWSurface; this->RequestHWSurface = STGFB_RequestHWSurface;
#endif #endif
this->AllocHWSurface = STGFB_AllocHWSurface; this->AllocHWSurface = STGFB_AllocHWSurface;

View File

@@ -148,8 +148,8 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video,
/* Get the pixels */ /* Get the pixels */
{ {
int fd = -1; int fd = -1;
size_t buf_size; size_t pixels_size;
off_t buf_off; off_t pixels_off;
off_t map_size; off_t map_size;
void* data_map; void* data_map;
GAL_SharedSurfaceHeader* hdr; GAL_SharedSurfaceHeader* hdr;
@@ -158,20 +158,20 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video,
if ((flags & GAL_HWSURFACE) == GAL_HWSURFACE && if ((flags & GAL_HWSURFACE) == GAL_HWSURFACE &&
video->AllocSharedHWSurface) { video->AllocSharedHWSurface) {
fd = video->AllocSharedHWSurface (video, surface, fd = video->AllocSharedHWSurface (video, surface,
&buf_size, &buf_off, rw_modes); &pixels_size, &pixels_off, rw_modes);
} }
if (fd < 0) { // fallback to use software surface if (fd < 0) { // fallback to use software surface
off_t file_size; off_t file_size;
byhw = 0; byhw = 0;
buf_size = (surface->h * surface->pitch); pixels_size = (surface->h * surface->pitch);
buf_off = sizeof (GAL_SharedSurfaceHeader); pixels_off = sizeof (GAL_SharedSurfaceHeader);
/* rounde file size to multiple of page size */ /* rounde file size to multiple of page size */
file_size = buf_off + buf_size; file_size = pixels_off + pixels_size;
file_size = ROUND_TO_MULTIPLE(file_size, getpagesize ()); file_size = ROUND_TO_MULTIPLE(file_size, getpagesize ());
buf_size = file_size - buf_off; pixels_size = file_size - pixels_off;
_DBG_PRINTF("shared surface: size (%d x %d), pitch (%d), file_size (%lu)\n", _DBG_PRINTF("shared surface: size (%d x %d), pitch (%d), file_size (%lu)\n",
surface->w, surface->h, surface->pitch, file_size); surface->w, surface->h, surface->pitch, file_size);
@@ -184,7 +184,7 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video,
surface->video = NULL; surface->video = NULL;
} }
map_size = buf_off + buf_size; map_size = pixels_off + pixels_size;
data_map = mmap (NULL, map_size, PROT_READ | PROT_WRITE, data_map = mmap (NULL, map_size, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, 0); MAP_SHARED, fd, 0);
if (data_map == MAP_FAILED) { if (data_map == MAP_FAILED) {
@@ -207,7 +207,8 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video,
hdr->Gmask = Gmask; hdr->Gmask = Gmask;
hdr->Bmask = Bmask; hdr->Bmask = Bmask;
hdr->Amask = Amask; hdr->Amask = Amask;
hdr->buf_size = buf_size; hdr->pixels_size= pixels_size;
hdr->pixels_off = pixels_off;
surface->dirty_info = &hdr->dirty_info; surface->dirty_info = &hdr->dirty_info;
surface->dirty_info->dirty_age = 0; surface->dirty_info->dirty_age = 0;
@@ -226,19 +227,7 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video,
} }
} }
#if 0 surface->pixels = (uint8_t*)surface->shared_header + pixels_off;
/* Use a unnamed POSIX semaphore shared between processes */
if (sem_init (&hdr->sem_lock, 1, 1) < 0) {
if (errno == ENOSYS) {
_ERR_PRINTF("The system does not support process-shared semaphore.\n");
}
goto error;
}
BOOL sem_inited = TRUE;
#endif
surface->pixels = surface->shared_header->buf;
// memset (surface->pixels, 0, buf_size);
if (byhw) if (byhw)
surface->flags |= GAL_HWSURFACE; surface->flags |= GAL_HWSURFACE;
@@ -277,7 +266,7 @@ error:
else { else {
close (surface->shared_header->fd); close (surface->shared_header->fd);
munmap (surface->shared_header, munmap (surface->shared_header,
surface->shared_header->buf_size surface->shared_header->pixels_size
+ sizeof(GAL_SharedSurfaceHeader)); + sizeof(GAL_SharedSurfaceHeader));
} }
@@ -310,19 +299,20 @@ void GAL_FreeSharedSurfaceData (GAL_Surface *surface)
__mg_free_sem_for_shared_surf (surface->shared_header->sem_num); __mg_free_sem_for_shared_surf (surface->shared_header->sem_num);
} }
// the file descriptor may have been closed.
if (surface->shared_header->fd >= 0) {
close (surface->shared_header->fd);
surface->shared_header->fd;
}
munmap (surface->shared_header,
surface->shared_header->pixels_size
+ surface->shared_header->pixels_off);
if (surface->shared_header->byhw) { if (surface->shared_header->byhw) {
assert (video->FreeSharedHWSurface); assert (video->FreeSharedHWSurface);
video->FreeSharedHWSurface (video, surface); video->FreeSharedHWSurface (video, surface);
surface->hwdata = NULL; surface->hwdata = NULL;
} }
else {
// the file descriptor may have been closed.
if (surface->shared_header->fd >= 0)
close (surface->shared_header->fd);
munmap (surface->shared_header,
surface->shared_header->buf_size
+ sizeof (GAL_SharedSurfaceHeader));
}
surface->pixels = NULL; surface->pixels = NULL;
surface->shared_header = NULL; surface->shared_header = NULL;
@@ -368,6 +358,7 @@ GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size,
surface->flags = flags; surface->flags = flags;
surface->shared_header = NULL; surface->shared_header = NULL;
surface->hwdata = NULL;
if (video && video->AttachSharedHWSurface) { if (video && video->AttachSharedHWSurface) {
// this method should fill hwdata and shared_header fields if success // this method should fill hwdata and shared_header fields if success
video->AttachSharedHWSurface (video, surface, fd, map_size, with_wr); video->AttachSharedHWSurface (video, surface, fd, map_size, with_wr);
@@ -384,7 +375,7 @@ GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size,
data_map = mmap (NULL, map_size, prot, MAP_SHARED, fd, 0); data_map = mmap (NULL, map_size, prot, MAP_SHARED, fd, 0);
if (data_map == MAP_FAILED) { if (data_map == MAP_FAILED) {
_ERR_PRINTF("NEWGAL: Failed to map shared RGB surface: %d\n", fd); _ERR_PRINTF("NEWGAL: Failed to map shared RGB surface: %d\n", fd);
return NULL; goto error;
} }
surface->hwdata = NULL; surface->hwdata = NULL;
@@ -395,8 +386,13 @@ GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size,
/* map successfully */ /* map successfully */
hdr = surface->shared_header; hdr = surface->shared_header;
if (surface->hwdata)
surface->flags |= GAL_HWSURFACE;
else
surface->flags &= ~GAL_HWSURFACE;
surface->dirty_info = &hdr->dirty_info; surface->dirty_info = &hdr->dirty_info;
surface->pixels = hdr->buf; surface->pixels = (uint8_t*)hdr + hdr->pixels_off;
surface->format = GAL_AllocFormat (hdr->depth, surface->format = GAL_AllocFormat (hdr->depth,
hdr->Rmask, hdr->Gmask, hdr->Bmask, hdr->Amask); hdr->Rmask, hdr->Gmask, hdr->Bmask, hdr->Amask);
if (surface->format == NULL) { if (surface->format == NULL) {
@@ -405,7 +401,7 @@ GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size,
surface->w = hdr->width; surface->w = hdr->width;
surface->h = hdr->height; surface->h = hdr->height;
surface->pitch = GAL_CalculatePitch (surface); surface->pitch = hdr->pitch;
surface->offset = 0; surface->offset = 0;
// for off-screen surface, DPI always be the default value // for off-screen surface, DPI always be the default value
surface->dpi = GDCAP_DPI_DEFAULT; surface->dpi = GDCAP_DPI_DEFAULT;
@@ -429,12 +425,12 @@ GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size,
return (surface); return (surface);
error: error:
if (data_map != MAP_FAILED) { if (video && surface->hwdata) {
if (video && video->DettachSharedHWSurface) { assert (video->DettachSharedHWSurface);
video->DettachSharedHWSurface (video, surface); video->DettachSharedHWSurface (video, surface);
} }
else else if (data_map != MAP_FAILED) {
munmap (data_map, map_size); munmap (data_map, map_size);
} }
if (surface) if (surface)
@@ -453,14 +449,17 @@ void GAL_DettachSharedSurfaceData (GAL_Surface *surface)
assert (surface->shared_header); assert (surface->shared_header);
if (video && video->DettachSharedHWSurface) { if (video && surface->hwdata) {
assert (video->DettachSharedHWSurface);
video->DettachSharedHWSurface (video, surface); video->DettachSharedHWSurface (video, surface);
surface->hwdata = NULL; surface->hwdata = NULL;
} }
else {
munmap (surface->shared_header,
surface->shared_header->pixels_size
+ surface->shared_header->pixels_off);
}
munmap (surface->shared_header,
surface->shared_header->buf_size
+ sizeof (GAL_SharedSurfaceHeader));
surface->pixels = NULL; surface->pixels = NULL;
surface->shared_header = NULL; surface->shared_header = NULL;
surface->dirty_info = NULL; surface->dirty_info = NULL;

View File

@@ -1760,7 +1760,7 @@ void GAL_FreeSurface (GAL_Surface *surface)
#endif #endif
} }
#if IS_SHAREDFB_SCHEMA #if IS_SHAREDFB_SCHEMA_PROCS
void GAL_RequestHWSurface (const REQ_HWSURFACE* request, REP_HWSURFACE* reply) void GAL_RequestHWSurface (const REQ_HWSURFACE* request, REP_HWSURFACE* reply)
{ {
if (__mg_current_video->RequestHWSurface) { if (__mg_current_video->RequestHWSurface) {

View File

@@ -156,7 +156,7 @@ struct GAL_VideoDevice {
Set to NULL if no hardware shared surface supported. Set to NULL if no hardware shared surface supported.
Return the PRIME file descriptor if success, otherwize -1. */ Return the PRIME file descriptor if success, otherwize -1. */
int (*AllocSharedHWSurface)(_THIS, GAL_Surface *surface, int (*AllocSharedHWSurface)(_THIS, GAL_Surface *surface,
size_t* buf_size, off_t* buf_off, Uint32 rw_modes); size_t* pixels_size, off_t* pixels_off, Uint32 rw_modes);
/* Free a shared surface in hardware video memory. /* Free a shared surface in hardware video memory.
Set to NULL if no hardware shared surface supported. Set to NULL if no hardware shared surface supported.
@@ -167,7 +167,7 @@ struct GAL_VideoDevice {
Set to NULL if no hardware shared surface supported. Set to NULL if no hardware shared surface supported.
Return 0 if success, otherwize -1. */ Return 0 if success, otherwize -1. */
int (*AttachSharedHWSurface)(_THIS, GAL_Surface *surface, int (*AttachSharedHWSurface)(_THIS, GAL_Surface *surface,
int fd, size_t mapsize, BOOL with_rw); int prime_fd, size_t mapsize, BOOL with_rw);
/* Dettach from a shared surface in hardware video memory. /* Dettach from a shared surface in hardware video memory.
Set to NULL if no hardware shared surface supported. Set to NULL if no hardware shared surface supported.
@@ -182,7 +182,7 @@ struct GAL_VideoDevice {
/* Free a dumb surface allocated from hardware. /* Free a dumb surface allocated from hardware.
Set to NULL if dumb surface is not supported. Set to NULL if dumb surface is not supported.
Return 0 if success, otherwise -1. */ Return 0 if success, otherwise -1. */
int (*FreeDumbSurface)(_THIS, GAL_Surface *surface); void (*FreeDumbSurface)(_THIS, GAL_Surface *surface);
/* Set hardware cursor. /* Set hardware cursor.
Set to NULL or return -1 if no hardware cursor support. */ Set to NULL or return -1 if no hardware cursor support. */

View File

@@ -4080,9 +4080,6 @@ GHANDLE GetVideoHandle (HDC hdc)
#ifdef _MGGAL_DRM #ifdef _MGGAL_DRM
/* implemented in DRI engine. */
BOOL __drm_get_surface_info (GAL_Surface *surface, DrmSurfaceInfo* info);
BOOL drmGetSurfaceInfo (GHANDLE video, HDC hdc, DrmSurfaceInfo* info) BOOL drmGetSurfaceInfo (GHANDLE video, HDC hdc, DrmSurfaceInfo* info)
{ {
PDC pdc = dc_HDC2PDC (hdc); PDC pdc = dc_HDC2PDC (hdc);
@@ -4092,14 +4089,8 @@ BOOL drmGetSurfaceInfo (GHANDLE video, HDC hdc, DrmSurfaceInfo* info)
return __drm_get_surface_info(pdc->surface, info); return __drm_get_surface_info(pdc->surface, info);
} }
/* implemented in DRI engine. */ HDC drmCreateDCFromName (GHANDLE video, uint32_t name, uint32_t drm_format,
GAL_Surface* __drm_create_surface_from_name (GHANDLE video, unsigned int width, unsigned int height, uint32_t pitch)
uint32_t name, uint32_t drm_format,
unsigned int width, unsigned int height, uint32_t pitch);
HDC drmCreateDCFromName (GHANDLE video,
uint32_t name, uint32_t drm_format,
unsigned int width, unsigned int height, uint32_t pitch)
{ {
PDC pmem_dc = NULL; PDC pmem_dc = NULL;
GAL_Surface* surface; GAL_Surface* surface;
@@ -4109,7 +4100,8 @@ HDC drmCreateDCFromName (GHANDLE video,
LOCK (&__mg_gdilock); LOCK (&__mg_gdilock);
surface = __drm_create_surface_from_name (video, name, surface = __drm_create_surface_from_name (video, name,
drm_format, width, height, pitch); drm_format, sizeof (GAL_SharedSurfaceHeader),
width, height, pitch);
UNLOCK (&__mg_gdilock); UNLOCK (&__mg_gdilock);
if (!surface) { if (!surface) {
@@ -4147,11 +4139,6 @@ HDC drmCreateDCFromName (GHANDLE video,
return (HDC)pmem_dc; return (HDC)pmem_dc;
} }
/* implemented in DRI engine. */
GAL_Surface* __drm_create_surface_from_handle (GHANDLE video,
uint32_t handle, unsigned long size, uint32_t drm_format,
unsigned int width, unsigned int height, uint32_t pitch);
HDC drmCreateDCFromHandle (GHANDLE video, HDC drmCreateDCFromHandle (GHANDLE video,
uint32_t handle, unsigned long size, uint32_t drm_format, uint32_t handle, unsigned long size, uint32_t drm_format,
unsigned int width, unsigned int height, uint32_t pitch) unsigned int width, unsigned int height, uint32_t pitch)
@@ -4164,7 +4151,7 @@ HDC drmCreateDCFromHandle (GHANDLE video,
LOCK (&__mg_gdilock); LOCK (&__mg_gdilock);
surface = __drm_create_surface_from_handle (video, handle, size, surface = __drm_create_surface_from_handle (video, handle, size,
drm_format, width, height, pitch); drm_format, 0, width, height, pitch);
UNLOCK (&__mg_gdilock); UNLOCK (&__mg_gdilock);
if (!surface) { if (!surface) {
@@ -4202,11 +4189,6 @@ HDC drmCreateDCFromHandle (GHANDLE video,
return (HDC)pmem_dc; return (HDC)pmem_dc;
} }
/* implemented in DRI engine. */
GAL_Surface* __drm_create_surface_from_prime_fd (GHANDLE video,
int prime_fd, unsigned long size, uint32_t drm_format,
unsigned int width, unsigned int height, uint32_t pitch);
HDC drmCreateDCFromPrimeFd (GHANDLE video, HDC drmCreateDCFromPrimeFd (GHANDLE video,
int prime_fd, unsigned long size, uint32_t drm_format, int prime_fd, unsigned long size, uint32_t drm_format,
unsigned int width, unsigned int height, uint32_t pitch) unsigned int width, unsigned int height, uint32_t pitch)
@@ -4219,7 +4201,8 @@ HDC drmCreateDCFromPrimeFd (GHANDLE video,
LOCK (&__mg_gdilock); LOCK (&__mg_gdilock);
surface =__drm_create_surface_from_prime_fd (video, prime_fd, size, surface =__drm_create_surface_from_prime_fd (video, prime_fd, size,
drm_format, width, height, pitch); drm_format, sizeof (GAL_SharedSurfaceHeader),
width, height, pitch);
UNLOCK (&__mg_gdilock); UNLOCK (&__mg_gdilock);
if (!surface) { if (!surface) {

View File

@@ -727,7 +727,7 @@ static int handle_mlshadow_req (int cli, int clifd, void* buff, size_t len)
} }
#endif #endif
#if IS_SHAREDFB_SCHEMA #if IS_SHAREDFB_SCHEMA_PROCS
void release_hw_surface (REQ_HWSURFACE* allocated) void release_hw_surface (REQ_HWSURFACE* allocated)
{ {
/*[humingming./2010/11/24]: don't call GAL_RequestHWSurface, /*[humingming./2010/11/24]: don't call GAL_RequestHWSurface,
@@ -768,23 +768,28 @@ static int req_hw_surface (int cli, int clifd, void* buff, size_t len)
return ServerSendReply (clifd, &reply, sizeof (REP_HWSURFACE)); return ServerSendReply (clifd, &reply, sizeof (REP_HWSURFACE));
} }
#endif /* IS_SHAREDFB_SCHEMA */ #endif /* IS_SHAREDFB_SCHEMA_PROCS */
#ifdef _MGHAVE_CLIPBOARD #ifdef _MGHAVE_CLIPBOARD
extern int __mg_clipboard_op (int cli, int clifd, void* buff, size_t len); extern int __mg_clipboard_op (int cli, int clifd, void* buff, size_t len);
#endif #endif
#if IS_COMPOSITING_SCHEMA #if IS_COMPOSITING_SCHEMA
static int get_wp_surface (int cli, int clifd, void* buff, size_t len) /* get the fake screen surface (wallpaper pattern surface) */
static int get_shared_surface (int cli, int clifd, void* buff, size_t len)
{ {
GHANDLE *handle;
SHAREDSURFINFO info; SHAREDSURFINFO info;
handle = buff;
assert (__gal_fake_screen); assert (__gal_fake_screen);
assert (*handle == 0);
info.flags = __gal_fake_screen->flags; info.flags = __gal_fake_screen->flags;
if (__gal_fake_screen->shared_header) { if (__gal_fake_screen->shared_header) {
info.map_size = sizeof (GAL_SharedSurfaceHeader); info.map_size = __gal_fake_screen->shared_header->pixels_size;
info.map_size += __gal_fake_screen->shared_header->buf_size; info.map_size += __gal_fake_screen->shared_header->pixels_off;
return ServerSendReplyEx (clifd, &info, sizeof (SHAREDSURFINFO), return ServerSendReplyEx (clifd, &info, sizeof (SHAREDSURFINFO),
__gal_fake_screen->shared_header->fd); __gal_fake_screen->shared_header->fd);
@@ -794,7 +799,24 @@ static int get_wp_surface (int cli, int clifd, void* buff, size_t len)
return ServerSendReplyEx (clifd, &info, sizeof (SHAREDSURFINFO), -1); return ServerSendReplyEx (clifd, &info, sizeof (SHAREDSURFINFO), -1);
} }
} }
#endif /* IS_COMPOSITING_SCHEMA */ #else /* IS_COMPOSITING_SCHEMA */
/* get the rendering surface */
static int get_shared_surface (int cli, int clifd, void* buff, size_t len)
{
int fd = -1;
GHANDLE *handle;
SHAREDSURFINFO info = { 0, 0 };
#ifdef _MGGAL_DRM
handle = buff;
extern int __drm_get_shared_screen_surface (GHANDLE, SHAREDSURFINFO*);
fd = __drm_get_shared_screen_surface (*handle, &info);
#endif
return ServerSendReplyEx (clifd, &info, sizeof (SHAREDSURFINFO), fd);
}
#endif /* not IS_COMPOSITING_SCHEMA */
static struct req_request { static struct req_request {
void* handler; void* handler;
@@ -819,7 +841,7 @@ static struct req_request {
{ set_ime_stat, 0 }, { set_ime_stat, 0 },
{ get_ime_stat, 0 }, { get_ime_stat, 0 },
{ register_hook, 0 }, { register_hook, 0 },
#if IS_SHAREDFB_SCHEMA #if IS_SHAREDFB_SCHEMA_PROCS
{ req_hw_surface, 0 }, { req_hw_surface, 0 },
#else #else
{ NULL, 0 }, { NULL, 0 },
@@ -849,13 +871,13 @@ static struct req_request {
{ set_ime_targetinfo, 0 }, { set_ime_targetinfo, 0 },
{ copy_cursor, 0 }, { copy_cursor, 0 },
#if IS_COMPOSITING_SCHEMA #if IS_COMPOSITING_SCHEMA
{ get_wp_surface, 0 }, { get_shared_surface, 0 },
{ load_cursor_png_file, 0 }, { load_cursor_png_file, 0 },
{ load_cursor_png_mem, 0 }, { load_cursor_png_mem, 0 },
{ alloc_sem_for_shared_surf, 0 }, { alloc_sem_for_shared_surf, 0 },
{ free_sem_for_shared_surf, 0 }, { free_sem_for_shared_surf, 0 },
#else #else
{ NULL, 0 }, { get_shared_surface, 0 },
{ NULL, 0 }, { NULL, 0 },
{ NULL, 0 }, { NULL, 0 },
{ NULL, 0 }, { NULL, 0 },