Replace tbm to screen-connector for dali
authorHyunho Kang <hhstark.kang@samsung.com>
Wed, 14 Dec 2016 10:29:08 +0000 (19:29 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Mon, 19 Dec 2016 01:13:17 +0000 (17:13 -0800)
Change-Id: I801ecf39ac089c4a57fc17b830e4d32bcf793e1f
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
CMakeLists.txt
internal/widget_view/widget_view_impl.cpp
internal/widget_view/widget_view_impl.h
internal/widget_view_manager/widget_view_manager_impl.cpp

index 06b71e3..82ea842 100644 (file)
@@ -18,8 +18,9 @@ pkg_check_modules(viewer_dali REQUIRED
        dali-adaptor
        dali-toolkit
        cynara-client
-        ecore-input
-        tizen-remote-surface-client
+       ecore-input
+       tizen-remote-surface-client
+       screen_connector_watcher
 )
 
 SET(BUILD_SOURCE
index a98d16b..83aa552 100644 (file)
@@ -36,7 +36,6 @@
 #include <widget_instance.h>
 #include <tzplatform_config.h>
 #include <wayland-extension/tizen-extension-client-protocol.h>
-#include <aul_rsm_viewer.h>
 
 namespace Dali
 {
@@ -89,7 +88,8 @@ DALI_ACTION_REGISTRATION( Dali::WidgetView, WidgetView, "activateFaultedWidget",
 
 DALI_TYPE_REGISTRATION_END()
 
-static void OnBufferUpdate( struct tizen_remote_surface* surface, wl_buffer* buffer, uint32_t time, void* data )
+static void OnBufferChanged( struct tizen_remote_surface *surface, uint32_t type, struct wl_buffer *buffer,
+                              int32_t img_file_fd, uint32_t img_file_size, uint32_t time, struct wl_array *keys, void *data)
 {
   Dali::WidgetView::Internal::WidgetView* widgetView = static_cast< Dali::WidgetView::Internal::WidgetView* >( data );
 
@@ -109,21 +109,35 @@ static void OnBufferUpdate( struct tizen_remote_surface* surface, wl_buffer* buf
   }
 }
 
-static void OnSurfaceMissing( struct tizen_remote_surface* surface, void* data )
+static void OnBufferUpdated( struct tizen_remote_surface* surface, wl_buffer* buffer, uint32_t time, void* data )
 {
   Dali::WidgetView::Internal::WidgetView* widgetView = static_cast< Dali::WidgetView::Internal::WidgetView* >( data );
 
   if( widgetView )
   {
-    widgetView->CloseRemoteSurface();
+    if( !widgetView->IsWidgetImageView() )
+    {
+      tizen_remote_surface_transfer_visibility( surface, TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE);
+
+      widgetView->CreateWidgetImageView();
+      widgetView->ConnectSignal( surface );
+    }
+
+    //get tbm surface from buffer
+    tbm_surface_h tbmSurface = static_cast< tbm_surface_h >( wl_buffer_get_user_data( buffer ) );
+    widgetView->UpdateImageSource( tbmSurface );
   }
 }
 
+static void OnSurfaceMissing( struct tizen_remote_surface* surface, void* data )
+{
+  Dali::WidgetView::Internal::WidgetView* widgetView = static_cast< Dali::WidgetView::Internal::WidgetView* >( data );
 
-static struct aul_rsm_handler_s remoteSurfaceHandler = {
-  OnBufferUpdate,
-  OnSurfaceMissing,
-};
+  if( widgetView )
+  {
+    widgetView->CloseRemoteSurface();
+  }
+}
 
 } // unnamed namespace
 
@@ -155,6 +169,7 @@ WidgetView::WidgetView()
   mPreviewVisible( true ),
   mStateTextVisible( true ),
   mPermanentDelete( false ),
+  mWatcherHandle( NULL ),
   mRemoteSurface( NULL )
 {
 }
@@ -172,6 +187,7 @@ WidgetView::WidgetView( const std::string& widgetId, const std::string& contentI
   mPreviewVisible( true ),
   mStateTextVisible( true ),
   mPermanentDelete( false ),
+  mWatcherHandle( NULL ),
   mRemoteSurface( NULL )
 {
 }
@@ -664,6 +680,7 @@ void WidgetView::OnInitialize()
   char* previewPath = NULL;
   std::string previewImage;
   widget_size_type_e sizeType;
+  screen_connector_watcher_ops ops;
 
   int ret = widget_instance_create( mWidgetId.c_str(), &instanceId );
   if( ret < 0 || !instanceId )
@@ -733,8 +750,10 @@ void WidgetView::OnInitialize()
     return;
   }
 
-  aul_rsm_viewer_set_surface_handler( mInstanceId.c_str(), &remoteSurfaceHandler, this );
-
+  ops.change_cb = OnBufferChanged;
+  ops.missing_cb = OnSurfaceMissing;
+  ops.update_cb = OnBufferUpdated;
+  mWatcherHandle = screen_connector_watcher_add(&ops, (char *)mWidgetId.c_str(), this);
   DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::OnInitialize: widget_instance_launch is called. [%s, mPid = %d]\n", mWidgetId.c_str(), mPid );
 
 }
@@ -900,7 +919,7 @@ float WidgetView::GetWidthForHeight( float height )
 
 void WidgetView::CloseRemoteSurface()
 {
-  aul_rsm_viewer_unset_surface_handler( mInstanceId.c_str() );
+  screen_connector_watcher_remove( mWatcherHandle );
   mRemoteSurface = NULL;
 }
 
index 94669d2..a9eaf7c 100644 (file)
@@ -28,6 +28,7 @@
 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
 #include <wayland-extension/tizen-remote-surface-client-protocol.h>
 #include <tbm_surface.h>
+#include <screen_connector_watcher.h>
 
 namespace Dali
 {
@@ -256,7 +257,7 @@ private:
   bool mPreviewVisible;
   bool mStateTextVisible;
   bool mPermanentDelete;
-
+  screen_connector_watcher_h mWatcherHandle;
   tizen_remote_surface* mRemoteSurface;
 
   // Signals
index 4d42798..714bdb6 100644 (file)
@@ -32,7 +32,7 @@
 #include <unistd.h>
 #include <widget_errno.h>
 #include <widget_instance.h>
-#include <aul_rsm_viewer.h>
+#include <screen_connector_watcher.h>
 
 namespace Dali
 {
@@ -147,7 +147,7 @@ WidgetViewManager::WidgetViewManager()
 
 WidgetViewManager::~WidgetViewManager()
 {
-  aul_rsm_viewer_fini();
+  screen_connector_watcher_fini();
   widget_instance_unlisten_event( WidgetViewManager::WidgetEventCallback );
   widget_instance_fini();
 }
@@ -167,7 +167,7 @@ int WidgetViewManager::Initialize( Application application, const std::string& n
   }
 
   // Binds tizen remote surface manager & connects callback
-  if( aul_rsm_viewer_init() < 0 )
+  if( screen_connector_watcher_init() < 0 )
   {
     return WIDGET_ERROR_FAULT;
   }