From f9164c47c47e11895f20071c5844d723581ec10c Mon Sep 17 00:00:00 2001 From: Simon Fels Date: Mon, 20 Jun 2016 09:44:26 +0200 Subject: [PATCH] Take screen resolution directly from Mir --- src/anbox/graphics/gl_renderer_server.cpp | 8 +++++++- src/anbox/graphics/mir_native_window_creator.cpp | 5 +++++ src/anbox/graphics/mir_native_window_creator.h | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/anbox/graphics/gl_renderer_server.cpp b/src/anbox/graphics/gl_renderer_server.cpp index 41ae098..ad21ecc 100644 --- a/src/anbox/graphics/gl_renderer_server.cpp +++ b/src/anbox/graphics/gl_renderer_server.cpp @@ -18,6 +18,7 @@ #include "anbox/logger.h" #include "anbox/graphics/gl_renderer_server.h" #include "anbox/graphics/mir_native_window_creator.h" +#include "anbox/graphics/mir_display_connection.h" #include "OpenglRender/render_api.h" @@ -71,10 +72,15 @@ void GLRendererServer::start() { socket_path_ = server_addr; DEBUG("socket path %s", socket_path_); + auto display = window_creator_->display(); + // Create the window we use for rendering the output we get from the // Android container. This will internally construct a Mir surface // and use the host EGL/GLES libraries for rendering. - showOpenGLSubwindow(0, 0, 0, 1080, 1920, 1080, 1920, 1.0f, 0); + const auto width = display->horizontal_resolution(); + const auto height = display->vertical_resolution(); + if (!showOpenGLSubwindow(0, 0, 0, width, height, width, height, 1.0f, 0)) + BOOST_THROW_EXCEPTION(std::runtime_error("Failed to setup GL based window")); } std::string GLRendererServer::socket_path() const { diff --git a/src/anbox/graphics/mir_native_window_creator.cpp b/src/anbox/graphics/mir_native_window_creator.cpp index 387f4da..43197cc 100644 --- a/src/anbox/graphics/mir_native_window_creator.cpp +++ b/src/anbox/graphics/mir_native_window_creator.cpp @@ -57,5 +57,10 @@ void MirNativeWindowCreator::destroy_window(EGLNativeWindowType win) { windows_.erase(iter); } + +std::shared_ptr MirNativeWindowCreator::display() const { + return display_connection_; +} + } // namespace graphics } // namespace anbox diff --git a/src/anbox/graphics/mir_native_window_creator.h b/src/anbox/graphics/mir_native_window_creator.h index fe8930c..47e9bdf 100644 --- a/src/anbox/graphics/mir_native_window_creator.h +++ b/src/anbox/graphics/mir_native_window_creator.h @@ -39,6 +39,8 @@ public: EGLNativeWindowType create_window(int x, int y, int width, int height) override; void destroy_window(EGLNativeWindowType win) override; + std::shared_ptr display() const; + private: std::shared_ptr input_channel_; std::shared_ptr display_connection_;