From: Sunghyun Kim Date: Mon, 7 Sep 2020 05:44:28 +0000 (+0900) Subject: Add Notification for check WidgetView is culled X-Git-Tag: submit/tizen/20200910.200255^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb2418d66545ae33e271c9c521abee5c94db76dd;p=platform%2Fcore%2Fuifw%2Fwidget-viewer-dali.git Add Notification for check WidgetView is culled If WidgetView is out of the screen, Widget need to be paused. For this, we added notification for check it. Change-Id: I457b39d3a5477c205c6c0f946174651dd844322a --- diff --git a/widget_viewer_dali/internal/widget_view/widget_view_impl.cpp b/widget_viewer_dali/internal/widget_view/widget_view_impl.cpp index 031d476..b18acdc 100644 --- a/widget_viewer_dali/internal/widget_view/widget_view_impl.cpp +++ b/widget_viewer_dali/internal/widget_view/widget_view_impl.cpp @@ -309,7 +309,9 @@ WidgetView::WidgetView() mBuffer( NULL ), mReloadFlag( false ), mCreated( false ), - mResizeRequired( false ) + mResizeRequired( false ), + mCulled( false ), + mPausedManually( false ) { } @@ -335,7 +337,9 @@ WidgetView::WidgetView( const std::string& widgetId, const std::string& contentI mBuffer( NULL ), mReloadFlag( false ), mCreated( false ), - mResizeRequired( false ) + mResizeRequired( false ), + mCulled( false ), + mPausedManually( false ) { } @@ -344,6 +348,18 @@ WidgetView::~WidgetView() } bool WidgetView::PauseWidget() +{ + mPausedManually = true; + return PauseWidgetInternally(); +} + +bool WidgetView::ResumeWidget() +{ + mPausedManually = false; + return ResumeWidgetInternally(); +} + +bool WidgetView::PauseWidgetInternally() { int ret = widget_instance_pause( mInstanceId.c_str() ); if( ret < 0 ) @@ -362,7 +378,7 @@ bool WidgetView::PauseWidget() return true; } -bool WidgetView::ResumeWidget() +bool WidgetView::ResumeWidgetInternally() { int ret = widget_instance_resume( mInstanceId.c_str() ); if( ret < 0 ) @@ -622,6 +638,10 @@ bool WidgetView::TerminateWidget() mCreated = false; mResizeRequired = false; + mPausedManually = false; + + Self().RemovePropertyNotification( mViewCulledNotification ); + return true; } @@ -1060,12 +1080,18 @@ void WidgetView::OnInitialize() return; } + // Add Notification for check WidgetView is culled or not. + mViewCulledNotification = Self().AddPropertyNotification( Actor::Property::CULLED, LessThanCondition( 0.5f ) ); + mViewCulledNotification.SetNotifyMode( PropertyNotification::NOTIFY_ON_CHANGED ); + mViewCulledNotification.NotifySignal().Connect( this, &WidgetView::OnChangeCulled ); + ops.updated_cb = OnBufferUpdated; ops.removed_cb = OnSurfaceRemoved; ops.added_cb = OnBufferAdded; mWatcherHandle = screen_connector_toolkit_add(&ops, (char *)instanceId, SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET, this); DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::OnInitialize: widget_instance_launch is called. [%s, mPid = %d]\n", mWidgetId.c_str(), mPid ); widget_service_set_lifecycle_event_cb( mWidgetId.c_str(), WidgetLifeCycleCallback, this ); + } void WidgetView::OnSceneConnection( int depth ) @@ -1101,6 +1127,31 @@ void WidgetView::OnWindowVisibilityChanged( Window window, bool visible ) DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::OnWindowVisibilityChanged: visibility is changed (visible: %d)\n", visible ); } +void WidgetView::OnChangeCulled( Dali::PropertyNotification& source ) +{ + bool isCulled = Self().GetProperty( Actor::Property::CULLED ).Get< bool >(); + + if( mPausedManually ) + { + mCulled = isCulled; + DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "Do not resume widget, because widget is paued manually \n"); + return; + } + + if( mCulled != isCulled ) + { + if( isCulled ) + { + PauseWidgetInternally(); + } + else + { + ResumeWidgetInternally(); + } + mCulled = isCulled; + } +} + void WidgetView::OnSizeSet( const Vector3& targetSize ) { } diff --git a/widget_viewer_dali/internal/widget_view/widget_view_impl.h b/widget_viewer_dali/internal/widget_view/widget_view_impl.h index 5672989..113c8b2 100644 --- a/widget_viewer_dali/internal/widget_view/widget_view_impl.h +++ b/widget_viewer_dali/internal/widget_view/widget_view_impl.h @@ -32,6 +32,7 @@ #include #include #include +#include namespace Dali { @@ -287,11 +288,26 @@ private: // From Control virtual void OnSizeAnimation( Animation& animation, const Vector3& targetSize ) override ; private: + /** + * @brief Call a PauseWidget internally + */ + bool PauseWidgetInternally(); + + /** + * @brief Call a ResumeWidget internally + */ + bool ResumeWidgetInternally(); + /** * @brief Callback when the visibility of the window is changed. */ void OnWindowVisibilityChanged( Window window, bool visible ); + /** + * @brief Callback when the actor is out of the view frustum. + */ + void OnChangeCulled( Dali::PropertyNotification& source ); + // Undefined WidgetView( const WidgetView& ); @@ -336,8 +352,11 @@ private: bool mReloadFlag; bool mCreated; bool mResizeRequired; + bool mCulled; + bool mPausedManually; Dali::Property::Map mEffectPropertyMap; + Dali::PropertyNotification mViewCulledNotification; // Signals Dali::WidgetView::WidgetView::WidgetViewSignalType mWidgetAddedSignal;