#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/object/property-array.h>
+#include <dali/public-api/render-tasks/render-task-list.h>
+#include <dali/public-api/render-tasks/render-task.h>
+#include <dali/public-api/actors/camera-actor.h>
#include <dali-toolkit/public-api/visuals/visual-properties.h>
#include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
#include <dali/integration-api/debug.h>
mReloadFlag( false ),
mCreated( false ),
mResizeRequired( false ),
- mCulled( false ),
+ mPaused( false ),
mPausedManually( false )
{
}
mReloadFlag( false ),
mCreated( false ),
mResizeRequired( false ),
- mCulled( false ),
+ mPaused( false ),
mPausedManually( false )
{
}
tizen_remote_surface_transfer_visibility( mRemoteSurface, TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_INVISIBLE);
}
- DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::PauseWidget: Widget is paused (%s, %s)\n", mWidgetId.c_str(), mInstanceId.c_str() );
+ DALI_LOG_RELEASE_INFO("WidgetView::PauseWidget: Widget is paused (%s, %s)\n", mWidgetId.c_str(), mInstanceId.c_str() );
return true;
}
tizen_remote_surface_transfer_visibility( mRemoteSurface, TIZEN_REMOTE_SURFACE_VISIBILITY_TYPE_VISIBLE);
}
- DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::ResumeWidget: Widget is resumed (%s, %s)\n", mWidgetId.c_str(), mInstanceId.c_str() );
+ DALI_LOG_RELEASE_INFO("WidgetView::ResumeWidget: Widget is resumed (%s, %s)\n", mWidgetId.c_str(), mInstanceId.c_str() );
return true;
}
+bool WidgetView::IsOutOfScreen()
+{
+ Actor self = Self();
+ Window window = DevelWindow::Get( self );
+ RenderTaskList taskList = window.GetRenderTaskList();
+ RenderTask task = taskList.GetTask( 0u );
+ Vector3 cameraPosition = task.GetCameraActor().GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
+ Vector3 worldPosition = self.GetProperty( Actor::Property::WORLD_POSITION ).Get< Vector3 >();
+ Vector2 size = self.GetProperty( Actor::Property::SIZE ).Get< Vector2 >();
+ Vector3 worldScale = self.GetProperty( Actor::Property::WORLD_SCALE ).Get< Vector3 >();
+
+ Vector2 windowSize = window.GetSize();
+ worldPosition -= cameraPosition;
+
+ Vector2 actorSize = Vector2(size.width*worldScale.x , size.height*worldScale.y);
+ if( worldPosition.x >= (-0.5f)*(actorSize.width + windowSize.width) && worldPosition.x <= (0.5f)*(actorSize.width + windowSize.width) )
+ {
+ if( worldPosition.y >= (-0.5f)*(actorSize.height + windowSize.height) && worldPosition.y <= (0.5f)*(actorSize.height + windowSize.height) )
+ {
+ return false;
+ }
+ }
+ return true;
+}
+
const std::string& WidgetView::GetWidgetId() const
{
return mWidgetId;
mResizeRequired = false;
mPausedManually = false;
- Self().RemovePropertyNotification( mViewCulledNotification );
-
return true;
}
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;
if( window )
{
DevelWindow::VisibilityChangedSignal( window ).Connect( this, &WidgetView::OnWindowVisibilityChanged );
+
+ // Add Notification for check WidgetView is out-of-screen or not.
+ auto self = Self();
+ mPositionUpdateNotification = self.AddPropertyNotification( Actor::Property::WORLD_POSITION, StepCondition( 1.0f, 1.0f ) );
+ mPositionUpdateNotification.SetNotifyMode( PropertyNotification::NOTIFY_ON_CHANGED );
+ mSizeUpdateNotification = self.AddPropertyNotification( Actor::Property::SIZE, StepCondition( 1.0f, 1.0f ) );
+ mSizeUpdateNotification.SetNotifyMode( PropertyNotification::NOTIFY_ON_CHANGED );
+ mScaleUpdateNotification = self.AddPropertyNotification( Actor::Property::WORLD_SCALE, StepCondition( 0.1f, 1.0f ) );
+ mScaleUpdateNotification.SetNotifyMode( PropertyNotification::NOTIFY_ON_CHANGED );
+
+ mPositionUpdateNotification.NotifySignal().Connect( this, &WidgetView::OnUpdateArea );
+ mSizeUpdateNotification.NotifySignal().Connect( this, &WidgetView::OnUpdateArea );
+ mScaleUpdateNotification.NotifySignal().Connect( this, &WidgetView::OnUpdateArea );
}
}
if( window )
{
DevelWindow::VisibilityChangedSignal( window ).Disconnect( this, &WidgetView::OnWindowVisibilityChanged );
+
+ Self().RemovePropertyNotification( mPositionUpdateNotification );
+ Self().RemovePropertyNotification( mSizeUpdateNotification );
+ Self().RemovePropertyNotification( mScaleUpdateNotification );
}
}
void WidgetView::OnWindowVisibilityChanged( Window window, bool visible )
{
+ bool needPaused = IsOutOfScreen();
+ if( mPausedManually )
+ {
+ mPaused = ( needPaused || !visible );
+ DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "Do not resume widget, because widget is paued manually \n");
+ return;
+ }
+
if( visible )
{
- ResumeWidget();
+ if( !needPaused)
+ {
+ ResumeWidgetInternally();
+ }
}
else
{
- PauseWidget();
+ PauseWidgetInternally();
}
+
DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "WidgetView::OnWindowVisibilityChanged: visibility is changed (visible: %d)\n", visible );
}
-void WidgetView::OnChangeCulled( Dali::PropertyNotification& source )
+void WidgetView::OnUpdateArea( Dali::PropertyNotification& source )
{
- bool isCulled = Self().GetProperty( Actor::Property::CULLED ).Get< bool >();
-
+ bool needPaused = IsOutOfScreen();
if( mPausedManually )
{
- mCulled = isCulled;
+ mPaused = needPaused;
DALI_LOG_INFO( gWidgetViewLogging, Debug::Verbose, "Do not resume widget, because widget is paued manually \n");
return;
}
- if( mCulled != isCulled )
+ if( mPaused != needPaused )
{
- if( isCulled )
+ if( needPaused )
{
PauseWidgetInternally();
}
{
ResumeWidgetInternally();
}
- mCulled = isCulled;
+ mPaused = needPaused;
}
}