Modify remote surface create request 59/211359/5
authorhyunho <hhstark.kang@samsung.com>
Fri, 2 Aug 2019 01:22:46 +0000 (10:22 +0900)
committerhyunho <hhstark.kang@samsung.com>
Fri, 2 Aug 2019 05:56:08 +0000 (14:56 +0900)
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 <hhstark.kang@samsung.com>
13 files changed:
screen_connector_provider/src/screen_connector_provider.c
screen_connector_remote_surface/remote_surface.cc
screen_connector_remote_surface/remote_surface.h
screen_connector_remote_surface/remote_surface_implementation.h
screen_connector_remote_surface/remote_surface_manager.cc
screen_connector_remote_surface/remote_surface_manager_internal.h
screen_connector_remote_surface_evas/remote_surface_evas.cc
screen_connector_remote_surface_evas/remote_surface_mixed.cc
screen_connector_remote_surface_evas/util.cc [new file with mode: 0644]
screen_connector_remote_surface_evas/util.h [new file with mode: 0644]
screen_connector_watcher/include/screen_connector_toolkit.h
screen_connector_watcher/src/screen_connector_toolkit.cc
unittest/src/sc_remote_surface_test.cpp

index 4164b9b73386db2c19d66c7c7ce53370436fa9ea..c67834d41e75a9903eba321c14d2b6ab1df6d2bd 100755 (executable)
@@ -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);
                }
        }
 
index 1bea25fda5b8cdd4bb98028e095a4a9f696be9a1..fb8e3c3ee9ce410ca25f92e9656c57ff9bfb4f22 100644 (file)
@@ -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<WlSurface> 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<WlSurface> 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<WlSurface> 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<WlSurface> 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());
index baa126502f54409a39f8d182789f81b55b81671e..18513521d254fb7701d3fb4c7b8c8e0d6875e14f 100644 (file)
@@ -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<WlSurface> wl_surface, bool mock = false);
+  RemoteSurface(int rid, const std::string& id, Type type,
+      std::shared_ptr<WlSurface> wl_surface, bool mock = false);
   RemoteSurface(RemoteSurface&&) noexcept;
   RemoteSurface& operator=(RemoteSurface&&) noexcept;
   virtual ~RemoteSurface();
index 7b71efcc4072185c36597f7e4063d8eb68618bff..25e60a9569978cbaa374d3026c87947465e10f41 100644 (file)
@@ -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<WlSurface> wl_surface, bool mock);
   Impl(RemoteSurface* parent, int rid, const std::string& id,
-                    RemoteSurface::Type type, bool mock);
+    RemoteSurface::Type type, std::shared_ptr<WlSurface> 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<ITRS> surface_;
+  std::shared_ptr<WlSurface> wl_surface_;
   std::shared_ptr<WlSurface> bind_surface_;
   std::unique_ptr<AulHandle> aul_handle_;
   RemoteSurface::Type type_;
index 3d6afd5d3959d758a16b56640c4908d07215ca19..0c6834de940562662168ec035828aade5a84d48c 100644 (file)
@@ -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<WlSurface> 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);
     }
   }
 
index 7f02fa948f90f4d2cb413d5a885f084ef02e0f0a..417251329bae14d11557130e2dffcb4f222e5234 100644 (file)
@@ -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<WlSurface> suf, bool mock = false);
   void Dispose();
   void Bind(const ITRS& trs, const WlSurface& suf);
   void Unbind(const ITRS& trs);
index 701e1befea045de26097657ce86ee0b2d9911d48..979df7ea16884aa79501d07e8b003af730a3156e 100644 (file)
@@ -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<EvasObject> 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<EvasObject> 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()) {
 }
index 24df22b362ff78b8903689669cb8a990a3b634a7..7bf69d952446864061887e3a389b94678e466c3e 100644 (file)
@@ -20,6 +20,7 @@
 #include <memory>
 
 #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<EvasObject> 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 (file)
index 0000000..393f49b
--- /dev/null
@@ -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 <dlog.h>
+
+#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<WlSurface> 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<WlSurface>(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 (file)
index 0000000..85faac1
--- /dev/null
@@ -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 <memory>
+
+#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<WlSurface> GetWlSurface(const EvasObject& win);
+}  // namespace util
+}  // namespace screen_connector
+
+#endif  // SCREEN_CONNECTOR_REMOTE_SURFACE_EVAS_UTIL_H_
index 4bd8a7f5e15ccc4280eb5f2cc0eaada12a7f214e..8943be48bf79a6ba9401e4e4876f19b09fb94f70 100644 (file)
@@ -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);
index 4b63845ae1c943f19d80d86cc8104e5e2e5ee582..cbe182b60e0af1dbb91986921bc29558e1857dcf 100644 (file)
@@ -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<screen_connector::WlSurface> 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<screen_connector::WlSurface> 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<screen_connector::WlSurface>(
+        new screen_connector::WlSurface(surface, false)), data);
 
   __toolkits[static_cast<int>(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<int>(type)]->Add(rs);
+
+  return static_cast<void*>(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<screen_connector::WlSurface>(
+        new screen_connector::WlSurface(surface, false)), data);
 
   __toolkits[static_cast<int>(type)]->Add(rs);
 
index d5b8ef02cb9eff096ac45e6554e7f0a45a9680a9..e4f201e586455b81addbd406cfe5da4ea066205f 100644 (file)
@@ -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 {