提交 5ee8c02b 编写于 作者: S Simon Fels

Hand EGL native display into renderer to not use default display

上级 6c15fb98
...@@ -14,7 +14,9 @@ include_directories( ...@@ -14,7 +14,9 @@ include_directories(
${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs/GLESv2_dec ${CMAKE_SOURCE_DIR}/external/android-emugl/host/libs/GLESv2_dec
${CMAKE_BINARY_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_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(host)
add_subdirectory(shared) add_subdirectory(shared)
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <EGL/egl.h>
/* list of constants to be passed to setStreamMode */ /* list of constants to be passed to setStreamMode */
#define RENDER_API_STREAM_MODE_DEFAULT 0 #define RENDER_API_STREAM_MODE_DEFAULT 0
#define RENDER_API_STREAM_MODE_TCP 1 #define RENDER_API_STREAM_MODE_TCP 1
...@@ -23,7 +25,7 @@ typedef void (*emugl_crash_func_t)(const char* format, ...); ...@@ -23,7 +25,7 @@ typedef void (*emugl_crash_func_t)(const char* format, ...);
#define LIST_RENDER_API_FUNCTIONS(X) \ #define LIST_RENDER_API_FUNCTIONS(X) \
X(int, initLibrary, (), ()) \ X(int, initLibrary, (), ()) \
X(int, setStreamMode, (int mode), (mode)) \ 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, getHardwareStrings, (const char** vendor, const char** renderer, const char** version), (vendor, renderer, version)) \
X(void, setPostCallback, (OnPostFn onPost, void* onPostContext), (onPost, onPostContext)) \ 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)) \ 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)) \
......
...@@ -165,7 +165,7 @@ void FrameBuffer::finalize(){ ...@@ -165,7 +165,7 @@ void FrameBuffer::finalize(){
s_egl.eglDestroySurface(m_eglDisplay, m_pbufSurface); 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"); GL_LOG("FrameBuffer::initialize");
if (s_theFrameBuffer != NULL) { if (s_theFrameBuffer != NULL) {
...@@ -184,7 +184,7 @@ bool FrameBuffer::initialize(int width, int height, bool useSubWindow) ...@@ -184,7 +184,7 @@ bool FrameBuffer::initialize(int width, int height, bool useSubWindow)
// //
// Initialize backend EGL display // 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) { if (fb->m_eglDisplay == EGL_NO_DISPLAY) {
ERR("Failed to Initialize backend EGL display\n"); ERR("Failed to Initialize backend EGL display\n");
delete fb; delete fb;
......
...@@ -74,7 +74,7 @@ public: ...@@ -74,7 +74,7 @@ public:
// own sub-windows. If false, this means the caller will use // own sub-windows. If false, this means the caller will use
// setPostCallback() instead to retrieve the content. // setPostCallback() instead to retrieve the content.
// Returns true on success, false otherwise. // 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 // 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 // on-top of an existing UI window. |p_window| is the platform-specific
......
...@@ -72,6 +72,7 @@ struct RenderWindowMessage { ...@@ -72,6 +72,7 @@ struct RenderWindowMessage {
union { union {
// CMD_INITIALIZE // CMD_INITIALIZE
struct { struct {
EGLNativeDisplayType nativeDisplay;
int width; int width;
int height; int height;
bool useSubWindow; bool useSubWindow;
...@@ -120,7 +121,8 @@ struct RenderWindowMessage { ...@@ -120,7 +121,8 @@ struct RenderWindowMessage {
D("CMD_INITIALIZE w=%d h=%d\n", msg.init.width, msg.init.height); D("CMD_INITIALIZE w=%d h=%d\n", msg.init.width, msg.init.height);
GL_LOG("RenderWindow: CMD_INITIALIZE w=%d h=%d", GL_LOG("RenderWindow: CMD_INITIALIZE w=%d h=%d",
msg.init.width, msg.init.height); 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.height,
msg.init.useSubWindow); msg.init.useSubWindow);
break; break;
...@@ -312,7 +314,8 @@ private: ...@@ -312,7 +314,8 @@ private:
} // namespace } // namespace
RenderWindow::RenderWindow(int width, RenderWindow::RenderWindow(EGLNativeDisplayType native_display,
int width,
int height, int height,
bool use_thread, bool use_thread,
bool use_sub_window) : bool use_sub_window) :
...@@ -328,6 +331,7 @@ RenderWindow::RenderWindow(int width, ...@@ -328,6 +331,7 @@ RenderWindow::RenderWindow(int width,
RenderWindowMessage msg; RenderWindowMessage msg;
msg.cmd = CMD_INITIALIZE; msg.cmd = CMD_INITIALIZE;
msg.init.nativeDisplay = native_display;
msg.init.width = width; msg.init.width = width;
msg.init.height = height; msg.init.height = height;
msg.init.useSubWindow = use_sub_window; msg.init.useSubWindow = use_sub_window;
......
...@@ -59,7 +59,7 @@ public: ...@@ -59,7 +59,7 @@ public:
// //
// Note that this call doesn't display anything, it just initializes // Note that this call doesn't display anything, it just initializes
// the library, use setupSubWindow() to display something. // 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. // Destructor. This will automatically call removeSubWindow() is needed.
~RenderWindow(); ~RenderWindow();
......
...@@ -78,6 +78,7 @@ RENDER_APICALL int RENDER_APIENTRY initLibrary(void) ...@@ -78,6 +78,7 @@ RENDER_APICALL int RENDER_APIENTRY initLibrary(void)
} }
RENDER_APICALL int RENDER_APIENTRY initOpenGLRenderer( RENDER_APICALL int RENDER_APIENTRY initOpenGLRenderer(
EGLNativeDisplayType native_display,
int width, int height, bool useSubWindow, char* addr, size_t addrLen, int width, int height, bool useSubWindow, char* addr, size_t addrLen,
emugl_logger_struct logfuncs, emugl_crash_func_t crashfunc) { emugl_logger_struct logfuncs, emugl_crash_func_t crashfunc) {
set_emugl_crash_reporter(crashfunc); set_emugl_crash_reporter(crashfunc);
...@@ -116,7 +117,7 @@ RENDER_APICALL int RENDER_APIENTRY initOpenGLRenderer( ...@@ -116,7 +117,7 @@ RENDER_APICALL int RENDER_APIENTRY initOpenGLRenderer(
// initialize the renderer and listen to connections // initialize the renderer and listen to connections
// on a thread in the current process. // 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) { if (!s_renderWindow) {
ERR("Could not create rendering window class"); ERR("Could not create rendering window class");
GL_LOG("Could not create rendering window class"); GL_LOG("Could not create rendering window class");
......
...@@ -72,7 +72,7 @@ void GLRendererServer::start() { ...@@ -72,7 +72,7 @@ void GLRendererServer::start() {
// The width & height we supply here are the dimensions the internal framebuffer // 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 // will use. Making this static prevents us for now to resize the window we create
// later for the actual display. // 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")); BOOST_THROW_EXCEPTION(std::runtime_error("Failed to setup OpenGL renderer"));
socket_path_ = server_addr; socket_path_ = server_addr;
......
...@@ -36,6 +36,7 @@ public: ...@@ -36,6 +36,7 @@ public:
}; };
virtual DisplayInfo display_info() const = 0; virtual DisplayInfo display_info() const = 0;
virtual EGLNativeDisplayType native_display() const = 0;
protected: protected:
std::shared_ptr<input::Manager> input_manager_; std::shared_ptr<input::Manager> input_manager_;
......
...@@ -54,5 +54,9 @@ void WindowCreator::destroy_window(EGLNativeWindowType win) { ...@@ -54,5 +54,9 @@ void WindowCreator::destroy_window(EGLNativeWindowType win) {
WindowCreator::DisplayInfo WindowCreator::display_info() const { WindowCreator::DisplayInfo WindowCreator::display_info() const {
return {display_->horizontal_resolution(), display_->vertical_resolution()}; return {display_->horizontal_resolution(), display_->vertical_resolution()};
} }
EGLNativeDisplayType WindowCreator::native_display() const {
return display_->native_display();
}
} // namespace bridge } // namespace bridge
} // namespace anbox } // namespace anbox
...@@ -37,6 +37,7 @@ public: ...@@ -37,6 +37,7 @@ public:
void destroy_window(EGLNativeWindowType win) override; void destroy_window(EGLNativeWindowType win) override;
DisplayInfo display_info() const override; DisplayInfo display_info() const override;
EGLNativeDisplayType native_display() const override;
private: private:
std::shared_ptr<input::Manager> input_manager_; std::shared_ptr<input::Manager> input_manager_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册