Introduce platform concept instead of having different policies
This commit is contained in:
parent
d33d98a835
commit
db7d18d01c
16 changed files with 77 additions and 66 deletions
|
|
@ -164,8 +164,9 @@ set(SOURCES
|
||||||
anbox/wm/window_state.cpp
|
anbox/wm/window_state.cpp
|
||||||
anbox/wm/window.cpp
|
anbox/wm/window.cpp
|
||||||
|
|
||||||
anbox/platform/policy.cpp
|
anbox/platform/base_platform.cpp
|
||||||
anbox/platform/default_policy.cpp
|
|
||||||
|
anbox/platform/null/platform.cpp
|
||||||
|
|
||||||
anbox/input/manager.cpp
|
anbox/input/manager.cpp
|
||||||
anbox/input/device.cpp
|
anbox/input/device.cpp
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ class AudioForwarder : public anbox::network::MessageProcessor {
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace audio {
|
namespace audio {
|
||||||
Server::Server(const std::shared_ptr<Runtime>& rt, const std::shared_ptr<platform::Policy> &platform_policy) :
|
Server::Server(const std::shared_ptr<Runtime>& rt, const std::shared_ptr<platform::BasePlatform> &platform) :
|
||||||
platform_policy_(platform_policy),
|
platform_(platform),
|
||||||
socket_file_(utils::string_format("%s/anbox_audio", SystemConfiguration::instance().socket_dir())),
|
socket_file_(utils::string_format("%s/anbox_audio", SystemConfiguration::instance().socket_dir())),
|
||||||
connector_(std::make_shared<network::PublishedSocketConnector>(
|
connector_(std::make_shared<network::PublishedSocketConnector>(
|
||||||
socket_file_, rt,
|
socket_file_, rt,
|
||||||
|
|
@ -81,7 +81,7 @@ void Server::create_connection_for(std::shared_ptr<boost::asio::basic_stream_soc
|
||||||
|
|
||||||
switch (client_info.type) {
|
switch (client_info.type) {
|
||||||
case ClientInfo::Type::Playback:
|
case ClientInfo::Type::Playback:
|
||||||
processor = std::make_shared<AudioForwarder>(platform_policy_->create_audio_sink());
|
processor = std::make_shared<AudioForwarder>(platform_->create_audio_sink());
|
||||||
break;
|
break;
|
||||||
case ClientInfo::Type::Recording:
|
case ClientInfo::Type::Recording:
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@
|
||||||
#include "anbox/audio/client_info.h"
|
#include "anbox/audio/client_info.h"
|
||||||
#include "anbox/network/socket_messenger.h"
|
#include "anbox/network/socket_messenger.h"
|
||||||
#include "anbox/network/socket_connection.h"
|
#include "anbox/network/socket_connection.h"
|
||||||
#include "anbox/platform/policy.h"
|
#include "anbox/platform/base_platform.h"
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
|
|
@ -33,7 +33,7 @@ class PublishedSocketConnector;
|
||||||
namespace audio {
|
namespace audio {
|
||||||
class Server {
|
class Server {
|
||||||
public:
|
public:
|
||||||
Server(const std::shared_ptr<Runtime>& rt, const std::shared_ptr<platform::Policy> &platform_policy);
|
Server(const std::shared_ptr<Runtime>& rt, const std::shared_ptr<platform::BasePlatform> &platform);
|
||||||
~Server();
|
~Server();
|
||||||
|
|
||||||
std::string socket_file() const { return socket_file_; }
|
std::string socket_file() const { return socket_file_; }
|
||||||
|
|
@ -44,7 +44,7 @@ class Server {
|
||||||
|
|
||||||
int next_id();
|
int next_id();
|
||||||
|
|
||||||
std::shared_ptr<platform::Policy> platform_policy_;
|
std::shared_ptr<platform::BasePlatform> platform_;
|
||||||
std::string socket_file_;
|
std::string socket_file_;
|
||||||
std::shared_ptr<network::PublishedSocketConnector> connector_;
|
std::shared_ptr<network::PublishedSocketConnector> connector_;
|
||||||
std::shared_ptr<network::Connections<network::SocketConnection>> const connections_;
|
std::shared_ptr<network::Connections<network::SocketConnection>> const connections_;
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "anbox/bridge/platform_api_skeleton.h"
|
#include "anbox/bridge/platform_api_skeleton.h"
|
||||||
#include "anbox/application/database.h"
|
#include "anbox/application/database.h"
|
||||||
#include "anbox/platform/policy.h"
|
#include "anbox/platform/base_platform.h"
|
||||||
#include "anbox/wm/manager.h"
|
#include "anbox/wm/manager.h"
|
||||||
#include "anbox/wm/window_state.h"
|
#include "anbox/wm/window_state.h"
|
||||||
#include "anbox/logger.h"
|
#include "anbox/logger.h"
|
||||||
|
|
@ -32,11 +32,11 @@ namespace anbox {
|
||||||
namespace bridge {
|
namespace bridge {
|
||||||
PlatformApiSkeleton::PlatformApiSkeleton(
|
PlatformApiSkeleton::PlatformApiSkeleton(
|
||||||
const std::shared_ptr<rpc::PendingCallCache> &pending_calls,
|
const std::shared_ptr<rpc::PendingCallCache> &pending_calls,
|
||||||
const std::shared_ptr<platform::Policy> &platform_policy,
|
const std::shared_ptr<platform::BasePlatform> &platform,
|
||||||
const std::shared_ptr<wm::Manager> &window_manager,
|
const std::shared_ptr<wm::Manager> &window_manager,
|
||||||
const std::shared_ptr<application::Database> &app_db)
|
const std::shared_ptr<application::Database> &app_db)
|
||||||
: pending_calls_(pending_calls),
|
: pending_calls_(pending_calls),
|
||||||
platform_policy_(platform_policy),
|
platform_(platform),
|
||||||
window_manager_(window_manager),
|
window_manager_(window_manager),
|
||||||
app_db_(app_db) {}
|
app_db_(app_db) {}
|
||||||
|
|
||||||
|
|
@ -49,7 +49,7 @@ void PlatformApiSkeleton::set_clipboard_data(anbox::protobuf::bridge::ClipboardD
|
||||||
(void)response;
|
(void)response;
|
||||||
|
|
||||||
if (request->has_text())
|
if (request->has_text())
|
||||||
platform_policy_->set_clipboard_data(platform::Policy::ClipboardData{request->text()});
|
platform_->set_clipboard_data(platform::BasePlatform::ClipboardData{request->text()});
|
||||||
|
|
||||||
done->Run();
|
done->Run();
|
||||||
}
|
}
|
||||||
|
|
@ -59,7 +59,7 @@ void PlatformApiSkeleton::get_clipboard_data(anbox::protobuf::rpc::Void const *r
|
||||||
google::protobuf::Closure *done) {
|
google::protobuf::Closure *done) {
|
||||||
(void)request;
|
(void)request;
|
||||||
|
|
||||||
auto data = platform_policy_->get_clipboard_data();
|
auto data = platform_->get_clipboard_data();
|
||||||
if (!data.text.empty())
|
if (!data.text.empty())
|
||||||
response->set_text(data.text);
|
response->set_text(data.text);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ class ApplicationListUpdateEvent;
|
||||||
} // namespace bridge
|
} // namespace bridge
|
||||||
} // namespace protobuf
|
} // namespace protobuf
|
||||||
namespace platform {
|
namespace platform {
|
||||||
class Policy;
|
class BasePlatform;
|
||||||
} // namespace platform
|
} // namespace platform
|
||||||
namespace rpc {
|
namespace rpc {
|
||||||
class PendingCallCache;
|
class PendingCallCache;
|
||||||
|
|
@ -56,7 +56,7 @@ class PlatformApiSkeleton {
|
||||||
public:
|
public:
|
||||||
PlatformApiSkeleton(
|
PlatformApiSkeleton(
|
||||||
const std::shared_ptr<rpc::PendingCallCache> &pending_calls,
|
const std::shared_ptr<rpc::PendingCallCache> &pending_calls,
|
||||||
const std::shared_ptr<platform::Policy> &platform_policy,
|
const std::shared_ptr<platform::BasePlatform> &platform,
|
||||||
const std::shared_ptr<wm::Manager> &window_manager,
|
const std::shared_ptr<wm::Manager> &window_manager,
|
||||||
const std::shared_ptr<application::Database> &app_db);
|
const std::shared_ptr<application::Database> &app_db);
|
||||||
virtual ~PlatformApiSkeleton();
|
virtual ~PlatformApiSkeleton();
|
||||||
|
|
@ -79,7 +79,7 @@ class PlatformApiSkeleton {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<rpc::PendingCallCache> pending_calls_;
|
std::shared_ptr<rpc::PendingCallCache> pending_calls_;
|
||||||
std::shared_ptr<platform::Policy> platform_policy_;
|
std::shared_ptr<platform::BasePlatform> platform_;
|
||||||
std::shared_ptr<wm::Manager> window_manager_;
|
std::shared_ptr<wm::Manager> window_manager_;
|
||||||
std::shared_ptr<application::Database> app_db_;
|
std::shared_ptr<application::Database> app_db_;
|
||||||
std::function<void()> boot_finished_handler_;
|
std::function<void()> boot_finished_handler_;
|
||||||
|
|
|
||||||
|
|
@ -176,25 +176,25 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory)
|
||||||
if (single_window_)
|
if (single_window_)
|
||||||
display_frame = window_size_;
|
display_frame = window_size_;
|
||||||
|
|
||||||
auto policy = std::make_shared<ubuntu::PlatformPolicy>(input_manager, display_frame, single_window_);
|
auto platform = std::make_shared<ubuntu::PlatformPolicy>(input_manager, display_frame, single_window_);
|
||||||
|
|
||||||
auto app_db = std::make_shared<application::Database>();
|
auto app_db = std::make_shared<application::Database>();
|
||||||
|
|
||||||
std::shared_ptr<wm::Manager> window_manager;
|
std::shared_ptr<wm::Manager> window_manager;
|
||||||
if (single_window_)
|
if (single_window_)
|
||||||
window_manager = std::make_shared<wm::SingleWindowManager>(policy, display_frame, app_db);
|
window_manager = std::make_shared<wm::SingleWindowManager>(platform, display_frame, app_db);
|
||||||
else
|
else
|
||||||
window_manager = std::make_shared<wm::MultiWindowManager>(policy, android_api_stub, app_db);
|
window_manager = std::make_shared<wm::MultiWindowManager>(platform, android_api_stub, app_db);
|
||||||
|
|
||||||
auto gl_server = std::make_shared<graphics::GLRendererServer>(
|
auto gl_server = std::make_shared<graphics::GLRendererServer>(
|
||||||
graphics::GLRendererServer::Config{gles_driver_, single_window_}, window_manager);
|
graphics::GLRendererServer::Config{gles_driver_, single_window_}, window_manager);
|
||||||
|
|
||||||
policy->set_window_manager(window_manager);
|
platform->set_window_manager(window_manager);
|
||||||
policy->set_renderer(gl_server->renderer());
|
platform->set_renderer(gl_server->renderer());
|
||||||
|
|
||||||
window_manager->setup();
|
window_manager->setup();
|
||||||
|
|
||||||
auto audio_server = std::make_shared<audio::Server>(rt, policy);
|
auto audio_server = std::make_shared<audio::Server>(rt, platform);
|
||||||
|
|
||||||
const auto socket_path = SystemConfiguration::instance().socket_dir();
|
const auto socket_path = SystemConfiguration::instance().socket_dir();
|
||||||
|
|
||||||
|
|
@ -219,7 +219,7 @@ anbox::cmds::SessionManager::SessionManager(const BusFactory &bus_factory)
|
||||||
android_api_stub->set_rpc_channel(rpc_channel);
|
android_api_stub->set_rpc_channel(rpc_channel);
|
||||||
|
|
||||||
auto server = std::make_shared<bridge::PlatformApiSkeleton>(
|
auto server = std::make_shared<bridge::PlatformApiSkeleton>(
|
||||||
pending_calls, policy, window_manager, app_db);
|
pending_calls, platform, window_manager, app_db);
|
||||||
server->register_boot_finished_handler([&]() {
|
server->register_boot_finished_handler([&]() {
|
||||||
DEBUG("Android successfully booted");
|
DEBUG("Android successfully booted");
|
||||||
android_api_stub->ready().set(true);
|
android_api_stub->ready().set(true);
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,19 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "anbox/platform/policy.h"
|
#include "anbox/platform/base_platform.h"
|
||||||
|
#include "anbox/platform/null/platform.h"
|
||||||
|
#include "anbox/logger.h"
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace platform {
|
namespace platform {
|
||||||
Policy::~Policy() {}
|
std::shared_ptr<BasePlatform> create(const std::string &name) {
|
||||||
} // namespace wm
|
if (name.empty())
|
||||||
} // namespace anbox
|
return std::make_shared<NullPlatform>();
|
||||||
|
|
||||||
|
WARNING("Unsupported platfrom '%s'", name);
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
} // namespace platform
|
||||||
|
} // namespace anbox
|
||||||
|
|
@ -32,9 +32,9 @@ namespace wm {
|
||||||
class Window;
|
class Window;
|
||||||
} // namespace wm
|
} // namespace wm
|
||||||
namespace platform {
|
namespace platform {
|
||||||
class Policy {
|
class BasePlatform {
|
||||||
public:
|
public:
|
||||||
virtual ~Policy();
|
virtual ~BasePlatform() {}
|
||||||
|
|
||||||
virtual std::shared_ptr<wm::Window> create_window(const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title) = 0;
|
virtual std::shared_ptr<wm::Window> create_window(const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title) = 0;
|
||||||
|
|
||||||
|
|
@ -48,6 +48,7 @@ class Policy {
|
||||||
virtual std::shared_ptr<audio::Sink> create_audio_sink() = 0;
|
virtual std::shared_ptr<audio::Sink> create_audio_sink() = 0;
|
||||||
virtual std::shared_ptr<audio::Source> create_audio_source() = 0;
|
virtual std::shared_ptr<audio::Source> create_audio_source() = 0;
|
||||||
};
|
};
|
||||||
|
std::shared_ptr<BasePlatform> create(const std::string &name = "");
|
||||||
} // namespace wm
|
} // namespace wm
|
||||||
} // namespace anbox
|
} // namespace anbox
|
||||||
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "anbox/platform/default_policy.h"
|
#include "anbox/platform/null/platform.h"
|
||||||
#include "anbox/wm/window.h"
|
#include "anbox/wm/window.h"
|
||||||
#include "anbox/logger.h"
|
#include "anbox/logger.h"
|
||||||
|
|
||||||
|
|
@ -31,29 +31,29 @@ class NullWindow : public anbox::wm::Window {
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace platform {
|
namespace platform {
|
||||||
DefaultPolicy::DefaultPolicy() {}
|
NullPlatform::NullPlatform() {}
|
||||||
|
|
||||||
std::shared_ptr<wm::Window> DefaultPolicy::create_window(
|
std::shared_ptr<wm::Window> NullPlatform::create_window(
|
||||||
const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title) {
|
const anbox::wm::Task::Id &task, const anbox::graphics::Rect &frame, const std::string &title) {
|
||||||
return std::make_shared<::NullWindow>(task, frame, title);
|
return std::make_shared<::NullWindow>(task, frame, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultPolicy::set_clipboard_data(const ClipboardData &data) {
|
void NullPlatform::set_clipboard_data(const ClipboardData &data) {
|
||||||
(void)data;
|
(void)data;
|
||||||
ERROR("Not implemented");
|
ERROR("Not implemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultPolicy::ClipboardData DefaultPolicy::get_clipboard_data() {
|
NullPlatform::ClipboardData NullPlatform::get_clipboard_data() {
|
||||||
ERROR("Not implemented");
|
ERROR("Not implemented");
|
||||||
return ClipboardData{};
|
return ClipboardData{};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<audio::Sink> DefaultPolicy::create_audio_sink() {
|
std::shared_ptr<audio::Sink> NullPlatform::create_audio_sink() {
|
||||||
ERROR("Not implemented");
|
ERROR("Not implemented");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<audio::Source> DefaultPolicy::create_audio_source() {
|
std::shared_ptr<audio::Source> NullPlatform::create_audio_source() {
|
||||||
ERROR("Not implemented");
|
ERROR("Not implemented");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
@ -15,16 +15,16 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ANBOX_PLATFORM_DEFAULT_POLICY_H_
|
#ifndef ANBOX_PLATFORM_NULL_PLATFORM_H_
|
||||||
#define ANBOX_PLATFORM_DEFAULT_POLICY_H_
|
#define ANBOX_PLATFORM_NULL_PLATFORM_H_
|
||||||
|
|
||||||
#include "anbox/platform/policy.h"
|
#include "anbox/platform/base_platform.h"
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace platform {
|
namespace platform {
|
||||||
class DefaultPolicy : public Policy {
|
class NullPlatform : public BasePlatform {
|
||||||
public:
|
public:
|
||||||
DefaultPolicy();
|
NullPlatform();
|
||||||
std::shared_ptr<wm::Window> create_window(
|
std::shared_ptr<wm::Window> create_window(
|
||||||
const anbox::wm::Task::Id &task,
|
const anbox::wm::Task::Id &task,
|
||||||
const anbox::graphics::Rect &frame,
|
const anbox::graphics::Rect &frame,
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
#define ANBOX_UBUNTU_PLATFORM_POLICY_H_
|
#define ANBOX_UBUNTU_PLATFORM_POLICY_H_
|
||||||
|
|
||||||
#include "anbox/ubuntu/window.h"
|
#include "anbox/ubuntu/window.h"
|
||||||
#include "anbox/platform/policy.h"
|
#include "anbox/platform/base_platform.h"
|
||||||
|
|
||||||
#include "anbox/graphics/emugl/DisplayManager.h"
|
#include "anbox/graphics/emugl/DisplayManager.h"
|
||||||
|
|
||||||
|
|
@ -40,7 +40,7 @@ class Manager;
|
||||||
} // namespace wm
|
} // namespace wm
|
||||||
namespace ubuntu {
|
namespace ubuntu {
|
||||||
class PlatformPolicy : public std::enable_shared_from_this<PlatformPolicy>,
|
class PlatformPolicy : public std::enable_shared_from_this<PlatformPolicy>,
|
||||||
public platform::Policy,
|
public platform::BasePlatform,
|
||||||
public Window::Observer {
|
public Window::Observer {
|
||||||
public:
|
public:
|
||||||
PlatformPolicy(const std::shared_ptr<input::Manager> &input_manager,
|
PlatformPolicy(const std::shared_ptr<input::Manager> &input_manager,
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include "anbox/application/database.h"
|
#include "anbox/application/database.h"
|
||||||
#include "anbox/wm/multi_window_manager.h"
|
#include "anbox/wm/multi_window_manager.h"
|
||||||
#include "anbox/platform/policy.h"
|
#include "anbox/platform/base_platform.h"
|
||||||
#include "anbox/bridge/android_api_stub.h"
|
#include "anbox/bridge/android_api_stub.h"
|
||||||
#include "anbox/logger.h"
|
#include "anbox/logger.h"
|
||||||
|
|
||||||
|
|
@ -25,10 +25,10 @@
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace wm {
|
namespace wm {
|
||||||
MultiWindowManager::MultiWindowManager(const std::weak_ptr<platform::Policy> &policy,
|
MultiWindowManager::MultiWindowManager(const std::weak_ptr<platform::BasePlatform> &platform,
|
||||||
const std::shared_ptr<bridge::AndroidApiStub> &android_api_stub,
|
const std::shared_ptr<bridge::AndroidApiStub> &android_api_stub,
|
||||||
const std::shared_ptr<application::Database> &app_db)
|
const std::shared_ptr<application::Database> &app_db)
|
||||||
: platform_policy_(policy), android_api_stub_(android_api_stub), app_db_(app_db) {}
|
: platform_(platform), android_api_stub_(android_api_stub), app_db_(app_db) {}
|
||||||
|
|
||||||
MultiWindowManager::~MultiWindowManager() {}
|
MultiWindowManager::~MultiWindowManager() {}
|
||||||
|
|
||||||
|
|
@ -67,7 +67,7 @@ void MultiWindowManager::apply_window_state_update(const WindowState::List &upda
|
||||||
if (app.valid())
|
if (app.valid())
|
||||||
title = app.name;
|
title = app.name;
|
||||||
|
|
||||||
if (auto p = platform_policy_.lock()) {
|
if (auto p = platform_.lock()) {
|
||||||
auto w = p->create_window(window.task(), window.frame(), title);
|
auto w = p->create_window(window.task(), window.frame(), title);
|
||||||
if (w) {
|
if (w) {
|
||||||
w->attach();
|
w->attach();
|
||||||
|
|
|
||||||
|
|
@ -32,12 +32,12 @@ namespace bridge {
|
||||||
class AndroidApiStub;
|
class AndroidApiStub;
|
||||||
} // namespace bridge
|
} // namespace bridge
|
||||||
namespace platform {
|
namespace platform {
|
||||||
class Policy;
|
class BasePlatform;
|
||||||
} // namespace platform
|
} // namespace platform
|
||||||
namespace wm {
|
namespace wm {
|
||||||
class MultiWindowManager : public Manager {
|
class MultiWindowManager : public Manager {
|
||||||
public:
|
public:
|
||||||
MultiWindowManager(const std::weak_ptr<platform::Policy> &policy,
|
MultiWindowManager(const std::weak_ptr<platform::BasePlatform> &platform,
|
||||||
const std::shared_ptr<bridge::AndroidApiStub> &android_api_stub,
|
const std::shared_ptr<bridge::AndroidApiStub> &android_api_stub,
|
||||||
const std::shared_ptr<application::Database> &app_db);
|
const std::shared_ptr<application::Database> &app_db);
|
||||||
~MultiWindowManager();
|
~MultiWindowManager();
|
||||||
|
|
@ -53,7 +53,7 @@ class MultiWindowManager : public Manager {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::mutex mutex_;
|
std::mutex mutex_;
|
||||||
std::weak_ptr<platform::Policy> platform_policy_;
|
std::weak_ptr<platform::BasePlatform> platform_;
|
||||||
std::shared_ptr<bridge::AndroidApiStub> android_api_stub_;
|
std::shared_ptr<bridge::AndroidApiStub> android_api_stub_;
|
||||||
std::shared_ptr<application::Database> app_db_;
|
std::shared_ptr<application::Database> app_db_;
|
||||||
std::map<Task::Id, std::shared_ptr<Window>> windows_;
|
std::map<Task::Id, std::shared_ptr<Window>> windows_;
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "anbox/wm/single_window_manager.h"
|
#include "anbox/wm/single_window_manager.h"
|
||||||
#include "anbox/platform/policy.h"
|
#include "anbox/platform/base_platform.h"
|
||||||
#include "anbox/logger.h"
|
#include "anbox/logger.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
@ -26,15 +26,15 @@
|
||||||
|
|
||||||
namespace anbox {
|
namespace anbox {
|
||||||
namespace wm {
|
namespace wm {
|
||||||
SingleWindowManager::SingleWindowManager(const std::weak_ptr<platform::Policy> &policy,
|
SingleWindowManager::SingleWindowManager(const std::weak_ptr<platform::BasePlatform> &platform,
|
||||||
const graphics::Rect &window_size,
|
const graphics::Rect &window_size,
|
||||||
const std::shared_ptr<application::Database> &app_db)
|
const std::shared_ptr<application::Database> &app_db)
|
||||||
: platform_policy_(policy), window_size_(window_size), app_db_(app_db) {}
|
: platform_(platform), window_size_(window_size), app_db_(app_db) {}
|
||||||
|
|
||||||
SingleWindowManager::~SingleWindowManager() {}
|
SingleWindowManager::~SingleWindowManager() {}
|
||||||
|
|
||||||
void SingleWindowManager::setup() {
|
void SingleWindowManager::setup() {
|
||||||
if (auto p = platform_policy_.lock()) {
|
if (auto p = platform_.lock()) {
|
||||||
window_ = p->create_window(0, window_size_, "Anbox - Android in a Box");
|
window_ = p->create_window(0, window_size_, "Anbox - Android in a Box");
|
||||||
if (!window_->attach())
|
if (!window_->attach())
|
||||||
WARNING("Failed to attach window to renderer");
|
WARNING("Failed to attach window to renderer");
|
||||||
|
|
|
||||||
|
|
@ -29,13 +29,13 @@ namespace application {
|
||||||
class Database;
|
class Database;
|
||||||
} // namespace application
|
} // namespace application
|
||||||
namespace platform {
|
namespace platform {
|
||||||
class Policy;
|
class BasePlatform;
|
||||||
} // namespace platform
|
} // namespace platform
|
||||||
namespace wm {
|
namespace wm {
|
||||||
class Window;
|
class Window;
|
||||||
class SingleWindowManager : public Manager {
|
class SingleWindowManager : public Manager {
|
||||||
public:
|
public:
|
||||||
SingleWindowManager(const std::weak_ptr<platform::Policy> &policy,
|
SingleWindowManager(const std::weak_ptr<platform::BasePlatform> &platform,
|
||||||
const graphics::Rect &window_size,
|
const graphics::Rect &window_size,
|
||||||
const std::shared_ptr<application::Database> &app_db);
|
const std::shared_ptr<application::Database> &app_db);
|
||||||
~SingleWindowManager();
|
~SingleWindowManager();
|
||||||
|
|
@ -52,7 +52,7 @@ class SingleWindowManager : public Manager {
|
||||||
void remove_task(const Task::Id &task) override;
|
void remove_task(const Task::Id &task) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::weak_ptr<platform::Policy> platform_policy_;
|
std::weak_ptr<platform::BasePlatform> platform_;
|
||||||
graphics::Rect window_size_;
|
graphics::Rect window_size_;
|
||||||
std::shared_ptr<application::Database> app_db_;
|
std::shared_ptr<application::Database> app_db_;
|
||||||
std::shared_ptr<Window> window_;
|
std::shared_ptr<Window> window_;
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include "anbox/application/database.h"
|
#include "anbox/application/database.h"
|
||||||
#include "anbox/platform/default_policy.h"
|
#include "anbox/platform/base_platform.h"
|
||||||
#include "anbox/wm/multi_window_manager.h"
|
#include "anbox/wm/multi_window_manager.h"
|
||||||
#include "anbox/wm/window_state.h"
|
#include "anbox/wm/window_state.h"
|
||||||
|
|
||||||
|
|
@ -45,9 +45,9 @@ TEST(LayerComposer, FindsNoSuitableWindowForLayer) {
|
||||||
|
|
||||||
// The default policy will create a dumb window instance when requested
|
// The default policy will create a dumb window instance when requested
|
||||||
// from the manager.
|
// from the manager.
|
||||||
auto platform_policy = std::make_shared<platform::DefaultPolicy>();
|
auto platform = platform::create();
|
||||||
auto app_db = std::make_shared<application::Database>();
|
auto app_db = std::make_shared<application::Database>();
|
||||||
auto wm = std::make_shared<wm::MultiWindowManager>(platform_policy, nullptr, app_db);
|
auto wm = std::make_shared<wm::MultiWindowManager>(platform, nullptr, app_db);
|
||||||
|
|
||||||
auto single_window = wm::WindowState{
|
auto single_window = wm::WindowState{
|
||||||
wm::Display::Id{1},
|
wm::Display::Id{1},
|
||||||
|
|
@ -79,9 +79,9 @@ TEST(LayerComposer, MapsLayersToWindows) {
|
||||||
|
|
||||||
// The default policy will create a dumb window instance when requested
|
// The default policy will create a dumb window instance when requested
|
||||||
// from the manager.
|
// from the manager.
|
||||||
auto platform_policy = std::make_shared<platform::DefaultPolicy>();
|
auto platform = platform::create();
|
||||||
auto app_db = std::make_shared<application::Database>();
|
auto app_db = std::make_shared<application::Database>();
|
||||||
auto wm = std::make_shared<wm::MultiWindowManager>(platform_policy, nullptr, app_db);
|
auto wm = std::make_shared<wm::MultiWindowManager>(platform, nullptr, app_db);
|
||||||
|
|
||||||
auto first_window = wm::WindowState{
|
auto first_window = wm::WindowState{
|
||||||
wm::Display::Id{1},
|
wm::Display::Id{1},
|
||||||
|
|
@ -139,9 +139,9 @@ TEST(LayerComposer, WindowPartiallyOffscreen) {
|
||||||
|
|
||||||
// The default policy will create a dumb window instance when requested
|
// The default policy will create a dumb window instance when requested
|
||||||
// from the manager.
|
// from the manager.
|
||||||
auto platform_policy = std::make_shared<platform::DefaultPolicy>();
|
auto platform = platform::create();
|
||||||
auto app_db = std::make_shared<application::Database>();
|
auto app_db = std::make_shared<application::Database>();
|
||||||
auto wm = std::make_shared<wm::MultiWindowManager>(platform_policy, nullptr, app_db);
|
auto wm = std::make_shared<wm::MultiWindowManager>(platform, nullptr, app_db);
|
||||||
|
|
||||||
auto window = wm::WindowState{
|
auto window = wm::WindowState{
|
||||||
wm::Display::Id{1},
|
wm::Display::Id{1},
|
||||||
|
|
@ -184,9 +184,9 @@ TEST(LayerComposer, PopupShouldNotCauseWindowLayerOffset) {
|
||||||
|
|
||||||
// The default policy will create a dumb window instance when requested
|
// The default policy will create a dumb window instance when requested
|
||||||
// from the manager.
|
// from the manager.
|
||||||
auto platform_policy = std::make_shared<platform::DefaultPolicy>();
|
auto platform = platform::create();
|
||||||
auto app_db = std::make_shared<application::Database>();
|
auto app_db = std::make_shared<application::Database>();
|
||||||
auto wm = std::make_shared<wm::MultiWindowManager>(platform_policy, nullptr, app_db);
|
auto wm = std::make_shared<wm::MultiWindowManager>(platform, nullptr, app_db);
|
||||||
|
|
||||||
auto window = wm::WindowState{
|
auto window = wm::WindowState{
|
||||||
wm::Display::Id{1},
|
wm::Display::Id{1},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue