use GAL_RefSurface() in CreateMemDCFromSurface()

This commit is contained in:
Vincent Wei
2023-09-01 10:01:11 +08:00
parent b4ce6f9f10
commit fbebc94718
7 changed files with 28 additions and 20 deletions
+1 -1
View File
@@ -2185,7 +2185,7 @@ static int create_memdc_for_menu (TRACKMENUINFO* ptmi)
return -1;
}
ptmi->dc = CreateMemDCFromSurface (surf);
ptmi->dc = __mg_create_memdc_for_surface (surf);
if (ptmi->dc == HDC_INVALID) {
GAL_FreeSurface (surf);
return -1;
+1 -3
View File
@@ -958,9 +958,7 @@ BOOL gui_LoadIconRes(HDC hdc, const char* rdr_name, char* file);
void gui_WndRect(HWND hWnd, PRECT prc);
void gui_WndClientRect(HWND hWnd, PRECT prc);
/* Undisclosed APIs */
HDC CreateMemDCFromSurface (struct GAL_Surface* surface);
struct GAL_Surface* GetSurfaceFromDC (HDC hdc);
HDC __mg_create_memdc_for_surface (struct GAL_Surface* surface);
/* Since 5.0.0 */
#ifdef _MGRM_PROCESSES
+5
View File
@@ -583,6 +583,11 @@ GAL_Surface *GAL_CreateRGBSurface
GAL_Surface *GAL_CreateRGBSurfaceFrom (void *pixels,
int width, int height, int depth, int pitch,
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
/* Since 5.2.0 */
static GAL_Surface *GAL_RefSurface (GAL_Surface *surface) {
surface->refcount++;
return surface;
}
void GAL_FreeSurface (GAL_Surface *surface);
typedef struct REQ_HWSURFACE {
+2 -2
View File
@@ -848,7 +848,7 @@ static int srvAllocZOrderNode (int cli, HWND hwnd, HWND main_win,
}
if (surf) {
memdc = CreateMemDCFromSurface (surf);
memdc = __mg_create_memdc_for_surface (surf);
if (memdc == HDC_INVALID) {
if (cli > 0) {
GAL_FreeSurface (surf);
@@ -1003,7 +1003,7 @@ static int srvMoveWindow (int cli, int idx_znode, const RECT* rcWin,
}
if (surf) {
memdc = CreateMemDCFromSurface (surf);
memdc = __mg_create_memdc_for_surface (surf);
if (memdc == HDC_INVALID) {
if (cli > 0) {
GAL_FreeSurface (surf);
+1 -1
View File
@@ -1614,7 +1614,7 @@ static int srvStartTrackPopupMenu (int cli, const RECT* rc, HWND ptmi,
}
if (surf) {
memdc = CreateMemDCFromSurface (surf);
memdc = __mg_create_memdc_for_surface (surf);
if (memdc == HDC_INVALID) {
GAL_FreeSurface (surf);
_WRN_PRINTF("failed to create memory dc for znode\n");
+17 -7
View File
@@ -3346,8 +3346,7 @@ HDC GUIAPI CreateMemDCEx (int width, int height, int depth, DWORD flags,
return (HDC)pmem_dc;
}
/* Since 5.0.0; exported as API since 5.2.0 */
HDC GUIAPI CreateMemDCFromSurface (HSURF surface)
static HDC create_memdc_from_surface(HSURF surface, BOOL take_owner)
{
PDC pmem_dc = NULL;
@@ -3360,7 +3359,10 @@ HDC GUIAPI CreateMemDCFromSurface (HSURF surface)
pmem_dc->DataType = TYPE_HDC;
pmem_dc->DCType = TYPE_MEMDC;
pmem_dc->bInUse = TRUE;
pmem_dc->surface = surface;
if (take_owner)
pmem_dc->surface = surface;
else
pmem_dc->surface = GAL_RefSurface(surface);
dc_InitDC (pmem_dc, HWND_NULL, FALSE);
@@ -3384,14 +3386,22 @@ HDC GUIAPI CreateMemDCFromSurface (HSURF surface)
return (HDC)pmem_dc;
}
/* Since 5.2.0 */
HDC GUIAPI CreateMemDCFromSurface (HSURF surface)
{
return create_memdc_from_surface(surface, FALSE);
}
HDC __mg_create_memdc_for_surface (HSURF surface)
{
return create_memdc_from_surface(surface, TRUE);
}
HSURF GUIAPI GetSurfaceFromDC (HDC hdc)
{
PDC pdc;
pdc = dc_HDC2PDC(hdc);
if (pdc)
return pdc->surface;
return NULL;
return pdc->surface;
}
HDC GUIAPI CreateSubMemDC (HDC parent, int off_x, int off_y,
+1 -6
View File
@@ -289,12 +289,7 @@ int GUIAPI GetSharedSurfaceFDByName(const char *name,
HSURF GUIAPI AttachToSharedSurface(GHANDLE video, int fd,
size_t map_size, DWORD flags)
{
HSURF surf = GAL_AttachSharedRGBSurface(video, fd, map_size, flags, TRUE);
if (surf) {
surf->refcount++;
}
return surf;
return GAL_AttachSharedRGBSurface(video, fd, map_size, flags, TRUE);
}
const char *GUIAPI GetSharedSurfaceInfo(HSURF surf, int *fd,