Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
8e5e003f
Commit
8e5e003f
authored
Aug 20, 2001
by
Uwe Bonnes
Committed by
Alexandre Julliard
Aug 20, 2001
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added reference counting and delayed destruction of GDI objects.
parent
d44e495a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
59 additions
and
3 deletions
+59
-3
dc.c
objects/dc.c
+1
-0
gdiobj.c
objects/gdiobj.c
+58
-3
No files found.
objects/dc.c
View file @
8e5e003f
...
...
@@ -757,6 +757,7 @@ BOOL WINAPI DeleteDC( HDC hdc )
SelectObject
(
hdc
,
GetStockObject
(
BLACK_PEN
)
);
SelectObject
(
hdc
,
GetStockObject
(
WHITE_BRUSH
)
);
SelectObject
(
hdc
,
GetStockObject
(
SYSTEM_FONT
)
);
SelectObject
(
hdc
,
GetStockObject
(
DEFAULT_BITMAP
)
);
funcs
=
dc
->
funcs
;
if
(
dc
->
funcs
->
pDeleteDC
)
dc
->
funcs
->
pDeleteDC
(
dc
);
}
...
...
objects/gdiobj.c
View file @
8e5e003f
...
...
@@ -145,6 +145,48 @@ static HFONT create_stock_font( char const *fontName, const LOGFONTW *font, HKEY
/***********************************************************************
* inc_ref_count
*
* Increment the reference count of a GDI object.
*/
inline
static
void
inc_ref_count
(
HGDIOBJ
handle
)
{
GDIOBJHDR
*
header
;
if
((
header
=
GDI_GetObjPtr
(
handle
,
MAGIC_DONTCARE
)))
{
header
->
dwCount
++
;
GDI_ReleaseObj
(
handle
);
}
}
/***********************************************************************
* dec_ref_count
*
* Decrement the reference count of a GDI object.
*/
inline
static
void
dec_ref_count
(
HGDIOBJ
handle
)
{
GDIOBJHDR
*
header
;
if
((
header
=
GDI_GetObjPtr
(
handle
,
MAGIC_DONTCARE
)))
{
if
(
header
->
dwCount
)
header
->
dwCount
--
;
if
(
header
->
dwCount
!=
0x80000000
)
GDI_ReleaseObj
(
handle
);
else
{
/* handle delayed DeleteObject*/
header
->
dwCount
=
0
;
GDI_ReleaseObj
(
handle
);
TRACE
(
"executing delayed DeleteObject for %04x
\n
"
,
handle
);
DeleteObject
(
handle
);
}
}
}
/***********************************************************************
* GDI_Init
*
* GDI initialization.
...
...
@@ -243,7 +285,6 @@ inline static GDIOBJHDR *alloc_large_heap( WORD size, HGDIOBJ *handle )
*/
void
*
GDI_AllocObject
(
WORD
size
,
WORD
magic
,
HGDIOBJ
*
handle
)
{
static
DWORD
count
=
0
;
GDIOBJHDR
*
obj
;
_EnterSysLevel
(
&
GDI_level
);
...
...
@@ -269,7 +310,7 @@ void *GDI_AllocObject( WORD size, WORD magic, HGDIOBJ *handle )
obj
->
hNext
=
0
;
obj
->
wMagic
=
magic
|
OBJECT_NOSYSTEM
;
obj
->
dwCount
=
++
count
;
obj
->
dwCount
=
0
;
TRACE_SEC
(
*
handle
,
"enter"
);
return
obj
;
...
...
@@ -427,7 +468,15 @@ BOOL WINAPI DeleteObject( HGDIOBJ obj )
GDI_ReleaseObj
(
obj
);
return
TRUE
;
}
if
(
header
->
dwCount
)
{
TRACE
(
"delayed for %04x because object in use, count %ld
\n
"
,
obj
,
header
->
dwCount
);
header
->
dwCount
|=
0x80000000
;
/* mark for delete */
GDI_ReleaseObj
(
obj
);
return
TRUE
;
}
TRACE
(
"%04x
\n
"
,
obj
);
/* Delete object */
...
...
@@ -701,6 +750,12 @@ HGDIOBJ WINAPI SelectObject( HDC hdc, HGDIOBJ handle )
if
(
dc
->
funcs
->
pSelectObject
)
ret
=
dc
->
funcs
->
pSelectObject
(
dc
,
handle
);
GDI_ReleaseObj
(
hdc
);
if
(
ret
&&
ret
!=
handle
)
{
inc_ref_count
(
handle
);
dec_ref_count
(
ret
);
}
return
ret
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment