Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
18ac6bf4
Commit
18ac6bf4
authored
Nov 19, 2018
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wineandroid: Add helper functions to encapsulate gralloc functionality.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
a4fbe12f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
30 deletions
+59
-30
android.h
dlls/wineandroid.drv/android.h
+1
-2
device.c
dlls/wineandroid.drv/device.c
+50
-22
init.c
dlls/wineandroid.drv/init.c
+8
-6
No files found.
dlls/wineandroid.drv/android.h
View file @
18ac6bf4
...
...
@@ -88,6 +88,7 @@ enum android_window_messages
WM_ANDROID_REFRESH
=
0x80001000
,
};
extern
void
init_gralloc
(
const
struct
hw_module_t
*
module
)
DECLSPEC_HIDDEN
;
extern
HWND
get_capture_window
(
void
)
DECLSPEC_HIDDEN
;
extern
void
init_monitors
(
int
width
,
int
height
)
DECLSPEC_HIDDEN
;
extern
void
set_screen_dpi
(
DWORD
dpi
)
DECLSPEC_HIDDEN
;
...
...
@@ -155,6 +156,4 @@ int send_event( const union event_data *data );
extern
JavaVM
*
wine_get_java_vm
(
void
);
extern
jobject
wine_get_java_object
(
void
);
extern
struct
gralloc_module_t
*
gralloc_module
;
#endif
/* __WINE_ANDROID_H */
dlls/wineandroid.drv/device.c
View file @
18ac6bf4
...
...
@@ -212,6 +212,8 @@ struct ioctl_android_set_capture
struct
ioctl_header
hdr
;
};
static
struct
gralloc_module_t
*
gralloc_module
;
static
inline
BOOL
is_in_desktop_process
(
void
)
{
return
thread
!=
NULL
;
...
...
@@ -496,6 +498,44 @@ void register_native_window( HWND hwnd, struct ANativeWindow *win, BOOL opengl )
NtQueueApcThread
(
thread
,
register_native_window_callback
,
(
ULONG_PTR
)
hwnd
,
(
ULONG_PTR
)
win
,
opengl
);
}
void
init_gralloc
(
const
struct
hw_module_t
*
module
)
{
TRACE
(
"got module %p ver %u.%u id %s name %s author %s
\n
"
,
module
,
module
->
module_api_version
>>
8
,
module
->
module_api_version
&
0xff
,
debugstr_a
(
module
->
id
),
debugstr_a
(
module
->
name
),
debugstr_a
(
module
->
author
)
);
gralloc_module
=
(
struct
gralloc_module_t
*
)
module
;
}
static
int
gralloc_grab_buffer
(
struct
ANativeWindowBuffer
*
buffer
)
{
if
(
gralloc_module
)
return
gralloc_module
->
registerBuffer
(
gralloc_module
,
buffer
->
handle
);
return
-
ENODEV
;
}
static
void
gralloc_release_buffer
(
struct
ANativeWindowBuffer
*
buffer
)
{
if
(
gralloc_module
)
gralloc_module
->
unregisterBuffer
(
gralloc_module
,
buffer
->
handle
);
close_native_handle
(
(
native_handle_t
*
)
buffer
->
handle
);
}
static
int
gralloc_lock
(
struct
ANativeWindowBuffer
*
buffer
,
void
**
bits
)
{
if
(
gralloc_module
)
return
gralloc_module
->
lock
(
gralloc_module
,
buffer
->
handle
,
GRALLOC_USAGE_SW_READ_OFTEN
|
GRALLOC_USAGE_SW_WRITE_OFTEN
,
0
,
0
,
buffer
->
width
,
buffer
->
height
,
bits
);
*
bits
=
((
struct
native_buffer_wrapper
*
)
buffer
)
->
bits
;
return
0
;
}
static
void
gralloc_unlock
(
struct
ANativeWindowBuffer
*
buffer
)
{
if
(
gralloc_module
)
gralloc_module
->
unlock
(
gralloc_module
,
buffer
->
handle
);
}
/* get the capture window stored in the desktop process */
HWND
get_capture_window
(
void
)
{
...
...
@@ -740,12 +780,10 @@ static NTSTATUS queueBuffer_ioctl( void *data, DWORD in_size, DWORD out_size, UL
if
(
win_data
->
mappings
[
res
->
buffer_id
])
{
void
*
bits
;
int
ret
=
gralloc_module
->
lock
(
gralloc_module
,
buffer
->
handle
,
GRALLOC_USAGE_SW_READ_OFTEN
|
GRALLOC_USAGE_SW_WRITE_OFTEN
,
0
,
0
,
buffer
->
width
,
buffer
->
height
,
&
bits
);
ret
=
gralloc_lock
(
buffer
,
&
bits
);
if
(
ret
)
return
android_error_to_status
(
ret
);
memcpy
(
bits
,
win_data
->
mappings
[
res
->
buffer_id
],
buffer
->
stride
*
buffer
->
height
*
4
);
gralloc_
module
->
unlock
(
gralloc_module
,
buffer
->
handle
);
gralloc_
unlock
(
buffer
);
}
wrap_java_call
();
ret
=
parent
->
queueBuffer
(
parent
,
buffer
,
-
1
);
...
...
@@ -1084,11 +1122,7 @@ static void buffer_decRef( struct android_native_base_t *base )
if
(
!
InterlockedDecrement
(
&
buffer
->
ref
))
{
if
(
!
is_in_desktop_process
())
{
if
(
gralloc_module
)
gralloc_module
->
unregisterBuffer
(
gralloc_module
,
buffer
->
buffer
.
handle
);
close_native_handle
(
(
native_handle_t
*
)
buffer
->
buffer
.
handle
);
}
if
(
!
is_in_desktop_process
())
gralloc_release_buffer
(
&
buffer
->
buffer
);
if
(
buffer
->
bits
)
UnmapViewOfFile
(
buffer
->
bits
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
}
...
...
@@ -1140,8 +1174,9 @@ static int dequeueBuffer( struct ANativeWindow *window, struct ANativeWindowBuff
}
else
if
(
!
is_in_desktop_process
())
{
if
((
ret
=
gralloc_module
->
registerBuffer
(
gralloc_module
,
buf
->
buffer
.
handle
))
<
0
)
WARN
(
"hwnd %p, buffer %p failed to register %d %s
\n
"
,
win
->
hwnd
,
&
buf
->
buffer
,
ret
,
strerror
(
-
ret
)
);
if
((
ret
=
gralloc_grab_buffer
(
&
buf
->
buffer
))
<
0
)
WARN
(
"hwnd %p, buffer %p failed to register %d %s
\n
"
,
win
->
hwnd
,
&
buf
->
buffer
,
ret
,
strerror
(
-
ret
)
);
}
}
...
...
@@ -1313,18 +1348,11 @@ static int perform( ANativeWindow *window, int operation, ... )
int
ret
=
window
->
dequeueBuffer_DEPRECATED
(
window
,
&
buffer
);
if
(
!
ret
)
{
if
(
gralloc_module
)
if
(
(
ret
=
gralloc_lock
(
buffer
,
&
buffer_ret
->
bits
))
)
{
if
((
ret
=
gralloc_module
->
lock
(
gralloc_module
,
buffer
->
handle
,
GRALLOC_USAGE_SW_READ_OFTEN
|
GRALLOC_USAGE_SW_WRITE_OFTEN
,
0
,
0
,
buffer
->
width
,
buffer
->
height
,
&
buffer_ret
->
bits
)))
{
WARN
(
"gralloc->lock %p failed %d %s
\n
"
,
win
->
hwnd
,
ret
,
strerror
(
-
ret
)
);
window
->
cancelBuffer
(
window
,
buffer
,
-
1
);
}
WARN
(
"gralloc->lock %p failed %d %s
\n
"
,
win
->
hwnd
,
ret
,
strerror
(
-
ret
)
);
window
->
cancelBuffer
(
window
,
buffer
,
-
1
);
}
else
buffer_ret
->
bits
=
((
struct
native_buffer_wrapper
*
)
buffer
)
->
bits
;
}
if
(
!
ret
)
{
...
...
@@ -1350,7 +1378,7 @@ static int perform( ANativeWindow *window, int operation, ... )
int
ret
=
-
EINVAL
;
if
(
win
->
locked_buffer
)
{
if
(
gralloc_module
)
gralloc_module
->
unlock
(
gralloc_module
,
win
->
locked_buffer
->
handle
);
gralloc_unlock
(
win
->
locked_buffer
);
ret
=
window
->
queueBuffer
(
window
,
win
->
locked_buffer
,
-
1
);
win
->
locked_buffer
=
NULL
;
}
...
...
dlls/wineandroid.drv/init.c
View file @
18ac6bf4
...
...
@@ -450,8 +450,6 @@ DECL_FUNCPTR( ANativeWindow_fromSurface );
DECL_FUNCPTR
(
ANativeWindow_release
);
DECL_FUNCPTR
(
hw_get_module
);
struct
gralloc_module_t
*
gralloc_module
=
NULL
;
#ifndef DT_GNU_HASH
#define DT_GNU_HASH 0x6ffffef5
#endif
...
...
@@ -564,6 +562,7 @@ static int enum_libs( struct dl_phdr_info* info, size_t size, void* data )
static
void
load_hardware_libs
(
void
)
{
const
struct
hw_module_t
*
module
;
int
ret
;
void
*
libhardware
;
char
error
[
256
];
...
...
@@ -589,10 +588,13 @@ static void load_hardware_libs(void)
}
}
if
(
phw_get_module
(
GRALLOC_HARDWARE_MODULE_ID
,
&
module
)
==
0
)
gralloc_module
=
(
struct
gralloc_module_t
*
)
module
;
else
ERR
(
"failed to load gralloc module
\n
"
);
if
((
ret
=
phw_get_module
(
GRALLOC_HARDWARE_MODULE_ID
,
&
module
)))
{
ERR
(
"failed to load gralloc module err %d
\n
"
,
ret
);
return
;
}
init_gralloc
(
module
);
}
static
void
load_android_libs
(
void
)
...
...
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