aboutsummaryrefslogtreecommitdiffstats
path: root/system/OpenglSystemCommon
diff options
context:
space:
mode:
authorLingfeng Yang <lfy@google.com>2020-08-28 00:10:41 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-08-28 00:10:41 +0000
commit2a3bc5d2b88dc41c8f1c61b0d56873e1221a364c (patch)
tree0fd305c920278d8cd24c0f826e8bb0d1e10f89f0 /system/OpenglSystemCommon
parent2c6502082472c5a75bd56918f6af2ba20af0aadf (diff)
parentfa7efc37df3bc3e45f3c3dd63ff4c1d5bf75dc94 (diff)
downloaddevice_generic_goldfish-opengl-2a3bc5d2b88dc41c8f1c61b0d56873e1221a364c.tar.gz
device_generic_goldfish-opengl-2a3bc5d2b88dc41c8f1c61b0d56873e1221a364c.tar.bz2
device_generic_goldfish-opengl-2a3bc5d2b88dc41c8f1c61b0d56873e1221a364c.zip
Merge "intrusive refcount for encoders so we dont need cleanup callback"
Diffstat (limited to 'system/OpenglSystemCommon')
-rw-r--r--system/OpenglSystemCommon/HostConnection.cpp47
-rw-r--r--system/OpenglSystemCommon/HostConnection.h8
2 files changed, 33 insertions, 22 deletions
diff --git a/system/OpenglSystemCommon/HostConnection.cpp b/system/OpenglSystemCommon/HostConnection.cpp
index 260bba88..72632b9d 100644
--- a/system/OpenglSystemCommon/HostConnection.cpp
+++ b/system/OpenglSystemCommon/HostConnection.cpp
@@ -49,6 +49,7 @@ public:
namespace goldfish_vk {
struct VkEncoder {
VkEncoder(IOStream*) { }
+ void decRef() { }
int placeholder;
};
} // namespace goldfish_vk
@@ -346,6 +347,7 @@ public:
{
return ::processPipeInit(connType, rcEnc);
}
+
};
static GoldfishGralloc m_goldfishGralloc;
@@ -373,6 +375,14 @@ HostConnection::~HostConnection()
if (m_rendernodeFdOwned) {
close(m_rendernodeFd);
}
+
+ if (m_vkEnc) {
+ m_vkEnc->decRef();
+ }
+
+ if (m_stream) {
+ m_stream->decRef();
+ }
}
// static
@@ -384,21 +394,20 @@ std::unique_ptr<HostConnection> HostConnection::connect() {
auto con = std::unique_ptr<HostConnection>(new HostConnection);
switch (connType) {
case HOST_CONNECTION_ADDRESS_SPACE: {
- auto stream = std::unique_ptr<AddressSpaceStream>(
- createAddressSpaceStream(STREAM_BUFFER_SIZE));
+ auto stream = createAddressSpaceStream(STREAM_BUFFER_SIZE);
if (!stream) {
ALOGE("Failed to create AddressSpaceStream for host connection!!!\n");
return nullptr;
}
con->m_connectionType = HOST_CONNECTION_ADDRESS_SPACE;
con->m_grallocType = GRALLOC_TYPE_RANCHU;
- con->m_stream = std::move(stream);
+ con->m_stream = stream;
con->m_grallocHelper = &m_goldfishGralloc;
con->m_processPipe = &m_goldfishProcessPipe;
break;
}
case HOST_CONNECTION_QEMU_PIPE: {
- auto stream = std::make_unique<QemuPipeStream>(STREAM_BUFFER_SIZE);
+ auto stream = new QemuPipeStream(STREAM_BUFFER_SIZE);
if (!stream) {
ALOGE("Failed to create QemuPipeStream for host connection!!!\n");
return nullptr;
@@ -409,7 +418,7 @@ std::unique_ptr<HostConnection> HostConnection::connect() {
}
con->m_connectionType = HOST_CONNECTION_QEMU_PIPE;
con->m_grallocType = GRALLOC_TYPE_RANCHU;
- con->m_stream = std::move(stream);
+ con->m_stream = stream;
con->m_grallocHelper = &m_goldfishGralloc;
con->m_processPipe = &m_goldfishProcessPipe;
break;
@@ -420,7 +429,7 @@ std::unique_ptr<HostConnection> HostConnection::connect() {
return nullptr;
break;
#else
- auto stream = std::make_unique<TcpStream>(STREAM_BUFFER_SIZE);
+ auto stream = new TcpStream(STREAM_BUFFER_SIZE);
if (!stream) {
ALOGE("Failed to create TcpStream for host connection!!!\n");
return nullptr;
@@ -432,7 +441,7 @@ std::unique_ptr<HostConnection> HostConnection::connect() {
}
con->m_connectionType = HOST_CONNECTION_TCP;
con->m_grallocType = GRALLOC_TYPE_RANCHU;
- con->m_stream = std::move(stream);
+ con->m_stream = stream;
con->m_grallocHelper = &m_goldfishGralloc;
con->m_processPipe = &m_goldfishProcessPipe;
break;
@@ -440,7 +449,7 @@ std::unique_ptr<HostConnection> HostConnection::connect() {
}
#ifdef VIRTIO_GPU
case HOST_CONNECTION_VIRTIO_GPU: {
- auto stream = std::make_unique<VirtioGpuStream>(STREAM_BUFFER_SIZE);
+ auto stream = new VirtioGpuStream(STREAM_BUFFER_SIZE);
if (!stream) {
ALOGE("Failed to create VirtioGpu for host connection!!!\n");
return nullptr;
@@ -453,7 +462,7 @@ std::unique_ptr<HostConnection> HostConnection::connect() {
con->m_grallocType = GRALLOC_TYPE_MINIGBM;
auto rendernodeFd = stream->getRendernodeFd();
con->m_processPipe = stream->getProcessPipe();
- con->m_stream = std::move(stream);
+ con->m_stream = stream;
con->m_rendernodeFdOwned = false;
con->m_rendernodeFdOwned = rendernodeFd;
MinigbmGralloc* m = new MinigbmGralloc;
@@ -462,8 +471,7 @@ std::unique_ptr<HostConnection> HostConnection::connect() {
break;
}
case HOST_CONNECTION_VIRTIO_GPU_PIPE: {
- auto stream =
- std::make_unique<VirtioGpuPipeStream>(STREAM_BUFFER_SIZE);
+ auto stream = new VirtioGpuPipeStream(STREAM_BUFFER_SIZE);
if (!stream) {
ALOGE("Failed to create VirtioGpu for host connection!!!\n");
return nullptr;
@@ -476,7 +484,7 @@ std::unique_ptr<HostConnection> HostConnection::connect() {
con->m_grallocType = getGrallocTypeFromProperty();
con->m_rendernodeFdOwned = false;
auto rendernodeFd = stream->getRendernodeFd();
- con->m_stream = std::move(stream);
+ con->m_stream = stream;
con->m_rendernodeFd = rendernodeFd;
switch (con->m_grallocType) {
case GRALLOC_TYPE_RANCHU:
@@ -497,8 +505,7 @@ std::unique_ptr<HostConnection> HostConnection::connect() {
}
#if !defined(HOST_BUILD) && !defined(__Fuchsia__)
case HOST_CONNECTION_VIRTIO_GPU_ADDRESS_SPACE: {
- auto stream = std::unique_ptr<AddressSpaceStream>(
- createVirtioGpuAddressSpaceStream(STREAM_BUFFER_SIZE));
+ auto stream = createVirtioGpuAddressSpaceStream(STREAM_BUFFER_SIZE);
if (!stream) {
ALOGE("Failed to create virtgpu AddressSpaceStream for host connection!!!\n");
return nullptr;
@@ -507,7 +514,7 @@ std::unique_ptr<HostConnection> HostConnection::connect() {
con->m_grallocType = getGrallocTypeFromProperty();
con->m_rendernodeFdOwned = false;
auto rendernodeFd = stream->getRendernodeFd();
- con->m_stream = std::move(stream);
+ con->m_stream = stream;
con->m_rendernodeFd = rendernodeFd;
switch (con->m_grallocType) {
case GRALLOC_TYPE_RANCHU:
@@ -581,7 +588,7 @@ std::unique_ptr<HostConnection> HostConnection::createUnique() {
GLEncoder *HostConnection::glEncoder()
{
if (!m_glEnc) {
- m_glEnc = std::make_unique<GLEncoder>(m_stream.get(), checksumHelper());
+ m_glEnc = std::make_unique<GLEncoder>(m_stream, checksumHelper());
DBG("HostConnection::glEncoder new encoder %p, tid %d",
m_glEnc, getCurrentThreadId());
m_glEnc->setContextAccessor(s_getGLContext);
@@ -593,7 +600,7 @@ GL2Encoder *HostConnection::gl2Encoder()
{
if (!m_gl2Enc) {
m_gl2Enc =
- std::make_unique<GL2Encoder>(m_stream.get(), checksumHelper());
+ std::make_unique<GL2Encoder>(m_stream, checksumHelper());
DBG("HostConnection::gl2Encoder new encoder %p, tid %d",
m_gl2Enc, getCurrentThreadId());
m_gl2Enc->setContextAccessor(s_getGL2Context);
@@ -608,15 +615,15 @@ GL2Encoder *HostConnection::gl2Encoder()
VkEncoder *HostConnection::vkEncoder()
{
if (!m_vkEnc) {
- m_vkEnc = std::make_unique<VkEncoder>(m_stream.get());
+ m_vkEnc = new VkEncoder(m_stream);
}
- return m_vkEnc.get();
+ return m_vkEnc;
}
ExtendedRCEncoderContext *HostConnection::rcEncoder()
{
if (!m_rcEnc) {
- m_rcEnc = std::make_unique<ExtendedRCEncoderContext>(m_stream.get(),
+ m_rcEnc = std::make_unique<ExtendedRCEncoderContext>(m_stream,
checksumHelper());
ExtendedRCEncoderContext* rcEnc = m_rcEnc.get();
diff --git a/system/OpenglSystemCommon/HostConnection.h b/system/OpenglSystemCommon/HostConnection.h
index 27cb5ada..32a1521f 100644
--- a/system/OpenglSystemCommon/HostConnection.h
+++ b/system/OpenglSystemCommon/HostConnection.h
@@ -222,10 +222,14 @@ private:
HostConnectionType m_connectionType;
GrallocType m_grallocType;
- std::unique_ptr<IOStream> m_stream;
+ // intrusively refcounted
+ IOStream* m_stream = nullptr;
+
std::unique_ptr<GLEncoder> m_glEnc;
std::unique_ptr<GL2Encoder> m_gl2Enc;
- std::unique_ptr<goldfish_vk::VkEncoder> m_vkEnc;
+
+ // intrusively refcounted
+ goldfish_vk::VkEncoder* m_vkEnc = nullptr;
std::unique_ptr<ExtendedRCEncoderContext> m_rcEnc;
ChecksumCalculator m_checksumHelper;