Changed constraint to PropertyNotification for updating position/size 50/155950/10
authortaeyoon0.lee <taeyoon0.lee@samsung.com>
Mon, 16 Oct 2017 13:45:23 +0000 (22:45 +0900)
committertaeyoon0.lee <taeyoon0.lee@samsung.com>
Mon, 23 Oct 2017 10:08:24 +0000 (19:08 +0900)
Change-Id: Id688eebcc2ac0b6ef4520b207d36b225a5379135

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp
automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp
dali-toolkit/internal/controls/video-view/video-view-impl.cpp
dali-toolkit/internal/controls/video-view/video-view-impl.h

index 09cc438..e7fb2cf 100644 (file)
@@ -59,6 +59,14 @@ public:
     return mLooping;
   }
 
+  void Stop()
+  {
+    if( !mFinishedSignal.Empty() )
+    {
+      mFinishedSignal.Emit();
+    }
+  }
+
 public:
 
   std::string mUrl;
@@ -162,6 +170,7 @@ void VideoPlayer::Pause()
 
 void VideoPlayer::Stop()
 {
+  Internal::Adaptor::GetImplementation( *this ).Stop();
 }
 
 void VideoPlayer::SetMute( bool mute )
index 30a7e8c..8baed37 100644 (file)
@@ -415,6 +415,7 @@ int UtcDaliVideoViewPropertyUnderlay(void)
   DALI_TEST_CHECK( view );
 
   Stage::GetCurrent().Add( view );
+  view.Play();
 
   application.SendNotification();
   application.Render();
@@ -422,10 +423,12 @@ int UtcDaliVideoViewPropertyUnderlay(void)
   bool isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
   DALI_TEST_CHECK( isUnderlay );
 
+  view.Play();
   view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, false );
   isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
   DALI_TEST_CHECK( !isUnderlay );
 
+  view.Play();
   view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, true );
   isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
   DALI_TEST_CHECK( isUnderlay );
@@ -438,5 +441,15 @@ int UtcDaliVideoViewPropertyUnderlay(void)
   isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
   DALI_TEST_CHECK( isUnderlay );
 
+  // For coverage
+  ToolkitApplication::DECODED_IMAGES_SUPPORTED = true;
+
+  view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, true );
+  view.SetProperty( Toolkit::VideoView::Property::UNDERLAY, false );
+  isUnderlay = view.GetProperty( Toolkit::VideoView::Property::UNDERLAY ).Get< bool >();
+  DALI_TEST_CHECK( !isUnderlay );
+
+  view.Stop();
+
   END_TEST;
 }
index 5834950..25dff01 100644 (file)
@@ -106,48 +106,19 @@ const char* FRAGMENT_SHADER = DALI_COMPOSE_SHADER(
   }\n
 );
 
-struct TriggerFunctor
-{
-  TriggerFunctor( TriggerEventInterface* notification )
-  : mNotification( notification )
-  {
-  }
-
-  void operator()( bool& current, const PropertyInputContainer& inputs )
-  {
-    if( mNotification != NULL )
-    {
-      mNotification->Trigger();
-    }
-  }
-
-  TriggerEventInterface* mNotification;
-};
-
 } // anonymous namepsace
 
 VideoView::VideoView()
 : Control( ControlBehaviour( ACTOR_BEHAVIOUR_DEFAULT | DISABLE_STYLE_CHANGE_SIGNALS ) ),
-  mUpdateTriggerPropertyIndex( Property::INVALID_INDEX),
-  mNotification( NULL ),
   mCurrentVideoPlayPosition( 0 ),
   mIsPlay( false ),
-  mIsPause( false ),
   mIsUnderlay( true )
 {
   mVideoPlayer = Dali::VideoPlayer::New();
-
-  TriggerEventFactory triggerEventFactory;
-  mNotification = triggerEventFactory.CreateTriggerEvent( MakeCallback(this, &VideoView::UpdateDisplayArea ),
-                                                               TriggerEventInterface::KEEP_ALIVE_AFTER_TRIGGER);
 }
 
 VideoView::~VideoView()
 {
-  if( mNotification != NULL )
-  {
-    delete mNotification;
-  }
 }
 
 Toolkit::VideoView VideoView::New()
@@ -162,7 +133,6 @@ Toolkit::VideoView VideoView::New()
 
 void VideoView::OnInitialize()
 {
-  mUpdateTriggerPropertyIndex = Self().RegisterProperty( "updateTrigger", true );
   mVideoPlayer.FinishedSignal().Connect( this, &VideoView::EmitSignalFinish );
   SetWindowSurfaceTarget();
 }
@@ -245,23 +215,25 @@ bool VideoView::IsLooping()
 
 void VideoView::Play()
 {
+  if( mIsUnderlay )
+  {
+    Self().AddRenderer( mRenderer );
+  }
+
   mVideoPlayer.Play();
   mIsPlay = true;
-  mIsPause = false;
 }
 
 void VideoView::Pause()
 {
   mVideoPlayer.Pause();
   mIsPlay = false;
-  mIsPause = true;
 }
 
 void VideoView::Stop()
 {
   mVideoPlayer.Stop();
   mIsPlay = false;
-  mIsPause = false;
 }
 
 void VideoView::Forward( int millisecond )
@@ -310,6 +282,11 @@ Dali::Toolkit::VideoView::VideoViewSignalType& VideoView::FinishedSignal()
 
 void VideoView::EmitSignalFinish()
 {
+  if( mIsUnderlay )
+  {
+    Self().RemoveRenderer( mRenderer );
+  }
+
   if ( !mFinishedSignal.Empty() )
   {
     Dali::Toolkit::VideoView handle( GetOwner() );
@@ -615,10 +592,17 @@ void VideoView::SetWindowSurfaceTarget()
     mVisual.Reset();
   }
 
-  Constraint constraint = Constraint::New<bool>( self, mUpdateTriggerPropertyIndex, TriggerFunctor( mNotification ) );
-  constraint.AddSource( Source( self, Actor::Property::POSITION ) );
-  constraint.AddSource( Source( self, Actor::Property::SIZE ) );
-  constraint.Apply();
+  if( mIsPlay )
+  {
+    mVideoPlayer.Pause();
+  }
+
+  mPositionUpdateNotification = self.AddPropertyNotification( Actor::Property::WORLD_POSITION, StepCondition( 1.0f, 1.0f ) );
+  mSizeUpdateNotification = self.AddPropertyNotification( Actor::Property::SIZE, StepCondition( 1.0f, 1.0f ) );
+  mScaleUpdateNotification = self.AddPropertyNotification( Actor::Property::WORLD_SCALE, StepCondition( 0.1f, 1.0f ) );
+  mPositionUpdateNotification.NotifySignal().Connect( this, &VideoView::UpdateDisplayArea );
+  mSizeUpdateNotification.NotifySignal().Connect( this, &VideoView::UpdateDisplayArea );
+  mScaleUpdateNotification.NotifySignal().Connect( this, &VideoView::UpdateDisplayArea );
 
   mVideoPlayer.SetRenderingTarget( Dali::Adaptor::Get().GetNativeWindowHandle() );
   mVideoPlayer.SetUrl( mUrl );
@@ -636,18 +620,10 @@ void VideoView::SetWindowSurfaceTarget()
     mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_SRC_ALPHA, BlendFactor::ONE );
     mRenderer.SetProperty( Renderer::Property::BLEND_FACTOR_DEST_ALPHA, BlendFactor::ZERO );
   }
-  self.AddRenderer( mRenderer );
-
-  UpdateDisplayArea();
 
   if( mIsPlay )
   {
-    mVideoPlayer.Play();
-  }
-  if( mIsPause )
-  {
-    mVideoPlayer.Play();
-    mVideoPlayer.Pause();
+    Play();
   }
 
   if( curPos > 0 )
@@ -665,7 +641,19 @@ void VideoView::SetNativeImageTarget()
     return;
   }
 
+  if( mIsPlay )
+  {
+    mVideoPlayer.Pause();
+  }
+
   Actor self( Self() );
+  self.RemoveRenderer( mRenderer );
+  Dali::Stage::GetCurrent().KeepRendering( 0.0f );
+
+  self.RemovePropertyNotification( mPositionUpdateNotification );
+  self.RemovePropertyNotification( mSizeUpdateNotification );
+  self.RemovePropertyNotification( mScaleUpdateNotification );
+
   int curPos = mVideoPlayer.GetPlayPosition();
 
   Any source;
@@ -680,21 +668,16 @@ void VideoView::SetNativeImageTarget()
 
   if( mIsPlay )
   {
-    mVideoPlayer.Play();
+    Play();
   }
 
-  if( mIsPause )
-  {
-    mVideoPlayer.Play();
-    mVideoPlayer.Pause();
-  }
   if( curPos > 0 )
   {
     mVideoPlayer.SetPlayPosition( curPos );
   }
 }
 
-void VideoView::UpdateDisplayArea()
+void VideoView::UpdateDisplayArea( Dali::PropertyNotification& source )
 {
   if( !mIsUnderlay )
   {
@@ -731,6 +714,8 @@ void VideoView::SetUnderlay( bool set )
     {
       SetNativeImageTarget();
     }
+
+    RelayoutRequest();
   }
 }
 
index d5a498a..cd7102c 100644 (file)
@@ -23,6 +23,8 @@
 #include <dali/public-api/images/native-image.h>
 #include <dali/devel-api/adaptor-framework/video-player.h>
 #include <dali/integration-api/adaptors/trigger-event-factory.h>
+#include <dali/public-api/object/property-notification.h>
+#include <dali/public-api/object/property-conditions.h>
 
 // INTERNAL INCLUDES
 #include <dali-toolkit/internal/visuals/image/image-visual.h>
@@ -210,7 +212,7 @@ public:
   /**
    * @brief Updates video display area for window rendering target
    */
-  void UpdateDisplayArea();
+  void UpdateDisplayArea( Dali::PropertyNotification& source );
 
   /**
    * @brief Sets underlay flag and initializes new rendering target by flag.
@@ -276,9 +278,9 @@ private:
   std::string mUrl;
   Dali::DisplayArea mDisplayArea;
   Dali::Renderer mRenderer;
-
-  Property::Index mUpdateTriggerPropertyIndex;
-  TriggerEventInterface* mNotification;
+  Dali::PropertyNotification mPositionUpdateNotification;
+  Dali::PropertyNotification mSizeUpdateNotification;
+  Dali::PropertyNotification mScaleUpdateNotification;
 
   int mCurrentVideoPlayPosition;
   bool mIsPlay;