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
2f92af70
Commit
2f92af70
authored
Oct 12, 2012
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gdi32: Add helper functions for converting between handle and index.
Also rename all instances of "large handles" since that's the only handle type now.
parent
22336a12
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
30 deletions
+37
-30
gdiobj.c
dlls/gdi32/gdiobj.c
+37
-30
No files found.
dlls/gdi32/gdiobj.c
View file @
2f92af70
...
...
@@ -600,12 +600,22 @@ BOOL WINAPI DllMain( HINSTANCE inst, DWORD reason, LPVOID reserved )
return
TRUE
;
}
#define FIRST_
LARGE
_HANDLE 16
#define MAX_
LARGE_HANDLES ((GDI_HEAP_SIZE >> 2) - FIRST_LARGE
_HANDLE)
static
GDIOBJHDR
*
large_handles
[
MAX_LARGE
_HANDLES
];
static
int
next_
large
_handle
;
#define FIRST_
GDI
_HANDLE 16
#define MAX_
GDI_HANDLES ((GDI_HEAP_SIZE >> 2) - FIRST_GDI
_HANDLE)
static
GDIOBJHDR
*
gdi_handles
[
MAX_GDI
_HANDLES
];
static
int
next_
gdi
_handle
;
static
LONG
debug_count
;
static
inline
HGDIOBJ
index_to_handle
(
int
index
)
{
return
ULongToHandle
(
(
index
+
FIRST_GDI_HANDLE
)
<<
2
);
}
static
inline
int
handle_to_index
(
HGDIOBJ
handle
)
{
return
(
HandleToULong
(
handle
)
>>
2
)
-
FIRST_GDI_HANDLE
;
}
static
const
char
*
gdi_obj_type
(
unsigned
type
)
{
switch
(
type
)
...
...
@@ -632,20 +642,19 @@ static void dump_gdi_objects( void )
{
int
i
;
TRACE
(
"%u objects:
\n
"
,
MAX_
LARGE
_HANDLES
);
TRACE
(
"%u objects:
\n
"
,
MAX_
GDI
_HANDLES
);
EnterCriticalSection
(
&
gdi_section
);
for
(
i
=
0
;
i
<
MAX_
LARGE
_HANDLES
;
i
++
)
for
(
i
=
0
;
i
<
MAX_
GDI
_HANDLES
;
i
++
)
{
if
(
!
large
_handles
[
i
])
if
(
!
gdi
_handles
[
i
])
{
TRACE
(
"index %d handle %p FREE
\n
"
,
i
,
(
HGDIOBJ
)(
ULONG_PTR
)((
i
+
FIRST_LARGE_HANDLE
)
<<
2
)
);
TRACE
(
"index %d handle %p FREE
\n
"
,
i
,
index_to_handle
(
i
)
);
continue
;
}
TRACE
(
"handle %p obj %p type %s selcount %u deleted %u
\n
"
,
(
HGDIOBJ
)(
ULONG_PTR
)((
i
+
FIRST_LARGE_HANDLE
)
<<
2
),
large_handles
[
i
],
gdi_obj_type
(
large_handles
[
i
]
->
type
),
large_handles
[
i
]
->
selcount
,
large_handles
[
i
]
->
deleted
);
index_to_handle
(
i
),
gdi_handles
[
i
],
gdi_obj_type
(
gdi_handles
[
i
]
->
type
),
gdi_handles
[
i
]
->
selcount
,
gdi_handles
[
i
]
->
deleted
);
}
LeaveCriticalSection
(
&
gdi_section
);
}
...
...
@@ -668,10 +677,10 @@ HGDIOBJ alloc_gdi_handle( GDIOBJHDR *obj, WORD type, const struct gdi_obj_funcs
obj
->
hdcs
=
NULL
;
EnterCriticalSection
(
&
gdi_section
);
for
(
i
=
next_
large_handle
+
1
;
i
<
MAX_LARGE
_HANDLES
;
i
++
)
if
(
!
large
_handles
[
i
])
goto
found
;
for
(
i
=
0
;
i
<=
next_
large
_handle
;
i
++
)
if
(
!
large
_handles
[
i
])
goto
found
;
for
(
i
=
next_
gdi_handle
+
1
;
i
<
MAX_GDI
_HANDLES
;
i
++
)
if
(
!
gdi
_handles
[
i
])
goto
found
;
for
(
i
=
0
;
i
<=
next_
gdi
_handle
;
i
++
)
if
(
!
gdi
_handles
[
i
])
goto
found
;
LeaveCriticalSection
(
&
gdi_section
);
ERR
(
"out of GDI object handles, expect a crash
\n
"
);
...
...
@@ -679,13 +688,13 @@ HGDIOBJ alloc_gdi_handle( GDIOBJHDR *obj, WORD type, const struct gdi_obj_funcs
return
0
;
found:
large
_handles
[
i
]
=
obj
;
next_
large
_handle
=
i
;
gdi
_handles
[
i
]
=
obj
;
next_
gdi
_handle
=
i
;
LeaveCriticalSection
(
&
gdi_section
);
TRACE
(
"allocated %s %p %u/%u
\n
"
,
gdi_obj_type
(
type
),
(
HGDIOBJ
)(
ULONG_PTR
)((
i
+
FIRST_LARGE_HANDLE
)
<<
2
),
InterlockedIncrement
(
&
debug_count
),
MAX_
LARGE
_HANDLES
);
return
(
HGDIOBJ
)(
ULONG_PTR
)((
i
+
FIRST_LARGE_HANDLE
)
<<
2
);
gdi_obj_type
(
type
),
index_to_handle
(
i
),
InterlockedIncrement
(
&
debug_count
),
MAX_
GDI
_HANDLES
);
return
index_to_handle
(
i
);
}
...
...
@@ -697,20 +706,19 @@ HGDIOBJ alloc_gdi_handle( GDIOBJHDR *obj, WORD type, const struct gdi_obj_funcs
void
*
free_gdi_handle
(
HGDIOBJ
handle
)
{
GDIOBJHDR
*
object
=
NULL
;
int
i
;
int
i
=
handle_to_index
(
handle
)
;
i
=
(
HandleToULong
(
handle
)
>>
2
)
-
FIRST_LARGE_HANDLE
;
if
(
i
>=
0
&&
i
<
MAX_LARGE_HANDLES
)
if
(
i
>=
0
&&
i
<
MAX_GDI_HANDLES
)
{
EnterCriticalSection
(
&
gdi_section
);
object
=
large
_handles
[
i
];
large
_handles
[
i
]
=
NULL
;
object
=
gdi
_handles
[
i
];
gdi
_handles
[
i
]
=
NULL
;
LeaveCriticalSection
(
&
gdi_section
);
}
if
(
object
)
{
TRACE
(
"freed %s %p %u/%u
\n
"
,
gdi_obj_type
(
object
->
type
),
handle
,
InterlockedDecrement
(
&
debug_count
)
+
1
,
MAX_
LARGE
_HANDLES
);
InterlockedDecrement
(
&
debug_count
)
+
1
,
MAX_
GDI
_HANDLES
);
object
->
type
=
0
;
/* mark it as invalid */
object
->
funcs
=
NULL
;
}
...
...
@@ -728,14 +736,13 @@ void *free_gdi_handle( HGDIOBJ handle )
void
*
GDI_GetObjPtr
(
HGDIOBJ
handle
,
WORD
type
)
{
GDIOBJHDR
*
ptr
=
NULL
;
int
i
;
int
i
=
handle_to_index
(
handle
)
;
EnterCriticalSection
(
&
gdi_section
);
i
=
(
HandleToULong
(
handle
)
>>
2
)
-
FIRST_LARGE_HANDLE
;
if
(
i
>=
0
&&
i
<
MAX_LARGE_HANDLES
)
if
(
i
>=
0
&&
i
<
MAX_GDI_HANDLES
)
{
ptr
=
large
_handles
[
i
];
ptr
=
gdi
_handles
[
i
];
if
(
ptr
&&
type
&&
ptr
->
type
!=
type
)
ptr
=
NULL
;
}
...
...
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