Refactor actual window creation into ubuntu specific namespace
This commit is contained in:
parent
cbd43fb7cb
commit
a453635b55
13 changed files with 177 additions and 96 deletions
|
|
@ -61,6 +61,8 @@ find_package(Threads)
|
||||||
find_package(EGL REQUIRED)
|
find_package(EGL REQUIRED)
|
||||||
find_package(GLESv2 REQUIRED)
|
find_package(GLESv2 REQUIRED)
|
||||||
|
|
||||||
|
# TODO(morphis): make mir an optional requirement so we can also add support
|
||||||
|
# for X11, wayland, ... at a later point if needed.
|
||||||
pkg_check_modules(MIRCLIENT REQUIRED mirclient)
|
pkg_check_modules(MIRCLIENT REQUIRED mirclient)
|
||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,8 @@ set(SOURCES
|
||||||
anbox/network/delegate_connection_creator.h
|
anbox/network/delegate_connection_creator.h
|
||||||
|
|
||||||
anbox/graphics/opengles_message_processor.cpp
|
anbox/graphics/opengles_message_processor.cpp
|
||||||
anbox/graphics/mir_display_connection.cpp
|
|
||||||
anbox/graphics/mir_window.cpp
|
|
||||||
anbox/graphics/mir_native_window_creator.cpp
|
|
||||||
anbox/graphics/gl_renderer_server.cpp
|
anbox/graphics/gl_renderer_server.cpp
|
||||||
|
anbox/graphics/window_creator.cpp
|
||||||
|
|
||||||
anbox/input/manager.cpp
|
anbox/input/manager.cpp
|
||||||
anbox/input/device.cpp
|
anbox/input/device.cpp
|
||||||
|
|
@ -59,6 +57,11 @@ set(SOURCES
|
||||||
anbox/support/camera_message_processor.cpp
|
anbox/support/camera_message_processor.cpp
|
||||||
anbox/support/fingerprint_message_processor.cpp
|
anbox/support/fingerprint_message_processor.cpp
|
||||||
|
|
||||||
|
anbox/ubuntu/platform_server.cpp
|
||||||
|
anbox/ubuntu/mir_display_connection.cpp
|
||||||
|
anbox/ubuntu/window_creator.cpp
|
||||||
|
anbox/ubuntu/window.cpp
|
||||||
|
|
||||||
anbox/cmds/version.cpp
|
anbox/cmds/version.cpp
|
||||||
anbox/cmds/run.cpp
|
anbox/cmds/run.cpp
|
||||||
anbox/cmds/shell.cpp
|
anbox/cmds/shell.cpp
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@
|
||||||
#include "anbox/network/qemu_pipe_connection_creator.h"
|
#include "anbox/network/qemu_pipe_connection_creator.h"
|
||||||
#include "anbox/graphics/gl_renderer_server.h"
|
#include "anbox/graphics/gl_renderer_server.h"
|
||||||
#include "anbox/input/manager.h"
|
#include "anbox/input/manager.h"
|
||||||
|
#include "anbox/ubuntu/platform_server.h"
|
||||||
|
#include "anbox/ubuntu/window_creator.h"
|
||||||
|
|
||||||
#include <sys/prctl.h>
|
#include <sys/prctl.h>
|
||||||
|
|
||||||
|
|
@ -69,7 +71,8 @@ anbox::cmds::Run::Run()
|
||||||
|
|
||||||
auto input_manager = std::make_shared<input::Manager>(rt);
|
auto input_manager = std::make_shared<input::Manager>(rt);
|
||||||
|
|
||||||
auto renderer = std::make_shared<graphics::GLRendererServer>(input_manager);
|
auto window_creator = std::make_shared<ubuntu::WindowCreator>(input_manager);
|
||||||
|
auto renderer = std::make_shared<graphics::GLRendererServer>(window_creator);
|
||||||
renderer->start();
|
renderer->start();
|
||||||
|
|
||||||
// Socket which will be used by the qemud service inside the Android
|
// Socket which will be used by the qemud service inside the Android
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,7 @@
|
||||||
|
|
||||||
#include "anbox/logger.h"
|
#include "anbox/logger.h"
|
||||||
#include "anbox/graphics/gl_renderer_server.h"
|
#include "anbox/graphics/gl_renderer_server.h"
|
||||||
#include "anbox/graphics/mir_native_window_creator.h"
|
#include "anbox/graphics/window_creator.h"
|
||||||
#include "anbox/graphics/mir_display_connection.h"
|
|
||||||
|
|
||||||
#include "OpenglRender/render_api.h"
|
#include "OpenglRender/render_api.h"
|
||||||
|
|
||||||
|
|
@ -28,8 +27,8 @@
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace graphics {
|
namespace graphics {
|
||||||
GLRendererServer::GLRendererServer(const std::shared_ptr<input::Manager> &input_manager) :
|
GLRendererServer::GLRendererServer(const std::shared_ptr<WindowCreator> &window_creator) :
|
||||||
window_creator_(std::make_shared<MirNativeWindowCreator>(input_manager)) {
|
window_creator_(window_creator) {
|
||||||
|
|
||||||
// Force the host EGL/GLES libraries as translator implementation
|
// Force the host EGL/GLES libraries as translator implementation
|
||||||
::setenv("ANDROID_EGL_LIB", "libEGL.so.1", 1);
|
::setenv("ANDROID_EGL_LIB", "libEGL.so.1", 1);
|
||||||
|
|
@ -65,9 +64,9 @@ void GLRendererServer::start() {
|
||||||
log_funcs.coarse = logger_write;
|
log_funcs.coarse = logger_write;
|
||||||
log_funcs.fine = logger_write;
|
log_funcs.fine = logger_write;
|
||||||
|
|
||||||
auto display = window_creator_->display();
|
auto display_info = window_creator_->display_info();
|
||||||
const auto width = display->horizontal_resolution();
|
const auto width = display_info.horizontal_resolution;
|
||||||
const auto height = display->vertical_resolution();
|
const auto height = display_info.vertical_resolution;
|
||||||
|
|
||||||
char server_addr[256] = { 0 };
|
char server_addr[256] = { 0 };
|
||||||
if (!initOpenGLRenderer(width, height, true, server_addr, sizeof(server_addr), log_funcs, logger_write))
|
if (!initOpenGLRenderer(width, height, true, server_addr, sizeof(server_addr), log_funcs, logger_write))
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,12 @@
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace input {
|
namespace input {
|
||||||
class Manager;
|
class Manager;
|
||||||
}
|
} // namespace input
|
||||||
namespace graphics {
|
namespace graphics {
|
||||||
class MirNativeWindowCreator;
|
class WindowCreator;
|
||||||
|
|
||||||
class GLRendererServer {
|
class GLRendererServer {
|
||||||
public:
|
public:
|
||||||
GLRendererServer(const std::shared_ptr<input::Manager> &input_manager);
|
GLRendererServer(const std::shared_ptr<WindowCreator> &window_creator);
|
||||||
~GLRendererServer();
|
~GLRendererServer();
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
|
|
@ -39,7 +38,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string socket_path_;
|
std::string socket_path_;
|
||||||
std::shared_ptr<MirNativeWindowCreator> window_creator_;
|
std::shared_ptr<WindowCreator> window_creator_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace graphics
|
} // namespace graphics
|
||||||
|
|
|
||||||
30
src/anbox/graphics/window_creator.cpp
Normal file
30
src/anbox/graphics/window_creator.cpp
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 3, as published
|
||||||
|
* by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranties of
|
||||||
|
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "anbox/graphics/window_creator.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace anbox {
|
||||||
|
namespace graphics {
|
||||||
|
WindowCreator::WindowCreator(const std::shared_ptr<input::Manager> &input_manager) :
|
||||||
|
input_manager_(input_manager) {
|
||||||
|
}
|
||||||
|
|
||||||
|
WindowCreator::~WindowCreator() {
|
||||||
|
}
|
||||||
|
} // namespace graphics
|
||||||
|
} // namespace anbox
|
||||||
45
src/anbox/graphics/window_creator.h
Normal file
45
src/anbox/graphics/window_creator.h
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 3, as published
|
||||||
|
* by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranties of
|
||||||
|
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef ANBOX_GRAPHICS_WINDOW_CREATOR_H_
|
||||||
|
#define ANBOX_GRAPHICS_WINDOW_CREATOR_H_
|
||||||
|
|
||||||
|
#include "external/android-emugl/host/libs/libOpenglRender/NativeSubWindow.h"
|
||||||
|
|
||||||
|
namespace anbox {
|
||||||
|
namespace input {
|
||||||
|
class Manager;
|
||||||
|
} // namespace input
|
||||||
|
namespace graphics {
|
||||||
|
class WindowCreator : public SubWindowHandler {
|
||||||
|
public:
|
||||||
|
WindowCreator(const std::shared_ptr<input::Manager> &input_manager);
|
||||||
|
virtual ~WindowCreator();
|
||||||
|
|
||||||
|
struct DisplayInfo {
|
||||||
|
int horizontal_resolution;
|
||||||
|
int vertical_resolution;
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual DisplayInfo display_info() const = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::shared_ptr<input::Manager> input_manager_;
|
||||||
|
};
|
||||||
|
} // namespace graphics
|
||||||
|
} // namespace anbox
|
||||||
|
#endif
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#include "anbox/graphics/mir_display_connection.h"
|
#include "anbox/ubuntu/mir_display_connection.h"
|
||||||
#include "anbox/logger.h"
|
#include "anbox/logger.h"
|
||||||
|
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
|
|
@ -48,7 +48,7 @@ static const MirDisplayOutput *find_active_output(
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace graphics {
|
namespace ubuntu {
|
||||||
MirDisplayConnection::MirDisplayConnection() :
|
MirDisplayConnection::MirDisplayConnection() :
|
||||||
connection_(nullptr),
|
connection_(nullptr),
|
||||||
output_id_(-1),
|
output_id_(-1),
|
||||||
|
|
@ -70,6 +70,13 @@ MirDisplayConnection::MirDisplayConnection() :
|
||||||
BOOST_THROW_EXCEPTION(std::runtime_error(msg.c_str()));
|
BOOST_THROW_EXCEPTION(std::runtime_error(msg.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mir_connection_set_display_config_change_callback(
|
||||||
|
connection_,
|
||||||
|
[](MirConnection* connection, void* context) {
|
||||||
|
auto thiz = reinterpret_cast<MirDisplayConnection*>(context);
|
||||||
|
DEBUG("");
|
||||||
|
}, this);
|
||||||
|
|
||||||
MirDisplayConfiguration* display_config =
|
MirDisplayConfiguration* display_config =
|
||||||
mir_connection_create_display_config(connection_);
|
mir_connection_create_display_config(connection_);
|
||||||
|
|
||||||
|
|
@ -82,6 +89,7 @@ MirDisplayConnection::MirDisplayConnection() :
|
||||||
output_id_ = output->output_id;
|
output_id_ = output->output_id;
|
||||||
|
|
||||||
const MirDisplayMode *mode = &output->modes[output->current_mode];
|
const MirDisplayMode *mode = &output->modes[output->current_mode];
|
||||||
|
|
||||||
vertical_resolution_ = mode->vertical_resolution;
|
vertical_resolution_ = mode->vertical_resolution;
|
||||||
horizontal_resolution_ = mode->horizontal_resolution;
|
horizontal_resolution_ = mode->horizontal_resolution;
|
||||||
|
|
||||||
|
|
@ -118,5 +126,5 @@ int MirDisplayConnection::vertical_resolution() const {
|
||||||
int MirDisplayConnection::horizontal_resolution() const {
|
int MirDisplayConnection::horizontal_resolution() const {
|
||||||
return horizontal_resolution_;
|
return horizontal_resolution_;
|
||||||
}
|
}
|
||||||
} // namespace graphics
|
} // namespace ubuntu
|
||||||
} // namespace anbox
|
} // namespace anbox
|
||||||
|
|
@ -15,8 +15,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ANBOX_GRAPHICS_MIR_DISPLAY_CONNECTION_H_
|
#ifndef ANBOX_UBUNTU_MIR_DISPLAY_CONNECTION_H_
|
||||||
#define ANBOX_GRAPHICS_MIR_DISPLAY_CONNECTION_H_
|
#define ANBOX_UBUNTU_MIR_DISPLAY_CONNECTION_H_
|
||||||
|
|
||||||
#define MIR_EGL_PLATFORM
|
#define MIR_EGL_PLATFORM
|
||||||
|
|
||||||
|
|
@ -25,8 +25,7 @@
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace graphics {
|
namespace ubuntu {
|
||||||
|
|
||||||
class MirDisplayConnection {
|
class MirDisplayConnection {
|
||||||
public:
|
public:
|
||||||
MirDisplayConnection();
|
MirDisplayConnection();
|
||||||
|
|
@ -47,8 +46,7 @@ private:
|
||||||
int vertical_resolution_;
|
int vertical_resolution_;
|
||||||
int horizontal_resolution_;
|
int horizontal_resolution_;
|
||||||
};
|
};
|
||||||
|
} // namespace ubuntu
|
||||||
} // namespace graphics
|
|
||||||
} // namespace anbox
|
} // namespace anbox
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -15,11 +15,13 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "anbox/graphics/mir_window.h"
|
#include "anbox/ubuntu/window.h"
|
||||||
#include "anbox/graphics/mir_display_connection.h"
|
#include "anbox/ubuntu/mir_display_connection.h"
|
||||||
#include "anbox/logger.h"
|
|
||||||
#include "anbox/input/manager.h"
|
#include "anbox/input/manager.h"
|
||||||
#include "anbox/input/device.h"
|
#include "anbox/input/device.h"
|
||||||
|
#include "anbox/logger.h"
|
||||||
|
|
||||||
|
#include <boost/throw_exception.hpp>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
class SlotFingerMapper {
|
class SlotFingerMapper {
|
||||||
|
|
@ -64,9 +66,12 @@ private:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace graphics {
|
namespace ubuntu {
|
||||||
MirWindow::MirWindow(const std::shared_ptr<MirDisplayConnection> &display, const std::shared_ptr<input::Manager> &input_manager) :
|
Window::Window(const std::shared_ptr<MirDisplayConnection> &display,
|
||||||
|
const std::shared_ptr<input::Manager> &input_manager,
|
||||||
|
int width, int height) :
|
||||||
native_window_(0),
|
native_window_(0),
|
||||||
surface_(nullptr) {
|
surface_(nullptr) {
|
||||||
|
|
||||||
|
|
@ -76,14 +81,15 @@ MirWindow::MirWindow(const std::shared_ptr<MirDisplayConnection> &display, const
|
||||||
|
|
||||||
auto spec = mir_connection_create_spec_for_normal_surface(
|
auto spec = mir_connection_create_spec_for_normal_surface(
|
||||||
display->connection(),
|
display->connection(),
|
||||||
display->vertical_resolution(),
|
width,
|
||||||
display->horizontal_resolution(),
|
height,
|
||||||
pixel_format);
|
pixel_format);
|
||||||
|
|
||||||
mir_surface_spec_set_name(spec, "anbox");
|
mir_surface_spec_set_name(spec, "anbox");
|
||||||
mir_surface_spec_set_event_handler(spec, handle_surface_event, this);
|
mir_surface_spec_set_event_handler(spec, handle_surface_event, this);
|
||||||
mir_surface_spec_set_fullscreen_on_output(spec, display->output_id());
|
mir_surface_spec_set_fullscreen_on_output(spec, display->output_id());
|
||||||
mir_surface_spec_set_buffer_usage(spec, mir_buffer_usage_hardware);
|
mir_surface_spec_set_buffer_usage(spec, mir_buffer_usage_hardware);
|
||||||
|
mir_surface_spec_set_shell_chrome(spec, mir_shell_chrome_normal);
|
||||||
|
|
||||||
surface_ = mir_surface_create_sync(spec);
|
surface_ = mir_surface_create_sync(spec);
|
||||||
mir_surface_spec_release(spec);
|
mir_surface_spec_release(spec);
|
||||||
|
|
@ -116,19 +122,19 @@ MirWindow::MirWindow(const std::shared_ptr<MirDisplayConnection> &display, const
|
||||||
input_device_->set_abs_bit(ABS_MT_POSITION_Y);
|
input_device_->set_abs_bit(ABS_MT_POSITION_Y);
|
||||||
input_device_->set_prop_bit(INPUT_PROP_DIRECT);
|
input_device_->set_prop_bit(INPUT_PROP_DIRECT);
|
||||||
input_device_->set_abs_min(ABS_MT_POSITION_X, 0);
|
input_device_->set_abs_min(ABS_MT_POSITION_X, 0);
|
||||||
input_device_->set_abs_max(ABS_MT_POSITION_X, display->horizontal_resolution());
|
input_device_->set_abs_max(ABS_MT_POSITION_X, parameters.width);
|
||||||
input_device_->set_abs_min(ABS_MT_POSITION_Y, 0);
|
input_device_->set_abs_min(ABS_MT_POSITION_Y, 0);
|
||||||
input_device_->set_abs_max(ABS_MT_POSITION_Y, display->vertical_resolution());
|
input_device_->set_abs_max(ABS_MT_POSITION_Y, parameters.height);
|
||||||
input_device_->set_abs_max(ABS_MT_SLOT, 10);
|
input_device_->set_abs_max(ABS_MT_SLOT, 10);
|
||||||
input_device_->set_abs_max(ABS_MT_TRACKING_ID, 255);
|
input_device_->set_abs_max(ABS_MT_TRACKING_ID, 255);
|
||||||
input_device_->set_key_bit(BTN_TOUCH);
|
input_device_->set_key_bit(BTN_TOUCH);
|
||||||
input_device_->set_key_bit(BTN_TOOL_FINGER);
|
input_device_->set_key_bit(BTN_TOOL_FINGER);
|
||||||
}
|
}
|
||||||
|
|
||||||
MirWindow::~MirWindow() {
|
Window::~Window() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MirWindow::handle_touch_event(MirTouchEvent const* touch_event) {
|
void Window::handle_touch_event(MirTouchEvent const* touch_event) {
|
||||||
const auto point_count = mir_touch_event_point_count(touch_event);
|
const auto point_count = mir_touch_event_point_count(touch_event);
|
||||||
|
|
||||||
static SlotFingerMapper mapper;
|
static SlotFingerMapper mapper;
|
||||||
|
|
@ -178,7 +184,7 @@ void MirWindow::handle_touch_event(MirTouchEvent const* touch_event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MirWindow::handle_input_event(MirInputEvent const* input_event) {
|
void Window::handle_input_event(MirInputEvent const* input_event) {
|
||||||
const auto type = mir_input_event_get_type(input_event);
|
const auto type = mir_input_event_get_type(input_event);
|
||||||
MirTouchEvent const* touch_event = nullptr;
|
MirTouchEvent const* touch_event = nullptr;
|
||||||
MirKeyboardEvent const* key_event = nullptr;
|
MirKeyboardEvent const* key_event = nullptr;
|
||||||
|
|
@ -196,9 +202,9 @@ void MirWindow::handle_input_event(MirInputEvent const* input_event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MirWindow::handle_surface_event(MirSurface *surface, MirEvent const* event, void *context) {
|
void Window::handle_surface_event(MirSurface*, MirEvent const* event, void *context) {
|
||||||
const auto event_type = mir_event_get_type(event);
|
const auto event_type = mir_event_get_type(event);
|
||||||
auto thiz = static_cast<MirWindow*>(context);
|
auto thiz = static_cast<Window*>(context);
|
||||||
|
|
||||||
switch (event_type) {
|
switch (event_type) {
|
||||||
case mir_event_type_input:
|
case mir_event_type_input:
|
||||||
|
|
@ -209,8 +215,8 @@ void MirWindow::handle_surface_event(MirSurface *surface, MirEvent const* event,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLNativeWindowType MirWindow::native_window() const {
|
EGLNativeWindowType Window::native_window() const {
|
||||||
return native_window_;
|
return native_window_;
|
||||||
}
|
}
|
||||||
} // namespace graphics
|
} // namespace bridge
|
||||||
} // namespace anbox
|
} // namespace anbox
|
||||||
|
|
@ -15,29 +15,28 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ANBOX_GRAPHICS_MIR_WINDOW_H_
|
#ifndef ANBOX_UBUNTU_WINDOW_H_
|
||||||
#define ANBOX_GRAPHICS_MIR_WINDOW_H_
|
#define ANBOX_UBUNTU_WINDOW_H_
|
||||||
|
|
||||||
#define MIR_EGL_PLATFORM
|
|
||||||
|
|
||||||
#include <mirclient/mir_toolkit/mir_client_library.h>
|
|
||||||
|
|
||||||
#include <EGL/egl.h>
|
#include <EGL/egl.h>
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#include <mirclient/mir_toolkit/mir_client_library.h>
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace input {
|
namespace input {
|
||||||
class Manager;
|
class Manager;
|
||||||
class Device;
|
class Device;
|
||||||
}
|
} // namespace input
|
||||||
namespace graphics {
|
namespace ubuntu {
|
||||||
class MirDisplayConnection;
|
class MirDisplayConnection;
|
||||||
|
class Window {
|
||||||
class MirWindow {
|
|
||||||
public:
|
public:
|
||||||
MirWindow(const std::shared_ptr<MirDisplayConnection> &display, const std::shared_ptr<input::Manager> &input_manager);
|
Window(const std::shared_ptr<MirDisplayConnection> &display,
|
||||||
~MirWindow();
|
const std::shared_ptr<input::Manager> &input_manager,
|
||||||
|
int width, int height);
|
||||||
|
~Window();
|
||||||
|
|
||||||
EGLNativeWindowType native_window() const;
|
EGLNativeWindowType native_window() const;
|
||||||
|
|
||||||
|
|
@ -51,8 +50,7 @@ private:
|
||||||
EGLNativeWindowType native_window_;
|
EGLNativeWindowType native_window_;
|
||||||
MirSurface *surface_;
|
MirSurface *surface_;
|
||||||
};
|
};
|
||||||
|
} // namespace bridge
|
||||||
} // namespace graphics
|
|
||||||
} // namespace anbox
|
} // namespace anbox
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -15,39 +15,35 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "anbox/graphics/mir_native_window_creator.h"
|
#include "anbox/ubuntu/window_creator.h"
|
||||||
#include "anbox/graphics/mir_display_connection.h"
|
#include "anbox/ubuntu/window.h"
|
||||||
#include "anbox/graphics/mir_window.h"
|
#include "anbox/ubuntu/mir_display_connection.h"
|
||||||
#include "anbox/input/manager.h"
|
#include "anbox/logger.h"
|
||||||
|
|
||||||
#include <boost/throw_exception.hpp>
|
#include <boost/throw_exception.hpp>
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace graphics {
|
namespace ubuntu {
|
||||||
MirNativeWindowCreator::MirNativeWindowCreator(const std::shared_ptr<input::Manager> &input_manager) :
|
WindowCreator::WindowCreator(const std::shared_ptr<input::Manager> &input_manager) :
|
||||||
|
graphics::WindowCreator(input_manager),
|
||||||
input_manager_(input_manager),
|
input_manager_(input_manager),
|
||||||
display_connection_(std::make_shared<MirDisplayConnection>()) {
|
display_(std::make_shared<MirDisplayConnection>()) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MirNativeWindowCreator::~MirNativeWindowCreator() {
|
WindowCreator::~WindowCreator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
EGLNativeWindowType MirNativeWindowCreator::create_window(int x, int y, int width, int height) {
|
EGLNativeWindowType WindowCreator::create_window(int x, int y, int width, int height) {
|
||||||
(void) x;
|
DEBUG("x %i y %i width %i height %i", x, y, width, height);
|
||||||
(void) y;
|
|
||||||
(void) width;
|
|
||||||
(void) height;
|
|
||||||
|
|
||||||
if (windows_.size() > 0)
|
auto window = std::make_shared<Window>(display_, input_manager_,
|
||||||
BOOST_THROW_EXCEPTION(std::runtime_error("We currently only allow a single native window"));
|
width, height);
|
||||||
|
|
||||||
auto window = std::make_shared<MirWindow>(display_connection_, input_manager_);
|
|
||||||
windows_.insert({window->native_window(), window});
|
windows_.insert({window->native_window(), window});
|
||||||
|
|
||||||
return window->native_window();
|
return window->native_window();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MirNativeWindowCreator::destroy_window(EGLNativeWindowType win) {
|
void WindowCreator::destroy_window(EGLNativeWindowType win) {
|
||||||
auto iter = windows_.find(win);
|
auto iter = windows_.find(win);
|
||||||
if (iter == windows_.end())
|
if (iter == windows_.end())
|
||||||
return;
|
return;
|
||||||
|
|
@ -55,9 +51,8 @@ void MirNativeWindowCreator::destroy_window(EGLNativeWindowType win) {
|
||||||
windows_.erase(iter);
|
windows_.erase(iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<MirDisplayConnection> MirNativeWindowCreator::display() const {
|
WindowCreator::DisplayInfo WindowCreator::display_info() const {
|
||||||
return display_connection_;
|
return {display_->horizontal_resolution(), display_->vertical_resolution()};
|
||||||
}
|
}
|
||||||
|
} // namespace bridge
|
||||||
} // namespace graphics
|
|
||||||
} // namespace anbox
|
} // namespace anbox
|
||||||
|
|
@ -15,40 +15,35 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ANBOX_GRAPHICS_MIR_NATIVE_WINDOW_CREATOR_H_
|
#ifndef ANBOX_UBUNTU_WINDOW_CREATOR_H_
|
||||||
#define ANBOX_GRAPHICS_MIR_NATIVE_WINDOW_CREATOR_H_
|
#define ANBOX_UBUNTU_WINDOW_CREATOR_H_
|
||||||
|
|
||||||
#include "external/android-emugl/host/libs/libOpenglRender/NativeSubWindow.h"
|
#include "anbox/graphics/window_creator.h"
|
||||||
|
|
||||||
#include <memory>
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
#include <EGL/egl.h>
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace input {
|
namespace ubuntu {
|
||||||
class Manager;
|
|
||||||
}
|
|
||||||
namespace graphics {
|
|
||||||
|
|
||||||
class MirDisplayConnection;
|
class MirDisplayConnection;
|
||||||
class MirWindow;
|
class Window;
|
||||||
|
class WindowCreator : public graphics::WindowCreator {
|
||||||
class MirNativeWindowCreator : public SubWindowHandler {
|
|
||||||
public:
|
public:
|
||||||
MirNativeWindowCreator(const std::shared_ptr<input::Manager> &input_channel);
|
WindowCreator(const std::shared_ptr<input::Manager> &input_manager);
|
||||||
virtual ~MirNativeWindowCreator();
|
~WindowCreator();
|
||||||
|
|
||||||
EGLNativeWindowType create_window(int x, int y, int width, int height) override;
|
EGLNativeWindowType create_window(int x, int y, int width, int height) override;
|
||||||
void destroy_window(EGLNativeWindowType win) override;
|
void destroy_window(EGLNativeWindowType win) override;
|
||||||
|
|
||||||
std::shared_ptr<MirDisplayConnection> display() const;
|
DisplayInfo display_info() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<input::Manager> input_manager_;
|
std::shared_ptr<input::Manager> input_manager_;
|
||||||
std::shared_ptr<MirDisplayConnection> display_connection_;
|
std::shared_ptr<MirDisplayConnection> display_;
|
||||||
std::map<EGLNativeWindowType,std::shared_ptr<MirWindow>> windows_;
|
std::map<EGLNativeWindowType,std::shared_ptr<Window>> windows_;
|
||||||
};
|
};
|
||||||
|
} // namespace bridge
|
||||||
} // namespace graphics
|
|
||||||
} // namespace anbox
|
} // namespace anbox
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
Loading…
Add table
Add a link
Reference in a new issue