Fix buffer leak 28/210828/4
authorhyunho <hhstark.kang@samsung.com>
Thu, 25 Jul 2019 06:13:45 +0000 (15:13 +0900)
committerhyunho <hhstark.kang@samsung.com>
Thu, 25 Jul 2019 07:17:47 +0000 (16:17 +0900)
The latest buffer should be released when the bind process begin.
If not latest buffer will be possessed until the window is unbinded.

Change-Id: I95e23c6a3088e4222e1b6f152e718d612450843e
Signed-off-by: hyunho <hhstark.kang@samsung.com>
screen_connector_remote_surface/buffer_event_interface.h
screen_connector_remote_surface/remote_surface.cc
screen_connector_remote_surface/remote_surface.h
screen_connector_remote_surface_evas/image.cc
screen_connector_remote_surface_evas/image_internal.h
screen_connector_remote_surface_evas/remote_surface_evas.cc
screen_connector_remote_surface_evas/remote_surface_evas.h
screen_connector_watcher_evas/src/screen_connector_toolkit_evas.cc

index 93d6b051c168ca3d62d7dbbd81609792b6d18160..86123c743f5fb21417bb4420bc39266a6d9dba44 100644 (file)
@@ -33,6 +33,7 @@ class EXPORT_API IBufferEvent {
                                const std::string& instId, int pid) = 0;
   virtual void OnBufferChanged(int type, std::shared_ptr<WlBuffer> tbm, int fd,
                                uint32_t size, uint32_t time) = 0;
+  virtual void OnBind() = 0;
 };
 
 }  // namespace screen_connector
index 7fd2bbdce46bf1683e5dd611e18ca088c0f5e876..1bea25fda5b8cdd4bb98028e095a4a9f696be9a1 100644 (file)
@@ -231,6 +231,7 @@ void RemoteSurface::Bind(std::shared_ptr<WlSurface> surface) {
   SendTouchCancel();
   RemoteSurfaceManager::GetInst().Bind(*(impl_->surface_), *surface);
   impl_->bind_surface_ = surface;
+  OnBind();
 }
 
 void RemoteSurface::Unbind() {
@@ -281,6 +282,9 @@ void RemoteSurface::OnBufferChanged(int type, std::shared_ptr<WlBuffer> tbm,
                                     int fd, uint32_t size, uint32_t time) {
 }
 
+void RemoteSurface::OnBind() {
+}
+
 const std::string& RemoteSurface::GetAppId() const {
   return impl_->app_id_;
 }
index ec2779a14fe5569fe9aad4ddfbe8191c2ae19e0f..baa126502f54409a39f8d182789f81b55b81671e 100644 (file)
@@ -90,6 +90,7 @@ class EXPORT_API RemoteSurface : public IBufferEvent {
                        const std::string& instId, int pid) override;
   void OnBufferChanged(int type, std::shared_ptr<WlBuffer> tbm, int fd,
                        uint32_t size, uint32_t time) override;
+  void OnBind() override;
 
   static void SetDelayedResumingTime(uint32_t ms);
   static void InitManager();
index d38320f6a92ad60e7b73fdbafb681126fe79b4bf..28642b23e227837343fc2b2657b3e15d34d411b9 100644 (file)
@@ -177,6 +177,11 @@ void Image::MoveCB(void* data, Evas* e, Evas_Object* obj, void* eventInfo) {
   img->listener_->OnMove(*img, eventInfo);
 }
 
+void Image::ClearTbm() {
+  LOGI("clear tbm");
+  prev_buf_.reset();
+}
+
 void Image::Update(std::shared_ptr<WlBuffer> tbm) {
   int width;
   int height;
index ef94fa1e791a75d6dfaffacb15497c936bbd81a3..4b9f6580dee8f4de1bc6bf0996f66c209d901224 100644 (file)
@@ -47,6 +47,7 @@ class Image : public EvasObject {
   virtual ~Image();
 
   virtual void Update(std::shared_ptr<WlBuffer> tbm);
+  void ClearTbm();
 
  private:
   static void MouseInCB(void* data, Evas* e, Evas_Object* obj, void* eventInfo);
index b86d960a2f47de4f1e47db9806861ea7149705ca..701e1befea045de26097657ce86ee0b2d9911d48 100644 (file)
@@ -459,6 +459,10 @@ void RemoteSurfaceEvas::OnBufferRemoved(const std::string& appId,
   impl_->winVisibility_map_.clear();
 }
 
+void RemoteSurfaceEvas::OnBind() {
+  impl_->img_tbm_->ClearTbm();
+}
+
 void RemoteSurfaceEvas::OnBufferChanged(int type, std::shared_ptr<WlBuffer> tbm,
                                         int fd, uint32_t size, uint32_t time) {
   bool isAdded = false;
@@ -466,6 +470,9 @@ void RemoteSurfaceEvas::OnBufferChanged(int type, std::shared_ptr<WlBuffer> tbm,
   if (type != TIZEN_REMOTE_SURFACE_BUFFER_TYPE_TBM)
     return;
 
+  if (GetType() == RemoteSurface::WATCH && RemoteSurface::IsBound())
+    return;
+
   if (impl_->img_tbm_.get() == nullptr) {
     LOGD("first added !!!! %d %s", type, GetAppId().c_str());
     impl_->winVisibility_map_.clear();
index 55acd137f1beb1bf6ec6f5d3924cf327600eb43b..d55ee2bd7a3ce8722f0558885d12a64f9a8a543e 100644 (file)
@@ -62,6 +62,7 @@ class EXPORT_API RemoteSurfaceEvas : public RemoteSurface, public IEvasEvent {
                        int pid) override;
   void OnBufferChanged(int type, std::shared_ptr<WlBuffer> tbm, int fd,
                        uint32_t size, uint32_t time) override;
+  void OnBind() override;
   void OnEvasAdded(const std::string& appId, const std::string& instId,
                    int pid, const EvasObject& image) override;
   void OnEvasRemoved(const std::string& appId, const std::string& instId,
index 97237a38126dbc6946adf3f934aa420fa463e174..664ff9d416d1c8ff30e60662ecdd7d93b8df9ba5 100644 (file)
@@ -398,6 +398,7 @@ screen_connector_toolkit_evas_bind(screen_connector_toolkit_evas_h h,
   if (!rs)
     return -1;
 
+  LOGI("bind window");
   rs->Bind(screen_connector::EvasObject(win, false));
 
   return 0;
@@ -411,6 +412,7 @@ screen_connector_toolkit_evas_unbind(screen_connector_toolkit_evas_h h) {
   if (!rs)
     return -1;
 
+  LOGI("bind window");
   rs->Unbind();
 
   return 0;