From 1bbd5ea4f10d74463918ac5d9a067b71dcaa21d9 Mon Sep 17 00:00:00 2001 From: Vincent Wei Date: Sat, 14 Mar 2020 19:03:57 +0800 Subject: [PATCH] IS_SHAREDFB_SCHEMA -> IS_SHAREDFB_SCHEMA_PROCS; reflects for the changes of fields name and internal functions --- cleanup-code.sh | 7 ++- src/client/client.c | 2 +- src/include/client.h | 12 +++-- src/include/constants.h | 4 +- src/kernel/desktop-procs.c | 12 ++--- src/kernel/zorder.c | 12 ++--- src/newgal/dfb/dfbvideo.c | 4 +- src/newgal/drm/drmvideo.h | 9 ++++ src/newgal/hisi/gal_hi3560a.c | 2 +- src/newgal/hisi/hi3510_fbvideo.c | 2 +- src/newgal/hisi/hi3560_fbvideo.c | 2 +- src/newgal/newgal.c | 9 ++-- src/newgal/s3c6410/gal-s3c6410.c | 2 +- src/newgal/stgfb/stgfb_video.c | 2 +- src/newgal/surface-shared.c | 87 ++++++++++++++++---------------- src/newgal/surface.c | 2 +- src/newgal/sysvideo.h | 6 +-- src/newgdi/gdi.c | 31 +++--------- src/server/request.c | 40 +++++++++++---- 19 files changed, 135 insertions(+), 112 deletions(-) diff --git a/cleanup-code.sh b/cleanup-code.sh index 840c71f7..dc6230af 100755 --- a/cleanup-code.sh +++ b/cleanup-code.sh @@ -172,5 +172,10 @@ tab2space() { # sed -i 's/\/checkAndGetMainWinIfMainWin/g' `grep '\' -rl include/ src/` # sed -i 's/\/checkAndGetMainWinIfWindow/g' `grep '\' -rl include/ src/` -sed -i 's/\/getMsgQueueForThisThread/g' `grep '\' -rl include/ src/` +# sed -i 's/\/getMsgQueueForThisThread/g' `grep '\' -rl include/ src/` + +# sed -i 's/\/IS_SHAREDFB_SCHEMA_PROCS/g' `grep '\' -rl include/ src/` + +sed -i 's/\/REQID_GETSHAREDSURFACE/g' `grep '\' -rl include/ src/` + exit 0 diff --git a/src/client/client.c b/src/client/client.c index 7d2d724c..f4435a6a 100644 --- a/src/client/client.c +++ b/src/client/client.c @@ -192,7 +192,7 @@ int GUIAPI ClientRequestEx2 (const REQUEST* request, && (__mg_client_id == 0 && request->id != REQID_JOINLAYER)) { #elif defined(_MGSCHEMA_COMPOSITING) if (__mg_client_id == 0 && request->id != REQID_JOINLAYER && - request->id != REQID_GETWPSURFACE) { + request->id != REQID_GETSHAREDSURFACE) { #else if (__mg_client_id == 0 && request->id != REQID_JOINLAYER) { #endif diff --git a/src/include/client.h b/src/include/client.h index c215e95f..07d904e0 100644 --- a/src/include/client.h +++ b/src/include/client.h @@ -101,8 +101,8 @@ #define REQID_COPYCURSOR 0x001B /* Since 5.0.0 */ -// Get global wallpaper pattern surface -#define REQID_GETWPSURFACE 0x001C +// Get shared surface +#define REQID_GETSHAREDSURFACE 0x001C // Load cursor from PNG file #define REQID_LOADCURSOR_PNG 0x001D // Load cursor from in-memory PNG @@ -117,6 +117,9 @@ // Calculate the position a main window with WS_EX_AUTOPOSITION #define REQID_CALCPOSITION 0x0022 +// Get the shared screen surface for client +#define REQID_CALCPOSITION 0x0022 + #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 */ typedef struct _SharedSurfInfo { - Uint32 flags; - size_t map_size; + Uint32 flags; // the flags of the surface + uint32_t name; // when use flinked name + size_t map_size; // whole size of the surface } SHAREDSURFINFO; typedef struct JoinLayerInfo { diff --git a/src/include/constants.h b/src/include/constants.h index 7bee1f47..a80f07e0 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -62,9 +62,9 @@ #endif #if defined(_MGRM_PROCESSES) && defined(_MGSCHEMA_SHAREDFB) -# define IS_SHAREDFB_SCHEMA 1 +# define IS_SHAREDFB_SCHEMA_PROCS 1 #else -# define IS_SHAREDFB_SCHEMA 0 +# define IS_SHAREDFB_SCHEMA_PROCS 0 #endif /* the maximal number of the dirty rects */ diff --git a/src/kernel/desktop-procs.c b/src/kernel/desktop-procs.c index 5202531c..03016321 100644 --- a/src/kernel/desktop-procs.c +++ b/src/kernel/desktop-procs.c @@ -357,8 +357,8 @@ static intptr_t cliAllocZOrderNode (PMAINWIN pWin, const COMPOSITINGINFO* ct_inf assert (pWin->surf && pWin->surf->shared_header); info.surf_flags = pWin->surf->flags; - info.surf_size = pWin->surf->shared_header->buf_size; - info.surf_size += sizeof (*pWin->surf->shared_header); + info.surf_size = pWin->surf->shared_header->pixels_size; + info.surf_size += pWin->surf->shared_header->pixels_off; if (ct_info) { info.ct = ct_info->type; @@ -474,8 +474,8 @@ static intptr_t cliMoveWindow (PMAINWIN pWin, const RECT* rcWin, int fd) #ifdef _MGSCHEMA_COMPOSITING info.surf_flags = pWin->surf->flags; - info.surf_size = pWin->surf->shared_header->buf_size; - info.surf_size += sizeof (*pWin->surf->shared_header); + info.surf_size = pWin->surf->shared_header->pixels_size; + info.surf_size += pWin->surf->shared_header->pixels_off; #endif if (ClientRequestEx2 (&req, NULL, 0, fd, @@ -529,8 +529,8 @@ static intptr_t cliStartTrackPopupMenu (PTRACKMENUINFO ptmi) assert (surf->shared_header); info.surf_flags = surf->flags; - info.surf_size = surf->shared_header->buf_size; - info.surf_size += sizeof (*surf->shared_header); + info.surf_size = surf->shared_header->pixels_size; + info.surf_size += surf->shared_header->pixels_off; if (ClientRequestEx2 (&req, NULL, 0, surf->shared_header->fd, &ret, sizeof (intptr_t), NULL) < 0) return -1; diff --git a/src/kernel/zorder.c b/src/kernel/zorder.c index 58db9550..0a04c045 100644 --- a/src/kernel/zorder.c +++ b/src/kernel/zorder.c @@ -274,7 +274,7 @@ void __kernel_free_z_order_info (ZORDERINFO* zi) } #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) { @@ -299,7 +299,7 @@ int __kernel_alloc_z_order_info (int nr_topmosts, int nr_normals) 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) { @@ -378,14 +378,14 @@ ZORDERINFO* __kernel_alloc_z_order_info (int nr_topmosts, int nr_normals) return zi; } -#endif /* not IS_SHAREDFB_SCHEMA */ +#endif /* not IS_SHAREDFB_SCHEMA_PROCS */ void __kernel_free_z_order_info (ZORDERINFO* zi) { -#if IS_SHAREDFB_SCHEMA +#if IS_SHAREDFB_SCHEMA_PROCS if (shmdt (zi) < 0) perror ("Detaches shared zorder nodes"); -#else /* not IS_SHAREDFB_SCHEMA */ +#else /* not IS_SHAREDFB_SCHEMA_PROCS */ #ifdef _MGRM_THREADS #ifndef __NOUNIX__ @@ -396,7 +396,7 @@ void __kernel_free_z_order_info (ZORDERINFO* zi) #endif /* _MGRM_THREADS */ free (zi); -#endif /* not IS_SHAREDFB_SCHEMA */ +#endif /* not IS_SHAREDFB_SCHEMA_PROCS */ } #endif /* deprecated code */ diff --git a/src/newgal/dfb/dfbvideo.c b/src/newgal/dfb/dfbvideo.c index 6898fabb..7fc33dad 100644 --- a/src/newgal/dfb/dfbvideo.c +++ b/src/newgal/dfb/dfbvideo.c @@ -117,7 +117,7 @@ GAL_FunctionTable mgGALFuncTable = { DFB_SetColors, DFB_UpdateRects, DFB_VideoQuit, -#if IS_SHAREDFB_SCHEMA +#if IS_SHAREDFB_SCHEMA_PROCS DFB_RequestHWSurface, #endif DFB_AllocHWSurface, @@ -167,7 +167,7 @@ static GAL_VideoDevice *DFB_CreateDevice (int devindex) device->SetColors = DFB_SetColors; device->VideoQuit = DFB_VideoQuit; device->UpdateRects = DFB_UpdateRects; -#if IS_SHAREDFB_SCHEMA +#if IS_SHAREDFB_SCHEMA_PROCS device->RequestHWSurface = DFB_RequestHWSurface; #endif device->AllocHWSurface = DFB_AllocHWSurface; diff --git a/src/newgal/drm/drmvideo.h b/src/newgal/drm/drmvideo.h index d07b9e5d..19064197 100644 --- a/src/newgal/drm/drmvideo.h +++ b/src/newgal/drm/drmvideo.h @@ -85,6 +85,15 @@ typedef struct GAL_PrivateVideoData { /* only valid when using DRM driver */ 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; #endif /* _NEWGAL_DRIVIDEO_H */ diff --git a/src/newgal/hisi/gal_hi3560a.c b/src/newgal/hisi/gal_hi3560a.c index 92ba310b..c59bab34 100644 --- a/src/newgal/hisi/gal_hi3560a.c +++ b/src/newgal/hisi/gal_hi3560a.c @@ -236,7 +236,7 @@ static GAL_VideoDevice *HI3560A_CreateDevice(int devindex) device->SetVideoMode = HI3560A_SetVideoMode; device->SetColors = HI3560A_SetColors; device->VideoQuit = HI3560A_VideoQuit; -#if IS_SHAREDFB_SCHEMA +#if IS_SHAREDFB_SCHEMA_PROCS device->RequestHWSurface = HI3560A_RequestHWSurface; #endif device->AllocHWSurface = HI3560A_AllocHWSurface; diff --git a/src/newgal/hisi/hi3510_fbvideo.c b/src/newgal/hisi/hi3510_fbvideo.c index a4e0733a..ef5c4f58 100644 --- a/src/newgal/hisi/hi3510_fbvideo.c +++ b/src/newgal/hisi/hi3510_fbvideo.c @@ -1851,7 +1851,7 @@ static GAL_VideoDevice *HI3510_CreateDevice (int devindex) this->SetVideoMode = HI3510_SetVideoMode; //this->SetColors = FB_SetColors; this->VideoQuit = HI3510_VideoQuit; -#if IS_SHAREDFB_SCHEMA +#if IS_SHAREDFB_SCHEMA_PROCS this->RequestHWSurface = HI3510_RequestHWSurface; #endif this->AllocHWSurface = HI3510_AllocHWSurface; diff --git a/src/newgal/hisi/hi3560_fbvideo.c b/src/newgal/hisi/hi3560_fbvideo.c index 10d00bba..ffb0c7e3 100644 --- a/src/newgal/hisi/hi3560_fbvideo.c +++ b/src/newgal/hisi/hi3560_fbvideo.c @@ -1843,7 +1843,7 @@ static GAL_VideoDevice *HI3560_CreateDevice (int devindex) this->ListModes = HI3560_ListModes; this->SetVideoMode = HI3560_SetVideoMode; this->VideoQuit = HI3560_VideoQuit; -#if IS_SHAREDFB_SCHEMA +#if IS_SHAREDFB_SCHEMA_PROCS this->RequestHWSurface = HI3560_RequestHWSurface; #endif this->AllocHWSurface = HI3560_AllocHWSurface; diff --git a/src/newgal/newgal.c b/src/newgal/newgal.c index 529b5ccf..97a2ff67 100644 --- a/src/newgal/newgal.c +++ b/src/newgal/newgal.c @@ -230,18 +230,19 @@ static GAL_Surface* create_wp_surface(GAL_Surface* screen) } else { REQUEST req; + GHANDLE handle = 0; // for wallpaper pattern, handle always be zero. int fd = -1; SHAREDSURFINFO info; - req.id = REQID_GETWPSURFACE; - req.data = &fd; - req.len_data = sizeof(int); + req.id = REQID_GETSHAREDSURFACE; + req.data = &handle; + req.len_data = sizeof(GHANDLE); if ((ClientRequestEx2 (&req, NULL, 0, -1, &info, sizeof (SHAREDSURFINFO), &fd) < 0) || (fd < 0)) 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); wp_surf = GAL_AttachSharedRGBSurface (fd, info.map_size, info.flags, TRUE); diff --git a/src/newgal/s3c6410/gal-s3c6410.c b/src/newgal/s3c6410/gal-s3c6410.c index 7722e5b3..e97824b0 100644 --- a/src/newgal/s3c6410/gal-s3c6410.c +++ b/src/newgal/s3c6410/gal-s3c6410.c @@ -190,7 +190,7 @@ static GAL_VideoDevice *S3C6410_CreateDevice(int devindex) device->SetVideoMode = S3C6410_SetVideoMode; device->SetColors = S3C6410_SetColors; device->VideoQuit = S3C6410_VideoQuit; -#if IS_SHAREDFB_SCHEMA +#if IS_SHAREDFB_SCHEMA_PROCS device->RequestHWSurface = S3C6410_RequestHWSurface; #endif device->AllocHWSurface = S3C6410_AllocHWSurface; diff --git a/src/newgal/stgfb/stgfb_video.c b/src/newgal/stgfb/stgfb_video.c index 26decd48..69430d39 100644 --- a/src/newgal/stgfb/stgfb_video.c +++ b/src/newgal/stgfb/stgfb_video.c @@ -847,7 +847,7 @@ static GAL_VideoDevice *STGFB_CreateDevice (int devindex) this->SetColors = STGFB_SetColors; this->VideoQuit = STGFB_VideoQuit; this->UpdateRects = STGFB_UpdateRects; -#if IS_SHAREDFB_SCHEMA +#if IS_SHAREDFB_SCHEMA_PROCS this->RequestHWSurface = STGFB_RequestHWSurface; #endif this->AllocHWSurface = STGFB_AllocHWSurface; diff --git a/src/newgal/surface-shared.c b/src/newgal/surface-shared.c index b6294580..976a44a9 100644 --- a/src/newgal/surface-shared.c +++ b/src/newgal/surface-shared.c @@ -148,8 +148,8 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video, /* Get the pixels */ { int fd = -1; - size_t buf_size; - off_t buf_off; + size_t pixels_size; + off_t pixels_off; off_t map_size; void* data_map; GAL_SharedSurfaceHeader* hdr; @@ -158,20 +158,20 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video, if ((flags & GAL_HWSURFACE) == GAL_HWSURFACE && video->AllocSharedHWSurface) { 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 off_t file_size; byhw = 0; - buf_size = (surface->h * surface->pitch); - buf_off = sizeof (GAL_SharedSurfaceHeader); + pixels_size = (surface->h * surface->pitch); + pixels_off = sizeof (GAL_SharedSurfaceHeader); /* 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 ()); - 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", surface->w, surface->h, surface->pitch, file_size); @@ -184,7 +184,7 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video, 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, MAP_SHARED, fd, 0); if (data_map == MAP_FAILED) { @@ -207,7 +207,8 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video, hdr->Gmask = Gmask; hdr->Bmask = Bmask; 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->dirty_age = 0; @@ -226,19 +227,7 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video, } } -#if 0 - /* 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); + surface->pixels = (uint8_t*)surface->shared_header + pixels_off; if (byhw) surface->flags |= GAL_HWSURFACE; @@ -277,7 +266,7 @@ error: else { close (surface->shared_header->fd); munmap (surface->shared_header, - surface->shared_header->buf_size + surface->shared_header->pixels_size + sizeof(GAL_SharedSurfaceHeader)); } @@ -310,19 +299,20 @@ void GAL_FreeSharedSurfaceData (GAL_Surface *surface) __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) { assert (video->FreeSharedHWSurface); video->FreeSharedHWSurface (video, surface); 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->shared_header = NULL; @@ -368,6 +358,7 @@ GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size, surface->flags = flags; surface->shared_header = NULL; + surface->hwdata = NULL; if (video && video->AttachSharedHWSurface) { // this method should fill hwdata and shared_header fields if success 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); if (data_map == MAP_FAILED) { _ERR_PRINTF("NEWGAL: Failed to map shared RGB surface: %d\n", fd); - return NULL; + goto error; } surface->hwdata = NULL; @@ -395,8 +386,13 @@ GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size, /* map successfully */ hdr = surface->shared_header; + if (surface->hwdata) + surface->flags |= GAL_HWSURFACE; + else + surface->flags &= ~GAL_HWSURFACE; + surface->dirty_info = &hdr->dirty_info; - surface->pixels = hdr->buf; + surface->pixels = (uint8_t*)hdr + hdr->pixels_off; surface->format = GAL_AllocFormat (hdr->depth, hdr->Rmask, hdr->Gmask, hdr->Bmask, hdr->Amask); if (surface->format == NULL) { @@ -405,7 +401,7 @@ GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size, surface->w = hdr->width; surface->h = hdr->height; - surface->pitch = GAL_CalculatePitch (surface); + surface->pitch = hdr->pitch; surface->offset = 0; // for off-screen surface, DPI always be the default value surface->dpi = GDCAP_DPI_DEFAULT; @@ -429,12 +425,12 @@ GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size, return (surface); error: - if (data_map != MAP_FAILED) { - if (video && video->DettachSharedHWSurface) { - video->DettachSharedHWSurface (video, surface); - } - else - munmap (data_map, map_size); + if (video && surface->hwdata) { + assert (video->DettachSharedHWSurface); + video->DettachSharedHWSurface (video, surface); + } + else if (data_map != MAP_FAILED) { + munmap (data_map, map_size); } if (surface) @@ -453,14 +449,17 @@ void GAL_DettachSharedSurfaceData (GAL_Surface *surface) assert (surface->shared_header); - if (video && video->DettachSharedHWSurface) { + if (video && surface->hwdata) { + assert (video->DettachSharedHWSurface); video->DettachSharedHWSurface (video, surface); 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->shared_header = NULL; surface->dirty_info = NULL; diff --git a/src/newgal/surface.c b/src/newgal/surface.c index ec3d3abc..17d99e84 100644 --- a/src/newgal/surface.c +++ b/src/newgal/surface.c @@ -1760,7 +1760,7 @@ void GAL_FreeSurface (GAL_Surface *surface) #endif } -#if IS_SHAREDFB_SCHEMA +#if IS_SHAREDFB_SCHEMA_PROCS void GAL_RequestHWSurface (const REQ_HWSURFACE* request, REP_HWSURFACE* reply) { if (__mg_current_video->RequestHWSurface) { diff --git a/src/newgal/sysvideo.h b/src/newgal/sysvideo.h index 1ecfd957..53494983 100644 --- a/src/newgal/sysvideo.h +++ b/src/newgal/sysvideo.h @@ -156,7 +156,7 @@ struct GAL_VideoDevice { Set to NULL if no hardware shared surface supported. Return the PRIME file descriptor if success, otherwize -1. */ 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. 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. Return 0 if success, otherwize -1. */ 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. Set to NULL if no hardware shared surface supported. @@ -182,7 +182,7 @@ struct GAL_VideoDevice { /* Free a dumb surface allocated from hardware. Set to NULL if dumb surface is not supported. Return 0 if success, otherwise -1. */ - int (*FreeDumbSurface)(_THIS, GAL_Surface *surface); + void (*FreeDumbSurface)(_THIS, GAL_Surface *surface); /* Set hardware cursor. Set to NULL or return -1 if no hardware cursor support. */ diff --git a/src/newgdi/gdi.c b/src/newgdi/gdi.c index baa8c67b..2b47faec 100644 --- a/src/newgdi/gdi.c +++ b/src/newgdi/gdi.c @@ -4080,9 +4080,6 @@ GHANDLE GetVideoHandle (HDC hdc) #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) { 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); } -/* implemented in DRI engine. */ -GAL_Surface* __drm_create_surface_from_name (GHANDLE video, - 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) +HDC drmCreateDCFromName (GHANDLE video, uint32_t name, uint32_t drm_format, + unsigned int width, unsigned int height, uint32_t pitch) { PDC pmem_dc = NULL; GAL_Surface* surface; @@ -4109,7 +4100,8 @@ HDC drmCreateDCFromName (GHANDLE video, LOCK (&__mg_gdilock); surface = __drm_create_surface_from_name (video, name, - drm_format, width, height, pitch); + drm_format, sizeof (GAL_SharedSurfaceHeader), + width, height, pitch); UNLOCK (&__mg_gdilock); if (!surface) { @@ -4147,11 +4139,6 @@ HDC drmCreateDCFromName (GHANDLE video, 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, uint32_t handle, unsigned long size, uint32_t drm_format, unsigned int width, unsigned int height, uint32_t pitch) @@ -4164,7 +4151,7 @@ HDC drmCreateDCFromHandle (GHANDLE video, LOCK (&__mg_gdilock); surface = __drm_create_surface_from_handle (video, handle, size, - drm_format, width, height, pitch); + drm_format, 0, width, height, pitch); UNLOCK (&__mg_gdilock); if (!surface) { @@ -4202,11 +4189,6 @@ HDC drmCreateDCFromHandle (GHANDLE video, 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, int prime_fd, unsigned long size, uint32_t drm_format, unsigned int width, unsigned int height, uint32_t pitch) @@ -4219,7 +4201,8 @@ HDC drmCreateDCFromPrimeFd (GHANDLE video, LOCK (&__mg_gdilock); 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); if (!surface) { diff --git a/src/server/request.c b/src/server/request.c index d5deaed8..b596c7b8 100644 --- a/src/server/request.c +++ b/src/server/request.c @@ -727,7 +727,7 @@ static int handle_mlshadow_req (int cli, int clifd, void* buff, size_t len) } #endif -#if IS_SHAREDFB_SCHEMA +#if IS_SHAREDFB_SCHEMA_PROCS void release_hw_surface (REQ_HWSURFACE* allocated) { /*[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)); } -#endif /* IS_SHAREDFB_SCHEMA */ +#endif /* IS_SHAREDFB_SCHEMA_PROCS */ #ifdef _MGHAVE_CLIPBOARD extern int __mg_clipboard_op (int cli, int clifd, void* buff, size_t len); #endif #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; + handle = buff; + assert (__gal_fake_screen); + assert (*handle == 0); info.flags = __gal_fake_screen->flags; if (__gal_fake_screen->shared_header) { - info.map_size = sizeof (GAL_SharedSurfaceHeader); - info.map_size += __gal_fake_screen->shared_header->buf_size; + info.map_size = __gal_fake_screen->shared_header->pixels_size; + info.map_size += __gal_fake_screen->shared_header->pixels_off; return ServerSendReplyEx (clifd, &info, sizeof (SHAREDSURFINFO), __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); } } -#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 { void* handler; @@ -819,7 +841,7 @@ static struct req_request { { set_ime_stat, 0 }, { get_ime_stat, 0 }, { register_hook, 0 }, -#if IS_SHAREDFB_SCHEMA +#if IS_SHAREDFB_SCHEMA_PROCS { req_hw_surface, 0 }, #else { NULL, 0 }, @@ -849,13 +871,13 @@ static struct req_request { { set_ime_targetinfo, 0 }, { copy_cursor, 0 }, #if IS_COMPOSITING_SCHEMA - { get_wp_surface, 0 }, + { get_shared_surface, 0 }, { load_cursor_png_file, 0 }, { load_cursor_png_mem, 0 }, { alloc_sem_for_shared_surf, 0 }, { free_sem_for_shared_surf, 0 }, #else - { NULL, 0 }, + { get_shared_surface, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 },