From aeff6e35df483f39919170c018b5c5fb044f71ef Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Wed, 21 Dec 2016 08:38:55 +0100 Subject: [PATCH] Cleanup formatting and code style --- android/service/local_socket_connection.cpp | 6 +++ android/service/local_socket_connection.h | 1 + src/anbox/graphics/emugl/RenderControl.cpp | 22 ++++++--- src/anbox/graphics/emugl/RenderThread.cpp | 46 ++++++------------- src/anbox/graphics/emugl/RenderThreadInfo.cpp | 4 +- 5 files changed, 38 insertions(+), 41 deletions(-) diff --git a/android/service/local_socket_connection.cpp b/android/service/local_socket_connection.cpp index f5d090a4..aa8567ae 100644 --- a/android/service/local_socket_connection.cpp +++ b/android/service/local_socket_connection.cpp @@ -75,4 +75,10 @@ void LocalSocketConnection::send(char const* data, size_t length) { bytes_written += result; } } + +ssize_t LocalSocketConnection::send_raw(char const* data, size_t length) { + (void)data; + (void)length; + return -EIO; +} } // namespace anbox diff --git a/android/service/local_socket_connection.h b/android/service/local_socket_connection.h index eddad1b9..ce84a52a 100644 --- a/android/service/local_socket_connection.h +++ b/android/service/local_socket_connection.h @@ -32,6 +32,7 @@ public: ssize_t read_all(std::uint8_t *buffer, const size_t &size); void send(char const* data, size_t length) override; + ssize_t send_raw(char const* data, size_t length) override; private: Fd fd_; diff --git a/src/anbox/graphics/emugl/RenderControl.cpp b/src/anbox/graphics/emugl/RenderControl.cpp index eba7e431..9527c5be 100644 --- a/src/anbox/graphics/emugl/RenderControl.cpp +++ b/src/anbox/graphics/emugl/RenderControl.cpp @@ -363,30 +363,36 @@ static void rcSelectChecksumCalculator(uint32_t protocol, uint32_t reserved) { ChecksumCalculatorThreadInfo::setVersion(protocol); } -int rcGetNumDisplays() { return 1; } +int rcGetNumDisplays() { + // For now we only support a single display but that single display + // will contain more than one display so that we simply spawn up a big + // virtual display which should match the real display arrangement + // in most cases. + return 1; +} int rcGetDisplayWidth(uint32_t display_id) { - printf("%s: display_id=%d\n", __func__, display_id); + (void)display_id; return DisplayManager::get()->display_info().horizontal_resolution; } int rcGetDisplayHeight(uint32_t display_id) { - printf("%s: display_id=%d\n", __func__, display_id); + (void)display_id; return DisplayManager::get()->display_info().vertical_resolution; } int rcGetDisplayDpiX(uint32_t display_id) { - printf("%s: display_id=%d\n", __func__, display_id); + (void)display_id; return 120; } int rcGetDisplayDpiY(uint32_t display_id) { - printf("%s: display_id=%d\n", __func__, display_id); + (void)display_id; return 120; } int rcGetDisplayVsyncPeriod(uint32_t display_id) { - printf("%s: display_id=%d\n", __func__, display_id); + (void)display_id; return 1; } @@ -394,6 +400,10 @@ static std::vector frame_layers; bool is_layer_blacklisted(const std::string &name) { static std::vector blacklist = { + // The 'Sprite' layer is the mouse cursor Android uses as soon + // as it has a pointer input device available. We don't want to + // display this layer at all but don't have a good way of disabling + // the cursor on the Android side yet. "Sprite", }; return std::find(blacklist.begin(), blacklist.end(), name) != blacklist.end(); diff --git a/src/anbox/graphics/emugl/RenderThread.cpp b/src/anbox/graphics/emugl/RenderThread.cpp index 71e5986d..60430300 100644 --- a/src/anbox/graphics/emugl/RenderThread.cpp +++ b/src/anbox/graphics/emugl/RenderThread.cpp @@ -26,6 +26,8 @@ #include "OpenGLESDispatch/GLESv1Dispatch.h" #include "OpenGLESDispatch/GLESv2Dispatch.h" +#include "anbox/logger.h" + #define STREAM_BUFFER_SIZE 4 * 1024 * 1024 RenderThread::RenderThread(IOStream *stream, emugl::Mutex *lock) @@ -33,7 +35,6 @@ RenderThread::RenderThread(IOStream *stream, emugl::Mutex *lock) RenderThread::~RenderThread() {} -// static RenderThread *RenderThread::create(IOStream *stream, emugl::Mutex *lock) { return new RenderThread(stream, lock); } @@ -41,54 +42,40 @@ RenderThread *RenderThread::create(IOStream *stream, emugl::Mutex *lock) { void RenderThread::forceStop() { m_stream->forceStop(); } intptr_t RenderThread::main() { - RenderThreadInfo tInfo; - ChecksumCalculatorThreadInfo tChecksumInfo; + RenderThreadInfo threadInfo; + ChecksumCalculatorThreadInfo threadChecksumInfo; - // - // initialize decoders - // - tInfo.m_glDec.initGL(gles1_dispatch_get_proc_func, NULL); - tInfo.m_gl2Dec.initGL(gles2_dispatch_get_proc_func, NULL); - initRenderControlContext(&tInfo.m_rcDec); + threadInfo.m_glDec.initGL(gles1_dispatch_get_proc_func, NULL); + threadInfo.m_gl2Dec.initGL(gles2_dispatch_get_proc_func, NULL); + initRenderControlContext(&threadInfo.m_rcDec); ReadBuffer readBuf(STREAM_BUFFER_SIZE); - while (1) { + while (true) { int stat = readBuf.getData(m_stream); - if (stat <= 0) { + if (stat <= 0) break; - } bool progress; do { progress = false; m_lock->lock(); - // - // try to process some of the command buffer using the GLESv1 decoder - // size_t last = - tInfo.m_glDec.decode(readBuf.buf(), readBuf.validData(), m_stream); + threadInfo.m_glDec.decode(readBuf.buf(), readBuf.validData(), m_stream); if (last > 0) { progress = true; readBuf.consume(last); } - // - // try to process some of the command buffer using the GLESv2 decoder - // last = - tInfo.m_gl2Dec.decode(readBuf.buf(), readBuf.validData(), m_stream); + threadInfo.m_gl2Dec.decode(readBuf.buf(), readBuf.validData(), m_stream); if (last > 0) { progress = true; readBuf.consume(last); } - // - // try to process some of the command buffer using the - // renderControl decoder - // - last = tInfo.m_rcDec.decode(readBuf.buf(), readBuf.validData(), m_stream); + last = threadInfo.m_rcDec.decode(readBuf.buf(), readBuf.validData(), m_stream); if (last > 0) { readBuf.consume(last); progress = true; @@ -99,17 +86,12 @@ intptr_t RenderThread::main() { } while (progress); } - // // Release references to the current thread's context/surfaces if any - // Renderer::get()->bindContext(0, 0, 0); - if (tInfo.currContext || tInfo.currDrawSurf || tInfo.currReadSurf) { - fprintf(stderr, - "ERROR: RenderThread exiting with current context/surfaces\n"); - } + if (threadInfo.currContext || threadInfo.currDrawSurf || threadInfo.currReadSurf) + ERROR("RenderThread exiting with current context/surfaces"); Renderer::get()->drainWindowSurface(); - Renderer::get()->drainRenderContext(); return 0; diff --git a/src/anbox/graphics/emugl/RenderThreadInfo.cpp b/src/anbox/graphics/emugl/RenderThreadInfo.cpp index 69c9f99a..500a0b47 100644 --- a/src/anbox/graphics/emugl/RenderThreadInfo.cpp +++ b/src/anbox/graphics/emugl/RenderThreadInfo.cpp @@ -20,13 +20,11 @@ #include "emugl/common/thread_store.h" namespace { - class ThreadInfoStore : public ::emugl::ThreadStore { public: ThreadInfoStore() : ::emugl::ThreadStore(NULL) {} }; - -} // namespace +} static ::emugl::LazyInstance s_tls = LAZY_INSTANCE_INIT; -- GitLab