diff --git a/src/include/newgal.h b/src/include/newgal.h index 72020b26..8d74c267 100644 --- a/src/include/newgal.h +++ b/src/include/newgal.h @@ -158,8 +158,8 @@ typedef struct _SharedSurfaceHeader { /* the RGBA masks */ Uint32 Rmask, Gmask, Bmask, Amask; - /* the size of the pixels data */ - size_t pixels_size; + /* the size of the whole buffer */ + size_t map_size; /* the offset of pixels data */ off_t pixels_off; } GAL_SharedSurfaceHeader; diff --git a/src/kernel/desktop-procs.c b/src/kernel/desktop-procs.c index f78596d7..f7c66561 100644 --- a/src/kernel/desktop-procs.c +++ b/src/kernel/desktop-procs.c @@ -357,8 +357,7 @@ 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->pixels_size; - info.surf_size += pWin->surf->shared_header->pixels_off; + info.surf_size = pWin->surf->shared_header->map_size; if (ct_info) { info.ct = ct_info->type; @@ -474,8 +473,7 @@ 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->pixels_size; - info.surf_size += pWin->surf->shared_header->pixels_off; + info.surf_size = pWin->surf->shared_header->map_size; #endif if (ClientRequestEx2 (&req, NULL, 0, fd, @@ -529,8 +527,7 @@ static intptr_t cliStartTrackPopupMenu (PTRACKMENUINFO ptmi) assert (surf->shared_header); info.surf_flags = surf->flags; - info.surf_size = surf->shared_header->pixels_size; - info.surf_size += surf->shared_header->pixels_off; + info.surf_size = surf->shared_header->map_size; if (ClientRequestEx2 (&req, NULL, 0, surf->shared_header->fd, &ret, sizeof (intptr_t), NULL) < 0) return -1; diff --git a/src/newgal/newgal.c b/src/newgal/newgal.c index c3b8f3bf..e24332d5 100644 --- a/src/newgal/newgal.c +++ b/src/newgal/newgal.c @@ -219,8 +219,10 @@ static GAL_Surface* create_wp_surface(GAL_Surface* screen) screen->format->BitsPerPixel, screen->format->Rmask, screen->format->Gmask, screen->format->Bmask, screen->format->Amask); - _DBG_PRINTF ("GAL_CreateSharedRGBSurface: buf_size: %lu, fd: %d\n", - wp_surf->shared_header->buf_size, wp_surf->shared_header->fd); + _WRN_PRINTF ("GAL_CreateSharedRGBSurface: map size: %lu, fd: %d, RGBAmasks: %x, %x, %x, %x\n", + wp_surf->shared_header->map_size, wp_surf->shared_header->fd, + wp_surf->format->Rmask, wp_surf->format->Gmask, + wp_surf->format->Bmask, wp_surf->format->Amask); } else { goto empty; @@ -241,7 +243,7 @@ static GAL_Surface* create_wp_surface(GAL_Surface* screen) &info, sizeof (SHAREDSURFINFO), &fd) < 0) || (fd < 0)) goto empty; - _DBG_PRINTF ("REQID_GETSHAREDSURFACE: size (%lu), flags (0x%x), fd: %d\n", + _WRN_PRINTF ("REQID_GETSHAREDSURFACE: size (%lu), flags (0x%x), fd: %d\n", info.size, info.flags, fd); wp_surf = GAL_AttachSharedRGBSurface (fd, info.size, info.flags, TRUE); diff --git a/src/newgal/surface-shared.c b/src/newgal/surface-shared.c index dda27a05..bed2e4f0 100644 --- a/src/newgal/surface-shared.c +++ b/src/newgal/surface-shared.c @@ -148,7 +148,7 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video, /* Get the pixels */ { int fd = -1; - size_t pixels_size; + size_t map_size; off_t pixels_off; GAL_SharedSurfaceHeader* hdr; int byhw = 1; @@ -156,12 +156,12 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video, if ((flags & GAL_HWSURFACE) == GAL_HWSURFACE && video->AllocSharedHWSurface) { fd = video->AllocSharedHWSurface (video, surface, - &pixels_size, &pixels_off, rw_modes); + &map_size, &pixels_off, rw_modes); hdr = surface->shared_header; } if (fd < 0) { // fallback to use software surface - off_t map_size; + size_t pixels_size; void* data_map; off_t file_size; @@ -169,12 +169,14 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video, pixels_size = (surface->h * surface->pitch); pixels_off = sizeof (GAL_SharedSurfaceHeader); - /* rounde file size to multiple of page size */ file_size = pixels_off + pixels_size; +#if 0 + /* rounde file size to multiple of page size */ file_size = ROUND_TO_MULTIPLE(file_size, getpagesize ()); pixels_size = file_size - pixels_off; +#endif - _DBG_PRINTF("shared surface: size (%d x %d), pitch (%d), file_size (%lu)\n", + _DBG_PRINTF("shared surface (%d x %d): pitch(%d), filesize(%lu)\n", surface->w, surface->h, surface->pitch, file_size); fd = __mg_create_anonymous_file (file_size, NULL, rw_modes); @@ -184,7 +186,7 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video, surface->video = NULL; - map_size = pixels_off + pixels_size; + map_size = file_size; data_map = mmap (NULL, map_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (data_map == MAP_FAILED) { @@ -208,7 +210,7 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video, hdr->Gmask = Gmask; hdr->Bmask = Bmask; hdr->Amask = Amask; - hdr->pixels_size= pixels_size; + hdr->map_size = map_size; hdr->pixels_off = pixels_off; surface->dirty_info = &hdr->dirty_info; @@ -267,8 +269,7 @@ error: else { close (surface->shared_header->fd); munmap (surface->shared_header, - surface->shared_header->pixels_size - + sizeof(GAL_SharedSurfaceHeader)); + surface->shared_header->map_size); } surface->shared_header = NULL; @@ -313,8 +314,7 @@ void GAL_FreeSharedSurfaceData (GAL_Surface *surface) } else { munmap (surface->shared_header, - surface->shared_header->pixels_size - + surface->shared_header->pixels_off); + surface->shared_header->map_size); } surface->pixels = NULL; @@ -459,8 +459,7 @@ void GAL_DettachSharedSurfaceData (GAL_Surface *surface) } else { munmap (surface->shared_header, - surface->shared_header->pixels_size - + surface->shared_header->pixels_off); + surface->shared_header->map_size); } surface->pixels = NULL; diff --git a/src/newgal/sysvideo.h b/src/newgal/sysvideo.h index 126068cf..31885fc5 100644 --- a/src/newgal/sysvideo.h +++ b/src/newgal/sysvideo.h @@ -158,7 +158,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* pixels_size, off_t* pixels_off, Uint32 rw_modes); + size_t* map_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. diff --git a/src/server/request.c b/src/server/request.c index 53ba36b2..bdea75a4 100644 --- a/src/server/request.c +++ b/src/server/request.c @@ -567,15 +567,15 @@ extern int Sigma8654_ServerOnGetSurface(REQ_SIGMA8654_GETSURFACE *request, REP_SIGMA8654_GETSURFACE *reply); static int sigma8654_client_get_surface(int cli, int clifd, void* buff, size_t len) { - REQ_SIGMA8654_GETSURFACE *request; - REP_SIGMA8654_GETSURFACE reply; + REQ_SIGMA8654_GETSURFACE *request; + REP_SIGMA8654_GETSURFACE reply; - if (Sigma8654_ServerOnGetSurface(request, &reply) < 0) - { - fprintf(stderr, "Nexus_ServerOnGetSurface() failed\n"); - return -1; - } - return ServerSendReply (clifd, &reply, sizeof (reply)); + if (Sigma8654_ServerOnGetSurface(request, &reply) < 0) + { + fprintf(stderr, "Nexus_ServerOnGetSurface() failed\n"); + return -1; + } + return ServerSendReply (clifd, &reply, sizeof (reply)); } #endif @@ -585,15 +585,15 @@ extern int Nexus_ServerOnGetSurface(REQ_NEXUS_GETSURFACE *request, REP_NEXUS_GETSURFACE *reply); static int nexus_client_get_surface(int cli, int clifd, void* buff, size_t len) { - REQ_NEXUS_GETSURFACE *request; - REP_NEXUS_GETSURFACE reply; + REQ_NEXUS_GETSURFACE *request; + REP_NEXUS_GETSURFACE reply; - if (Nexus_ServerOnGetSurface(request, &reply) < 0) - { - fprintf(stderr, "Nexus_ServerOnGetSurface() failed\n"); - return -1; - } - return ServerSendReply (clifd, &reply, sizeof (reply)); + if (Nexus_ServerOnGetSurface(request, &reply) < 0) + { + fprintf(stderr, "Nexus_ServerOnGetSurface() failed\n"); + return -1; + } + return ServerSendReply (clifd, &reply, sizeof (reply)); } #endif @@ -785,9 +785,7 @@ static int get_shared_surface (int cli, int clifd, void* buff, size_t len) info.flags = __gal_fake_screen->flags; if (strcmp (buff, SYSSF_WALLPAPER_PATTER) == 0 && __gal_fake_screen->shared_header) { - info.size = __gal_fake_screen->shared_header->pixels_size; - info.size += __gal_fake_screen->shared_header->pixels_off; - + info.size = __gal_fake_screen->shared_header->map_size; return ServerSendReplyEx (clifd, &info, sizeof (SHAREDSURFINFO), __gal_fake_screen->shared_header->fd); }