This commit is contained in:
Vincent Wei
2020-01-08 17:24:01 +08:00
parent dd69a7c764
commit d25d629292
4 changed files with 50 additions and 18 deletions
+2 -2
View File
@@ -245,7 +245,7 @@ HCURSOR GUIAPI CreateCursor (int xhotspot, int yhotspot, int w, int h,
req.len_data = sizeof (int) * 6 + len_and_bits + len_xor_bits;
if ((tmp = (int*) ALLOCATE_LOCAL (req.len_data)) == NULL)
return 0;
return 0;
tmp [0] = xhotspot; tmp [1] = yhotspot;
tmp [2] = w; tmp [3] = h;
@@ -494,7 +494,7 @@ static void showcursor (void)
for (i = 0; i < __mg_csrimgsize >> 2; i++) {
dst [i] &= andbits [i];
dst [i] ^= xorbits[i];
dst [i] ^= xorbits [i];
}
}
#endif
+14 -2
View File
@@ -204,7 +204,7 @@ GAL_Surface * GAL_CreateSharedRGBSurface (GAL_VideoDevice *video,
goto error;
surface->pixels = surface->shared_header->buf;
memset (surface->pixels, 0, buf_size);
// memset (surface->pixels, 0, buf_size);
if (byhw)
surface->flags |= GAL_HWSURFACE;
@@ -233,6 +233,7 @@ error:
if (surface->shared_header->byhw) {
assert(video->FreeSharedHWSurface);
video->FreeSharedHWSurface (video, surface);
surface->hwdata = NULL; /* set to NULL for GAL_FreeSurface */
}
else {
close (surface->shared_header->fd);
@@ -240,8 +241,11 @@ error:
surface->shared_header->buf_size
+ sizeof(GAL_SharedSurfaceHeader));
}
surface->shared_header = NULL;
}
surface->pixels = NULL;
GAL_FreeSurface (surface);
}
@@ -266,6 +270,7 @@ void GAL_FreeSharedSurfaceData (GAL_Surface *surface)
if (surface->shared_header->byhw) {
assert (video->FreeSharedHWSurface);
video->FreeSharedHWSurface (video, surface);
surface->hwdata = NULL;
}
else {
close (surface->shared_header->fd);
@@ -273,12 +278,16 @@ void GAL_FreeSharedSurfaceData (GAL_Surface *surface)
surface->shared_header->buf_size
+ sizeof (GAL_SharedSurfaceHeader));
}
surface->pixels = NULL;
surface->shared_header = NULL;
}
/*
* Attach to a shared RGB surface
*/
GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size, Uint32 flags, BOOL with_wr)
GAL_Surface * GAL_AttachSharedRGBSurface (int fd, size_t map_size,
Uint32 flags, BOOL with_wr)
{
GAL_VideoDevice *video;
GAL_Surface *surface;
@@ -410,11 +419,14 @@ void GAL_DettachSharedSurfaceData (GAL_Surface *surface)
if (video && video->DettachSharedHWSurface) {
video->DettachSharedHWSurface (video, surface);
surface->hwdata = NULL;
}
munmap (surface->shared_header,
surface->shared_header->buf_size
+ sizeof (GAL_SharedSurfaceHeader));
surface->pixels = NULL;
surface->shared_header = NULL;
}
#endif /* IS_COMPOSITING_SCHEMA */
+22 -8
View File
@@ -1746,6 +1746,9 @@ void GAL_FreeSurface (GAL_Surface *surface)
GAL_FreeSharedSurfaceData(surface);
else
GAL_DettachSharedSurfaceData(surface);
surface->hwdata = NULL;
surface->pixels = NULL;
}
#endif
@@ -1754,26 +1757,37 @@ void GAL_FreeSurface (GAL_Surface *surface)
#endif
if ((surface->flags & GAL_RLEACCEL) == GAL_RLEACCEL) {
GAL_UnRLESurface(surface, 0);
GAL_UnRLESurface(surface, 0);
}
if (surface->format) {
GAL_FreeFormat(surface->format);
surface->format = NULL;
}
if (surface->map != NULL) {
GAL_FreeBlitMap(surface->map);
surface->map = NULL;
}
if ((surface->flags & GAL_HWSURFACE) == GAL_HWSURFACE) {
GAL_VideoDevice *video = __mg_current_video;
GAL_VideoDevice *this = __mg_current_video;
video->FreeHWSurface(this, surface);
/* Use surface->hwdata to check hardware surface instead of
if (surface->flags & GAL_HWSURFACE) == GAL_HWSURFACE)
*/
if (surface->hwdata) {
GAL_VideoDevice *video = surface->video;
assert (video);
assert (video->FreeHWSurface);
video->FreeHWSurface (video, surface);
}
if (surface->pixels &&
((surface->flags & GAL_PREALLOC) != GAL_PREALLOC)) {
free(surface->pixels);
((surface->flags & GAL_PREALLOC) != GAL_PREALLOC)) {
free (surface->pixels);
}
free(surface);
free (surface);
#ifdef CHECK_LEAKS
--surfaces_allocated;
#endif
+12 -6
View File
@@ -167,16 +167,22 @@ struct GAL_VideoDevice {
/* Dettach from a shared surface in hardware video memory.
Set to NULL if no hardware shared surface supported.
Return 0 if success, otherwize -1. */
Return 0 if success, otherwise -1. */
int (*DettachSharedHWSurface)(_THIS, GAL_Surface *surface);
/* Get hardware surface for cursor.
Set to NULL or return -1 if no hardware cursor support. */
int (*GetCursorSurface)(_THIS, GAL_Surface *surface, int width, int height);
/* Allocate a dumb surface from hardware.
Set to NULL if dumb surface is not supported.
Return 0 if success, otherwise -1. */
int (*AllocDumbSurface)(_THIS, GAL_Surface *surface);
/* Set hot spot of hardware cursor.
/* 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);
/* Set hardware cursor.
Set to NULL or return -1 if no hardware cursor support. */
int (*SetCursorHotspot)(_THIS, int hot_x, int hot_y);
int (*SetCursor)(_THIS, GAL_Surface *surface, int hot_x, int hot_y);
/* Move hardware cursor to new position.
Set to NULL or return -1 if no hardware cursor support. */