Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
goldfish-opengl
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test
device
generic
goldfish-opengl
Commits
6d62288e
Commit
6d62288e
authored
6 years ago
by
Lingfeng Yang
Committed by
Huan Song
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
single host connection per gralloc process
reduce jank Change-Id: I158dbf5e43e9413c40332c831409431f7f35ae42
parent
f344f4fd
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
system/gralloc/gralloc.cpp
+36
-7
36 additions, 7 deletions
system/gralloc/gralloc.cpp
with
36 additions
and
7 deletions
system/gralloc/gralloc.cpp
+
36
−
7
View file @
6d62288e
...
...
@@ -331,12 +331,21 @@ static int map_buffer(cb_handle_t *cb, void **vaddr)
return
0
;
}
static
HostConnection
*
sHostCon
=
NULL
;
static
HostConnection
*
createOrGetHostConnection
()
{
if
(
!
sHostCon
)
{
sHostCon
=
HostConnection
::
createUnique
();
}
return
sHostCon
;
}
#define DEFINE_HOST_CONNECTION \
HostConnection *hostCon = HostConnection
::get
(); \
HostConnection *hostCon =
createOrGet
HostConnection(); \
ExtendedRCEncoderContext *rcEnc = (hostCon ? hostCon->rcEncoder() : NULL)
#define DEFINE_AND_VALIDATE_HOST_CONNECTION \
HostConnection *hostCon = HostConnection
::get
(); \
HostConnection *hostCon =
createOrGet
HostConnection(); \
if (!hostCon) { \
ALOGE("gralloc: Failed to get host connection\n"); \
return -EIO; \
...
...
@@ -351,7 +360,6 @@ static int map_buffer(cb_handle_t *cb, void **vaddr)
if (hostCon && hostCon->isGrallocOnly()) { \
ALOGD("%s: exiting HostConnection (is buffer-handling thread)", \
__FUNCTION__); \
HostConnection::exit(); \
}
#if PLATFORM_SDK_VERSION < 18
...
...
@@ -719,6 +727,8 @@ static int gralloc_alloc(alloc_device_t* dev,
cb
->
setFd
(
fd
);
hostCon
->
lock
();
if
(
rcEnc
->
getDmaVersion
()
>
0
)
{
D
(
"%s: creating goldfish dma region of size %lu (cb fd %d)
\n
"
,
__FUNCTION__
,
ashmem_size
,
cb
->
fd
);
init_gralloc_dmaregion
();
...
...
@@ -726,6 +736,7 @@ static int gralloc_alloc(alloc_device_t* dev,
}
else
{
cb
->
goldfish_dma
.
fd
=
-
1
;
}
hostCon
->
unlock
();
}
else
{
cb
->
goldfish_dma
.
fd
=
-
1
;
}
...
...
@@ -741,11 +752,13 @@ static int gralloc_alloc(alloc_device_t* dev,
if
(
HAL_PIXEL_FORMAT_RGBX_8888
==
format
)
{
allocFormat
=
GL_RGB
;
}
hostCon
->
lock
();
if
(
s_grdma
)
{
cb
->
hostHandle
=
rcEnc
->
rcCreateColorBufferDMA
(
rcEnc
,
w
,
h
,
allocFormat
,
cb
->
emuFrameworkFormat
);
}
else
{
cb
->
hostHandle
=
rcEnc
->
rcCreateColorBuffer
(
rcEnc
,
w
,
h
,
allocFormat
);
}
hostCon
->
unlock
();
}
if
(
!
cb
->
hostHandle
)
{
...
...
@@ -817,7 +830,9 @@ static int gralloc_free(alloc_device_t* dev,
if
(
*
openCountPtr
>
0
)
{
DEFINE_AND_VALIDATE_HOST_CONNECTION
;
D
(
"Closing host ColorBuffer 0x%x
\n
"
,
cb
->
hostHandle
);
hostCon
->
lock
();
rcEnc
->
rcCloseColorBuffer
(
rcEnc
,
cb
->
hostHandle
);
hostCon
->
unlock
();
}
else
{
D
(
"A rcCloseColorBuffer is owed!!! sdk ver: %d"
,
PLATFORM_SDK_VERSION
);
*
openCountPtr
=
-
1
;
...
...
@@ -916,8 +931,10 @@ static int fb_post(struct framebuffer_device_t* dev, buffer_handle_t buffer)
(
*
postCountPtr
)
++
;
// send post request to host
hostCon
->
lock
();
rcEnc
->
rcFBPost
(
rcEnc
,
cb
->
hostHandle
);
hostCon
->
flush
();
hostCon
->
unlock
();
return
0
;
}
...
...
@@ -959,8 +976,10 @@ static int fb_setSwapInterval(struct framebuffer_device_t* dev,
DEFINE_AND_VALIDATE_HOST_CONNECTION
;
// send request to host
hostCon
->
lock
();
rcEnc
->
rcFBSetSwapInterval
(
rcEnc
,
interval
);
hostCon
->
flush
();
hostCon
->
unlock
();
return
0
;
}
...
...
@@ -1002,7 +1021,9 @@ static int gralloc_register_buffer(gralloc_module_t const* module,
if
(
cb
->
hostHandle
!=
0
&&
!
cb
->
hasRefcountPipe
())
{
DEFINE_AND_VALIDATE_HOST_CONNECTION
;
D
(
"Opening host ColorBuffer 0x%x
\n
"
,
cb
->
hostHandle
);
hostCon
->
lock
();
rcEnc
->
rcOpenColorBuffer2
(
rcEnc
,
cb
->
hostHandle
);
hostCon
->
unlock
();
}
//
...
...
@@ -1024,10 +1045,12 @@ static int gralloc_register_buffer(gralloc_module_t const* module,
}
DEFINE_AND_VALIDATE_HOST_CONNECTION
;
hostCon
->
lock
();
if
(
rcEnc
->
getDmaVersion
()
>
0
)
{
init_gralloc_dmaregion
();
gralloc_dmaregion_register_ashmem
(
cb
->
ashmemSize
);
}
hostCon
->
unlock
();
}
...
...
@@ -1058,6 +1081,7 @@ static int gralloc_unregister_buffer(gralloc_module_t const* module,
if
(
cb
->
hostHandle
&&
!
cb
->
hasRefcountPipe
())
{
D
(
"Closing host ColorBuffer 0x%x
\n
"
,
cb
->
hostHandle
);
DEFINE_AND_VALIDATE_HOST_CONNECTION
;
hostCon
->
lock
();
rcEnc
->
rcCloseColorBuffer
(
rcEnc
,
cb
->
hostHandle
);
if
(
isHidlGralloc
)
{
...
...
@@ -1072,6 +1096,7 @@ static int gralloc_unregister_buffer(gralloc_module_t const* module,
}
}
}
hostCon
->
unlock
();
EXIT_GRALLOCONLY_HOST_CONNECTION
;
}
...
...
@@ -1087,7 +1112,6 @@ static int gralloc_unregister_buffer(gralloc_module_t const* module,
if
(
!
SHOULD_UNMAP
)
goto
done
;
DEFINE_AND_VALIDATE_HOST_CONNECTION
;
void
*
vaddr
;
int
err
=
munmap
((
void
*
)
cb
->
ashmemBase
,
cb
->
ashmemSize
);
...
...
@@ -1098,7 +1122,6 @@ static int gralloc_unregister_buffer(gralloc_module_t const* module,
cb
->
ashmemBase
=
0
;
cb
->
mappedPid
=
0
;
D
(
"%s: Unregister buffer previous mapped to pid %d"
,
__FUNCTION__
,
getpid
());
EXIT_GRALLOCONLY_HOST_CONNECTION
;
}
done
:
...
...
@@ -1191,6 +1214,7 @@ static int gralloc_lock(gralloc_module_t const* module,
if
(
cb
->
hostHandle
)
{
// Make sure we have host connection
DEFINE_AND_VALIDATE_HOST_CONNECTION
;
hostCon
->
lock
();
//
// flush color buffer write cache on host and get its sync status.
...
...
@@ -1228,6 +1252,7 @@ static int gralloc_lock(gralloc_module_t const* module,
delete
[]
tmpBuf
;
}
}
hostCon
->
unlock
();
}
//
...
...
@@ -1276,6 +1301,7 @@ static int gralloc_unlock(gralloc_module_t const* module,
// Make sure we have host connection
DEFINE_AND_VALIDATE_HOST_CONNECTION
;
hostCon
->
lock
();
void
*
cpu_addr
=
(
void
*
)(
cb
->
ashmemBase
+
getAshmemColorOffset
(
cb
));
...
...
@@ -1287,6 +1313,7 @@ static int gralloc_unlock(gralloc_module_t const* module,
updateHostColorBuffer
(
cb
,
false
,
rgb_addr
);
}
hostCon
->
unlock
();
DD
(
"gralloc_unlock success. cpu_addr: %p"
,
cpu_addr
);
}
...
...
@@ -1423,8 +1450,8 @@ static int gralloc_device_open(const hw_module_t* module,
// Create host connection and keep it in the TLS.
// return error if connection with host can not be established
HostConnection
*
hostCon
=
HostConnection
::
get
();
if
(
!
hostCon
)
{
HostConnection
*
hostCon
n
=
createOrGet
HostConnection
();
if
(
!
hostCon
n
)
{
ALOGE
(
"gralloc: failed to get host connection while opening %s
\n
"
,
name
);
return
-
EIO
;
}
...
...
@@ -1458,6 +1485,7 @@ static int gralloc_device_open(const hw_module_t* module,
// return error if connection with host can not be established
DEFINE_AND_VALIDATE_HOST_CONNECTION
;
hostCon
->
lock
();
//
// Query the host for Framebuffer attributes
...
...
@@ -1477,6 +1505,7 @@ static int gralloc_device_open(const hw_module_t* module,
D
(
"gralloc: min_swap=%d
\n
"
,
min_si
);
EGLint
max_si
=
rcEnc
->
rcGetFBParam
(
rcEnc
,
FB_MAX_SWAP_INTERVAL
);
D
(
"gralloc: max_swap=%d
\n
"
,
max_si
);
hostCon
->
unlock
();
//
// Allocate memory for the framebuffer device
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment