From: taeyoon0.lee Date: Mon, 16 Oct 2017 13:45:23 +0000 (+0900) Subject: Changed constraint to PropertyNotification for updating position/size X-Git-Tag: dali_1.2.63~8 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=commitdiff_plain;h=3297062b74ec6c1e48177974e3d8d7de9b86ff57 Changed constraint to PropertyNotification for updating position/size Change-Id: Id688eebcc2ac0b6ef4520b207d36b225a5379135 --- diff --git a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp index 09cc438..e7fb2cf 100644 --- a/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp +++ b/automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-video-player.cpp @@ -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 ) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp b/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp index 30a7e8c..8baed37 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-VideoView.cpp @@ -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; } diff --git a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp index 5834950..25dff01 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.cpp +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.cpp @@ -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( 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(); } } diff --git a/dali-toolkit/internal/controls/video-view/video-view-impl.h b/dali-toolkit/internal/controls/video-view/video-view-impl.h index d5a498a..cd7102c 100644 --- a/dali-toolkit/internal/controls/video-view/video-view-impl.h +++ b/dali-toolkit/internal/controls/video-view/video-view-impl.h @@ -23,6 +23,8 @@ #include #include #include +#include +#include // INTERNAL INCLUDES #include @@ -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;