diff --git a/external/android-emugl/CMakeLists.txt b/external/android-emugl/CMakeLists.txt index f515bf4f49f4dcd4e2b0e4e28c66656c87a0f997..dcaccc7430d8c048c59a2fb9b007fcd3ff57d755 100644 --- a/external/android-emugl/CMakeLists.txt +++ b/external/android-emugl/CMakeLists.txt @@ -14,7 +14,9 @@ include_directories( ${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs/GLESv2_dec ${CMAKE_BINARY_DIR}/external/android-emugl/host/libs/GLESv2_dec ${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs/renderControl_dec - ${CMAKE_BINARY_DIR}/external/android-emugl/host/libs/renderControl_dec) + ${CMAKE_BINARY_DIR}/external/android-emugl/host/libs/renderControl_dec + ${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs/Translator/include + ${MIRCLIENT_INCLUDE_DIRS}) add_subdirectory(host) add_subdirectory(shared) diff --git a/external/android-emugl/host/include/OpenglRender/render_api_functions.h b/external/android-emugl/host/include/OpenglRender/render_api_functions.h index d55bc2b1480e72736539ba52b1819cac1c7a186c..b68deee44400b8f2e42fe215badc2ebdc2f84a55 100644 --- a/external/android-emugl/host/include/OpenglRender/render_api_functions.h +++ b/external/android-emugl/host/include/OpenglRender/render_api_functions.h @@ -10,6 +10,8 @@ #include #include +#include + /* list of constants to be passed to setStreamMode */ #define RENDER_API_STREAM_MODE_DEFAULT 0 #define RENDER_API_STREAM_MODE_TCP 1 @@ -23,7 +25,7 @@ typedef void (*emugl_crash_func_t)(const char* format, ...); #define LIST_RENDER_API_FUNCTIONS(X) \ X(int, initLibrary, (), ()) \ X(int, setStreamMode, (int mode), (mode)) \ - X(int, initOpenGLRenderer, (int width, int height, bool useSubWindow, char* addr, size_t addrLen, emugl_logger_struct logfuncs, emugl_crash_func_t crashfunc), (width, height, useSubWindow, addr, addrLen, logfuncs, crashfunc)) \ + X(int, initOpenGLRenderer, (EGLNativeDisplayType native_display, int width, int height, bool useSubWindow, char* addr, size_t addrLen, emugl_logger_struct logfuncs, emugl_crash_func_t crashfunc), (width, height, useSubWindow, addr, addrLen, logfuncs, crashfunc)) \ X(void, getHardwareStrings, (const char** vendor, const char** renderer, const char** version), (vendor, renderer, version)) \ X(void, setPostCallback, (OnPostFn onPost, void* onPostContext), (onPost, onPostContext)) \ X(bool, showOpenGLSubwindow, (FBNativeWindowType window, int wx, int wy, int ww, int wh, int fbw, int fbh, float dpr, float zRot), (window, wx, wy, ww, wh, fbw, fbh, dpr, zRot)) \ diff --git a/external/android-emugl/host/libs/libOpenglRender/FrameBuffer.cpp b/external/android-emugl/host/libs/libOpenglRender/FrameBuffer.cpp index d7f3f06be269989fd22c138a3ceb0c96f362b07a..bff43b34c3b29775c03da34c9663d7e00c407750 100644 --- a/external/android-emugl/host/libs/libOpenglRender/FrameBuffer.cpp +++ b/external/android-emugl/host/libs/libOpenglRender/FrameBuffer.cpp @@ -165,7 +165,7 @@ void FrameBuffer::finalize(){ s_egl.eglDestroySurface(m_eglDisplay, m_pbufSurface); } -bool FrameBuffer::initialize(int width, int height, bool useSubWindow) +bool FrameBuffer::initialize(EGLNativeDisplayType nativeDisplay, int width, int height, bool useSubWindow) { GL_LOG("FrameBuffer::initialize"); if (s_theFrameBuffer != NULL) { @@ -184,7 +184,7 @@ bool FrameBuffer::initialize(int width, int height, bool useSubWindow) // // Initialize backend EGL display // - fb->m_eglDisplay = s_egl.eglGetDisplay(EGL_DEFAULT_DISPLAY); + fb->m_eglDisplay = s_egl.eglGetDisplay(nativeDisplay); if (fb->m_eglDisplay == EGL_NO_DISPLAY) { ERR("Failed to Initialize backend EGL display\n"); delete fb; diff --git a/external/android-emugl/host/libs/libOpenglRender/FrameBuffer.h b/external/android-emugl/host/libs/libOpenglRender/FrameBuffer.h index 77a2705b29cc4fd09773660be9b0f004bb48daf4..b581a4446e04daf84a949d3c2e5a57963ab6f6d7 100644 --- a/external/android-emugl/host/libs/libOpenglRender/FrameBuffer.h +++ b/external/android-emugl/host/libs/libOpenglRender/FrameBuffer.h @@ -74,7 +74,7 @@ public: // own sub-windows. If false, this means the caller will use // setPostCallback() instead to retrieve the content. // Returns true on success, false otherwise. - static bool initialize(int width, int height, bool useSubWindow); + static bool initialize(EGLNativeDisplayType nativeDisplay, int width, int height, bool useSubWindow); // Setup a sub-window to display the content of the emulated GPU // on-top of an existing UI window. |p_window| is the platform-specific diff --git a/external/android-emugl/host/libs/libOpenglRender/RenderWindow.cpp b/external/android-emugl/host/libs/libOpenglRender/RenderWindow.cpp index bbfaa5e147c5cf68d5b1dd068174c7a9115d07c6..ced43deb9811a92e9883955ec8c325c78f19d640 100644 --- a/external/android-emugl/host/libs/libOpenglRender/RenderWindow.cpp +++ b/external/android-emugl/host/libs/libOpenglRender/RenderWindow.cpp @@ -72,6 +72,7 @@ struct RenderWindowMessage { union { // CMD_INITIALIZE struct { + EGLNativeDisplayType nativeDisplay; int width; int height; bool useSubWindow; @@ -120,7 +121,8 @@ struct RenderWindowMessage { D("CMD_INITIALIZE w=%d h=%d\n", msg.init.width, msg.init.height); GL_LOG("RenderWindow: CMD_INITIALIZE w=%d h=%d", msg.init.width, msg.init.height); - result = FrameBuffer::initialize(msg.init.width, + result = FrameBuffer::initialize(msg.init.nativeDisplay, + msg.init.width, msg.init.height, msg.init.useSubWindow); break; @@ -312,7 +314,8 @@ private: } // namespace -RenderWindow::RenderWindow(int width, +RenderWindow::RenderWindow(EGLNativeDisplayType native_display, + int width, int height, bool use_thread, bool use_sub_window) : @@ -328,6 +331,7 @@ RenderWindow::RenderWindow(int width, RenderWindowMessage msg; msg.cmd = CMD_INITIALIZE; + msg.init.nativeDisplay = native_display; msg.init.width = width; msg.init.height = height; msg.init.useSubWindow = use_sub_window; diff --git a/external/android-emugl/host/libs/libOpenglRender/RenderWindow.h b/external/android-emugl/host/libs/libOpenglRender/RenderWindow.h index ab0361916e2386989bcfe28b86efd75efde492b1..1443688632a3854859e53b65400c528c5092664f 100644 --- a/external/android-emugl/host/libs/libOpenglRender/RenderWindow.h +++ b/external/android-emugl/host/libs/libOpenglRender/RenderWindow.h @@ -59,7 +59,7 @@ public: // // Note that this call doesn't display anything, it just initializes // the library, use setupSubWindow() to display something. - RenderWindow(int width, int height, bool use_thread, bool use_sub_window); + RenderWindow(EGLNativeDisplayType native_display, int width, int height, bool use_thread, bool use_sub_window); // Destructor. This will automatically call removeSubWindow() is needed. ~RenderWindow(); diff --git a/external/android-emugl/host/libs/libOpenglRender/render_api.cpp b/external/android-emugl/host/libs/libOpenglRender/render_api.cpp index 970477ce1d48da6d81898cd91c0ee94b04b1a9e9..228119f1b07ab4a48a2b0b4f27fbcb29e07531db 100644 --- a/external/android-emugl/host/libs/libOpenglRender/render_api.cpp +++ b/external/android-emugl/host/libs/libOpenglRender/render_api.cpp @@ -78,6 +78,7 @@ RENDER_APICALL int RENDER_APIENTRY initLibrary(void) } RENDER_APICALL int RENDER_APIENTRY initOpenGLRenderer( + EGLNativeDisplayType native_display, int width, int height, bool useSubWindow, char* addr, size_t addrLen, emugl_logger_struct logfuncs, emugl_crash_func_t crashfunc) { set_emugl_crash_reporter(crashfunc); @@ -116,7 +117,7 @@ RENDER_APICALL int RENDER_APIENTRY initOpenGLRenderer( // initialize the renderer and listen to connections // on a thread in the current process. // - s_renderWindow = new RenderWindow(width, height, kUseThread, useSubWindow); + s_renderWindow = new RenderWindow(native_display, width, height, kUseThread, useSubWindow); if (!s_renderWindow) { ERR("Could not create rendering window class"); GL_LOG("Could not create rendering window class"); diff --git a/src/anbox/graphics/gl_renderer_server.cpp b/src/anbox/graphics/gl_renderer_server.cpp index c2598eb4136d7aa8543b137a18eba21e97497a6d..0d8ed185c738fa1791e9940813717452f6a89ce1 100644 --- a/src/anbox/graphics/gl_renderer_server.cpp +++ b/src/anbox/graphics/gl_renderer_server.cpp @@ -72,7 +72,7 @@ void GLRendererServer::start() { // The width & height we supply here are the dimensions the internal framebuffer // will use. Making this static prevents us for now to resize the window we create // later for the actual display. - if (!initOpenGLRenderer(width, height, true, server_addr, sizeof(server_addr), log_funcs, logger_write)) + if (!initOpenGLRenderer(window_creator_->native_display(), width, height, true, server_addr, sizeof(server_addr), log_funcs, logger_write)) BOOST_THROW_EXCEPTION(std::runtime_error("Failed to setup OpenGL renderer")); socket_path_ = server_addr; diff --git a/src/anbox/graphics/window_creator.h b/src/anbox/graphics/window_creator.h index ab0578a5aa0a76cbe84927bd702355b8a95223af..00cd8be50a645a8238b2ada5adf464a215c12e85 100644 --- a/src/anbox/graphics/window_creator.h +++ b/src/anbox/graphics/window_creator.h @@ -36,6 +36,7 @@ public: }; virtual DisplayInfo display_info() const = 0; + virtual EGLNativeDisplayType native_display() const = 0; protected: std::shared_ptr input_manager_; diff --git a/src/anbox/ubuntu/window_creator.cpp b/src/anbox/ubuntu/window_creator.cpp index 4fd77ec0f82bb5a816a298dc47f9f22a22ec1485..b222f4d5841ce49c51e3ba2d959dc56b492853fe 100644 --- a/src/anbox/ubuntu/window_creator.cpp +++ b/src/anbox/ubuntu/window_creator.cpp @@ -54,5 +54,9 @@ void WindowCreator::destroy_window(EGLNativeWindowType win) { WindowCreator::DisplayInfo WindowCreator::display_info() const { return {display_->horizontal_resolution(), display_->vertical_resolution()}; } + +EGLNativeDisplayType WindowCreator::native_display() const { + return display_->native_display(); +} } // namespace bridge } // namespace anbox diff --git a/src/anbox/ubuntu/window_creator.h b/src/anbox/ubuntu/window_creator.h index 60a2f8de2b1a1a00aa8773ec018295b88a61cdcb..b980cb3f9f42465caced548f3ad7906c94c91070 100644 --- a/src/anbox/ubuntu/window_creator.h +++ b/src/anbox/ubuntu/window_creator.h @@ -37,6 +37,7 @@ public: void destroy_window(EGLNativeWindowType win) override; DisplayInfo display_info() const override; + EGLNativeDisplayType native_display() const override; private: std::shared_ptr input_manager_;