From 03b74e26fbecb79933351ed863964766a6c159dc Mon Sep 17 00:00:00 2001 From: hyunho Date: Fri, 2 Aug 2019 10:22:46 +0900 Subject: [PATCH] Modify remote surface create request The surface should be created with window surface to tell consumer window. Also, the custom launching animation needs this feature. Change-Id: Ifbcc16b520fda6cc2a64fa3a716cfc34333f68d3 Signed-off-by: hyunho --- .../src/screen_connector_provider.c | 2 +- screen_connector_remote_surface/remote_surface.cc | 22 +++++---- screen_connector_remote_surface/remote_surface.h | 6 ++- .../remote_surface_implementation.h | 7 +-- .../remote_surface_manager.cc | 15 ++++--- .../remote_surface_manager_internal.h | 2 +- .../remote_surface_evas.cc | 5 ++- .../remote_surface_mixed.cc | 4 +- screen_connector_remote_surface_evas/util.cc | 52 ++++++++++++++++++++++ screen_connector_remote_surface_evas/util.h | 31 +++++++++++++ .../include/screen_connector_toolkit.h | 8 +++- .../src/screen_connector_toolkit.cc | 40 ++++++++++++++--- unittest/src/sc_remote_surface_test.cpp | 3 +- 13 files changed, 164 insertions(+), 33 deletions(-) create mode 100644 screen_connector_remote_surface_evas/util.cc create mode 100644 screen_connector_remote_surface_evas/util.h diff --git a/screen_connector_provider/src/screen_connector_provider.c b/screen_connector_provider/src/screen_connector_provider.c index 4164b9b..c67834d 100755 --- a/screen_connector_provider/src/screen_connector_provider.c +++ b/screen_connector_provider/src/screen_connector_provider.c @@ -264,7 +264,7 @@ EXPORT_API int screen_connector_provider_init(void) if (!strcmp(global->interface, "tizen_remote_surface_manager")) { __rsm = wl_registry_bind(registry, global->id, &tizen_remote_surface_manager_interface, - global->version < 4 ? global->version : 4); + global->version < 6 ? global->version : 6); } } diff --git a/screen_connector_remote_surface/remote_surface.cc b/screen_connector_remote_surface/remote_surface.cc index 1bea25f..fb8e3c3 100644 --- a/screen_connector_remote_surface/remote_surface.cc +++ b/screen_connector_remote_surface/remote_surface.cc @@ -68,8 +68,9 @@ void RemoteSurface::SetDelayedResumingTime(uint32_t ms) { RemoteSurface::Impl::Impl(RemoteSurface* parent, const std::string& id, - RemoteSurface::Type type, bool mock) - : inst_id_(id), pid_(0), rid_(0), + RemoteSurface::Type type, + std::shared_ptr wl_surface, bool mock) + : inst_id_(id), pid_(0), rid_(0), wl_surface_(std::move(wl_surface)), aul_handle_(mock ? new test::AulHandleMock(this, (aul_screen_type_e)type) : new AulHandle(this, (aul_screen_type_e)type)), @@ -78,8 +79,9 @@ RemoteSurface::Impl::Impl(RemoteSurface* parent, RemoteSurface::Impl::Impl(RemoteSurface* parent, int rid, const std::string& id, - RemoteSurface::Type type, bool mock) - : inst_id_(id), pid_(0), rid_(rid), + RemoteSurface::Type type, + std::shared_ptr wl_surface, bool mock) + : inst_id_(id), pid_(0), rid_(rid), wl_surface_(std::move(wl_surface)), aul_handle_(mock ? new test::AulHandleMock(this, (aul_screen_type_e)type) : new AulHandle(this, (aul_screen_type_e)type)), @@ -129,13 +131,14 @@ void RemoteSurface::Impl::OnAppUpdated(const std::string &appId, Redirect(); } -RemoteSurface::RemoteSurface(const std::string& id, Type type, bool mock) - : impl_(new Impl(this, id, type, mock)) { +RemoteSurface::RemoteSurface(const std::string& id, Type type, + std::shared_ptr wl_surface, bool mock) + : impl_(new Impl(this, id, type, std::move(wl_surface), mock)) { } RemoteSurface::RemoteSurface(int rid, const std::string& id, - Type type, bool mock) - : impl_(new Impl(this, rid, id, type, mock)) { + Type type, std::shared_ptr wl_surface, bool mock) + : impl_(new Impl(this, rid, id, type, std::move(wl_surface), mock)) { impl_->Redirect(); } @@ -215,7 +218,8 @@ void RemoteSurface::Impl::OnInputFilterChanged(uint32_t event_filter) { } void RemoteSurface::Impl::Redirect() { - surface_.reset(RemoteSurfaceManager::GetInst(mock_).CreateTRS(rid_, mock_)); + surface_.reset(RemoteSurfaceManager::GetInst(mock_) + .CreateTRS(rid_, wl_surface_, mock_)); LOGD("resource_id : %d, (%p), %s", rid_, surface_->GetHandle(), inst_id_.c_str()); diff --git a/screen_connector_remote_surface/remote_surface.h b/screen_connector_remote_surface/remote_surface.h index baa1265..1851352 100644 --- a/screen_connector_remote_surface/remote_surface.h +++ b/screen_connector_remote_surface/remote_surface.h @@ -56,8 +56,10 @@ class EXPORT_API RemoteSurface : public IBufferEvent { KEY }; - RemoteSurface(const std::string& id, Type type, bool mock = false); - RemoteSurface(int rid, const std::string& id, Type type, bool mock = false); + RemoteSurface(const std::string& id, Type type, + std::shared_ptr wl_surface, bool mock = false); + RemoteSurface(int rid, const std::string& id, Type type, + std::shared_ptr wl_surface, bool mock = false); RemoteSurface(RemoteSurface&&) noexcept; RemoteSurface& operator=(RemoteSurface&&) noexcept; virtual ~RemoteSurface(); diff --git a/screen_connector_remote_surface/remote_surface_implementation.h b/screen_connector_remote_surface/remote_surface_implementation.h index 7b71efc..25e60a9 100644 --- a/screen_connector_remote_surface/remote_surface_implementation.h +++ b/screen_connector_remote_surface/remote_surface_implementation.h @@ -49,10 +49,10 @@ class RemoteSurface::Impl : AulHandle::IEventListener, ITRS::IEventListener { private: friend class RemoteSurface; - Impl(RemoteSurface* parent, const std::string& id, - RemoteSurface::Type type, bool mock); + Impl(RemoteSurface* parent, const std::string& id, RemoteSurface::Type type, + std::shared_ptr wl_surface, bool mock); Impl(RemoteSurface* parent, int rid, const std::string& id, - RemoteSurface::Type type, bool mock); + RemoteSurface::Type type, std::shared_ptr wl_surface, bool mock); void ClearResumingTimer(); void SetResumingTimer(); @@ -64,6 +64,7 @@ class RemoteSurface::Impl : AulHandle::IEventListener, ITRS::IEventListener { int pid_; unsigned int rid_; std::unique_ptr surface_; + std::shared_ptr wl_surface_; std::shared_ptr bind_surface_; std::unique_ptr aul_handle_; RemoteSurface::Type type_; diff --git a/screen_connector_remote_surface/remote_surface_manager.cc b/screen_connector_remote_surface/remote_surface_manager.cc index 3d6afd5..0c6834d 100644 --- a/screen_connector_remote_surface/remote_surface_manager.cc +++ b/screen_connector_remote_surface/remote_surface_manager.cc @@ -36,11 +36,14 @@ RemoteSurfaceManager& RemoteSurfaceManager::GetInst(bool mock) { return sInst; } -ITRS* RemoteSurfaceManager::CreateTRS(int rid, bool mock) { - return mock ? - new test::TRSMock() : - new TRS(tizen_remote_surface_manager_create_surface(rsm_, - (uint32_t)rid, tbm_), true); +ITRS* RemoteSurfaceManager::CreateTRS(int rid, std::shared_ptr surf, + bool mock) { + struct tizen_remote_surface *tzrs = (surf != nullptr) ? + tizen_remote_surface_manager_create_surface_with_wl_surface(rsm_, + (uint32_t)rid, tbm_, surf->GetRaw()) : + tizen_remote_surface_manager_create_surface(rsm_, (uint32_t)rid, tbm_); + + return mock ? new test::TRSMock() : new TRS(tzrs, true); } RemoteSurfaceManager::RemoteSurfaceManager() { @@ -104,7 +107,7 @@ void RemoteSurfaceManager::Init() { if (!strcmp(global->interface, "tizen_remote_surface_manager")) { rsm_ = (struct tizen_remote_surface_manager*)wl_registry_bind(registry, global->id, &tizen_remote_surface_manager_interface, - global->version < 5 ? global->version : 5); + global->version < 6 ? global->version : 6); } } diff --git a/screen_connector_remote_surface/remote_surface_manager_internal.h b/screen_connector_remote_surface/remote_surface_manager_internal.h index 7f02fa9..4172513 100644 --- a/screen_connector_remote_surface/remote_surface_manager_internal.h +++ b/screen_connector_remote_surface/remote_surface_manager_internal.h @@ -35,7 +35,7 @@ class RemoteSurfaceManager { RemoteSurfaceManager& operator = (const RemoteSurfaceManager&) = delete; static RemoteSurfaceManager& GetInst(bool mock = false); - ITRS* CreateTRS(int rid, bool mock = false); + ITRS* CreateTRS(int rid, std::shared_ptr suf, bool mock = false); void Dispose(); void Bind(const ITRS& trs, const WlSurface& suf); void Unbind(const ITRS& trs); diff --git a/screen_connector_remote_surface_evas/remote_surface_evas.cc b/screen_connector_remote_surface_evas/remote_surface_evas.cc index 701e1be..979df7e 100644 --- a/screen_connector_remote_surface_evas/remote_surface_evas.cc +++ b/screen_connector_remote_surface_evas/remote_surface_evas.cc @@ -22,6 +22,7 @@ #include "screen_connector_remote_surface_evas/remote_surface_evas.h" #include "screen_connector_remote_surface_evas/remote_surface_evas_implementation.h" #include "screen_connector_remote_surface_evas/image_mock_internal.h" +#include "screen_connector_remote_surface_evas/util.h" #ifdef LOG_TAG #undef LOG_TAG @@ -36,7 +37,7 @@ RemoteSurfaceEvas::RemoteSurfaceEvas(const std::string& id, RemoteSurface::Type type, std::shared_ptr viewerWin, bool mock) - : RemoteSurface(id, type, mock), + : RemoteSurface(id, type, util::GetWlSurface(*viewerWin.get()), mock), impl_(new Impl(this, viewerWin, mock)), win_ctx_(new WindowContext()) { } @@ -45,7 +46,7 @@ RemoteSurfaceEvas::RemoteSurfaceEvas(int rid, const std::string& id, RemoteSurface::Type type, std::shared_ptr viewerWin, bool mock) - : RemoteSurface(rid, id, type, mock), + : RemoteSurface(rid, id, type, util::GetWlSurface(*viewerWin.get()), mock), impl_(new Impl(this, viewerWin, mock)), win_ctx_(new WindowContext()) { } diff --git a/screen_connector_remote_surface_evas/remote_surface_mixed.cc b/screen_connector_remote_surface_evas/remote_surface_mixed.cc index 24df22b..7bf69d9 100644 --- a/screen_connector_remote_surface_evas/remote_surface_mixed.cc +++ b/screen_connector_remote_surface_evas/remote_surface_mixed.cc @@ -20,6 +20,7 @@ #include #include "screen_connector_remote_surface_evas/remote_surface_mixed_internal.h" +#include "screen_connector_remote_surface_evas/util.h" #ifdef LOG_TAG #undef LOG_TAG @@ -34,7 +35,8 @@ RemoteSurfaceMixed::RemoteSurfaceMixed(const std::string& id, RemoteSurface::Type type, std::shared_ptr viewer_win, IWatcherEvent* listener) - : RemoteSurface(id, type), listener_(listener), viewer_win_(viewer_win) { + : RemoteSurface(id, type, util::GetWlSurface(*viewer_win.get())), + listener_(listener), viewer_win_(viewer_win) { } RemoteSurfaceMixed:: ~RemoteSurfaceMixed() { diff --git a/screen_connector_remote_surface_evas/util.cc b/screen_connector_remote_surface_evas/util.cc new file mode 100644 index 0000000..393f49b --- /dev/null +++ b/screen_connector_remote_surface_evas/util.cc @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "screen_connector_remote_surface_evas/util.h" + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "SC_REMOTE_SURFACE" + +using namespace std; +namespace screen_connector { +namespace util { + + std::shared_ptr GetWlSurface(const EvasObject& win) { + struct wl_surface* surface; + Ecore_Wl2_Window* wl_win; + Ecore_Evas *ee = ecore_evas_ecore_evas_get( + evas_object_evas_get(win.GetRaw())); + + wl_win = ecore_evas_wayland2_window_get(ee); + if (!wl_win) { + LOGE("failed to get wl_win"); + return nullptr; + } + + surface = ecore_wl2_window_surface_get(wl_win); + if (!surface) { + LOGE("failed to get surface"); + return nullptr; + } + return std::shared_ptr(new WlSurface(surface, false)); + } + +} // namespace util +} // namespace watchface_complication diff --git a/screen_connector_remote_surface_evas/util.h b/screen_connector_remote_surface_evas/util.h new file mode 100644 index 0000000..85faac1 --- /dev/null +++ b/screen_connector_remote_surface_evas/util.h @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_UTIL_H_ +#define SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_UTIL_H_ + +#include + +#include "screen_connector_remote_surface_evas/evas_object.h" +#include "screen_connector_remote_surface/remote_surface.h" + +namespace screen_connector { +namespace util { + EXPORT_API std::shared_ptr GetWlSurface(const EvasObject& win); +} // namespace util +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_UTIL_H_ diff --git a/screen_connector_watcher/include/screen_connector_toolkit.h b/screen_connector_watcher/include/screen_connector_toolkit.h index 4bd8a7f..8943be4 100644 --- a/screen_connector_watcher/include/screen_connector_toolkit.h +++ b/screen_connector_watcher/include/screen_connector_toolkit.h @@ -82,7 +82,13 @@ int screen_connector_toolkit_check_input_disabled(screen_connector_toolkit_h h, screen_connector_toolkit_h screen_connector_toolkit_add_by_rid( screen_connector_toolkit_ops *ops, const char* id, screen_connector_screen_type_e type, int surface_id, - void* data); + struct wl_surface* surface, void* data); +screen_connector_toolkit_h screen_connector_toolkit_add_with_surface( + screen_connector_toolkit_ops *ops, + const char *id, + screen_connector_screen_type_e type, + struct wl_surface *surface, + void *data); struct tizen_remote_surface *screen_connector_toolkit_get_trs( screen_connector_toolkit_h h); int screen_connector_toolkit_redirect_surface(screen_connector_toolkit_h info); diff --git a/screen_connector_watcher/src/screen_connector_toolkit.cc b/screen_connector_watcher/src/screen_connector_toolkit.cc index 4b63845..cbe182b 100644 --- a/screen_connector_watcher/src/screen_connector_toolkit.cc +++ b/screen_connector_watcher/src/screen_connector_toolkit.cc @@ -31,6 +31,8 @@ #include "screen_connector_toolkit.h" #include "screen_connector_remote_surface/remote_surface.h" +#include "screen_connector_remote_surface/trs_interface.h" +#include "screen_connector_remote_surface/handle.h" #ifdef LOG_TAG #undef LOG_TAG @@ -43,17 +45,19 @@ class RemoteSurfaceToolkit : public screen_connector::RemoteSurface { RemoteSurfaceToolkit(const std::string& id, screen_connector::RemoteSurface::Type type, screen_connector_toolkit_ops *ops, + std::shared_ptr wl_surface, void* data) - : screen_connector::RemoteSurface(id, type), + : screen_connector::RemoteSurface(id, type, wl_surface), ops_(*ops), data_(data) { } RemoteSurfaceToolkit(const std::string& id, screen_connector::RemoteSurface::Type type, - screen_connector_toolkit_ops *ops, - int rid, void* data) - : screen_connector::RemoteSurface(rid, id, type), + screen_connector_toolkit_ops *ops, int rid, + std::shared_ptr wl_surface, + void* data) + : screen_connector::RemoteSurface(rid, id, type, wl_surface), ops_(*ops), data_(data) { } @@ -169,6 +173,7 @@ screen_connector_toolkit_add_by_rid(screen_connector_toolkit_ops *ops, const char* id, screen_connector_screen_type_e type, int surface_id, + struct wl_surface* surface, void* data) { if (screen_connector_toolkit_is_exist(id, type)) { LOGE("Already exists %s", id); @@ -176,7 +181,9 @@ screen_connector_toolkit_add_by_rid(screen_connector_toolkit_ops *ops, } auto rs = new RemoteSurfaceToolkit(id, - (screen_connector::RemoteSurface::Type)type, ops, surface_id, data); + (screen_connector::RemoteSurface::Type)type, ops, surface_id, + std::shared_ptr( + new screen_connector::WlSurface(surface, false)), data); __toolkits[static_cast(type)]->Add(rs); @@ -194,7 +201,28 @@ screen_connector_toolkit_add(screen_connector_toolkit_ops *ops, } auto rs = new RemoteSurfaceToolkit(id, - (screen_connector::RemoteSurface::Type)type, ops, data); + (screen_connector::RemoteSurface::Type)type, ops, nullptr, data); + + __toolkits[static_cast(type)]->Add(rs); + + return static_cast(rs); +} + +extern "C" EXPORT_API screen_connector_toolkit_h +screen_connector_toolkit_add_with_surface(screen_connector_toolkit_ops *ops, + const char* id, + screen_connector_screen_type_e type, + struct wl_surface* surface, + void* data) { + if (screen_connector_toolkit_is_exist(id, type)) { + LOGE("Already exists %s", id); + return NULL; + } + + auto rs = new RemoteSurfaceToolkit(id, + (screen_connector::RemoteSurface::Type)type, + ops, std::shared_ptr( + new screen_connector::WlSurface(surface, false)), data); __toolkits[static_cast(type)]->Add(rs); diff --git a/unittest/src/sc_remote_surface_test.cpp b/unittest/src/sc_remote_surface_test.cpp index d5b8ef0..e4f201e 100644 --- a/unittest/src/sc_remote_surface_test.cpp +++ b/unittest/src/sc_remote_surface_test.cpp @@ -26,7 +26,8 @@ class SimpleRs : public screen_connector::RemoteSurface { int curType = -1; SimpleRs(const std::string& id, screen_connector::RemoteSurface::Type type, bool mock, Event evType) - : screen_connector::RemoteSurface(id, type, mock), curEvent(evType) { + : screen_connector::RemoteSurface(id, type, nullptr, mock), + curEvent(evType) { } void OnBufferAdded(const std::string& appId, const std::string& instId, int pid) override { -- 2.7.4