[Tizen] Use SceneHolder::Get() instead of Window::Get() 13/298513/2
authorHeeyong Song <heeyong.song@samsung.com>
Mon, 5 Jun 2023 08:53:11 +0000 (17:53 +0900)
committerseungho baek <sbsh.baek@samsung.com>
Tue, 12 Sep 2023 11:19:38 +0000 (20:19 +0900)
To support off-screen window

Change-Id: I5d12ab14190a98b90904637a6b2d1c89d8a70c09

automated-tests/src/dali-toolkit/dali-toolkit-test-utils/toolkit-scene-holder.cpp
dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp
dali-scene3d/internal/controls/scene-view/scene-view-impl.h
dali-toolkit/internal/text/controller/text-controller-impl.cpp

index 132ce79..22a027b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,8 +15,8 @@
  *
  */
 
-#include <dali/integration-api/events/touch-event-integ.h>
 #include <dali/integration-api/adaptor-framework/scene-holder.h>
+#include <dali/integration-api/events/touch-event-integ.h>
 
 #include <toolkit-scene-holder-impl.h>
 
 #include <dali/public-api/object/base-object.h>
 
 #include <dali/integration-api/adaptor-framework/adaptor.h>
-#include <toolkit-adaptor-impl.h>
 #include <dali/public-api/render-tasks/render-task-list.h>
+#include <toolkit-adaptor-impl.h>
 
 using AdaptorImpl = Dali::Internal::Adaptor::Adaptor;
 
 namespace Dali
 {
-
 ///////////////////////////////////////////////////////////////////////////////
 //
 // Dali::Internal::Adaptor::SceneHolder Stub
@@ -41,32 +40,30 @@ namespace Dali
 
 namespace Internal
 {
-
 namespace Adaptor
 {
-
-SceneHolder::SceneHolder( const Dali::Rect<int>& positionSize )
-: mRenderSurface( positionSize ),
-  mScene( Dali::Integration::Scene::New( Dali::Size( static_cast<float>( positionSize.width ), static_cast<float>( positionSize.height ) ) ) )
+SceneHolder::SceneHolder(const Dali::Rect<int>& positionSize)
+: mRenderSurface(positionSize),
+  mScene(Dali::Integration::Scene::New(Dali::Size(static_cast<float>(positionSize.width), static_cast<float>(positionSize.height))))
 {
 }
 
 SceneHolder::~SceneHolder()
 {
-  if ( Dali::Adaptor::IsAvailable() )
+  if(Dali::Adaptor::IsAvailable())
   {
-    AdaptorImpl::GetImpl( AdaptorImpl::Get() ).RemoveWindow( this );
+    AdaptorImpl::GetImpl(AdaptorImpl::Get()).RemoveWindow(this);
   }
 }
 
-void SceneHolder::Add( Dali::Actor actor )
+void SceneHolder::Add(Dali::Actor actor)
 {
-  mScene.Add( actor );
+  mScene.Add(actor);
 }
 
-void SceneHolder::Remove( Dali::Actor actor )
+void SceneHolder::Remove(Dali::Actor actor)
 {
-  mScene.Remove( actor );
+  mScene.Remove(actor);
 }
 
 Dali::Layer SceneHolder::GetRootLayer() const
@@ -74,9 +71,9 @@ Dali::Layer SceneHolder::GetRootLayer() const
   return mScene.GetRootLayer();
 }
 
-void SceneHolder::SetBackgroundColor( Vector4 color )
+void SceneHolder::SetBackgroundColor(Vector4 color)
 {
-  return mScene.SetBackgroundColor( color );
+  return mScene.SetBackgroundColor(color);
 }
 
 Vector4 SceneHolder::GetBackgroundColor() const
@@ -84,15 +81,15 @@ Vector4 SceneHolder::GetBackgroundColor() const
   return mScene.GetBackgroundColor();
 }
 
-void SceneHolder::FeedTouchPoint( Dali::TouchPoint& point, int timeStamp )
+void SceneHolder::FeedTouchPoint(Dali::TouchPoint& point, int timeStamp)
 {
 }
 
-void SceneHolder::FeedWheelEvent( Dali::WheelEvent& wheelEvent )
+void SceneHolder::FeedWheelEvent(Dali::WheelEvent& wheelEvent)
 {
 }
 
-void SceneHolder::FeedKeyEvent( Dali::KeyEvent& keyEvent )
+void SceneHolder::FeedKeyEvent(Dali::KeyEvent& keyEvent)
 {
 }
 
@@ -148,7 +145,6 @@ Dali::RenderTaskList SceneHolder::GetRenderTaskList()
 
 namespace Integration
 {
-
 SceneHolder::SceneHolder()
 {
   // Dali::Internal::Adaptor::Adaptor::Get().WindowCreatedSignal().Emit( *this );
@@ -158,99 +154,104 @@ SceneHolder::~SceneHolder()
 {
 }
 
-SceneHolder::SceneHolder( const SceneHolder& handle )
+SceneHolder::SceneHolder(const SceneHolder& handle)
 : BaseHandle(handle)
 {
 }
 
-SceneHolder::SceneHolder( Internal::Adaptor::SceneHolder* internal )
+SceneHolder::SceneHolder(Internal::Adaptor::SceneHolder* internal)
 : BaseHandle(internal)
 {
 }
 
-SceneHolder& SceneHolder::operator=( const SceneHolder& rhs )
+SceneHolder& SceneHolder::operator=(const SceneHolder& rhs)
 {
   BaseHandle::operator=(rhs);
   return *this;
 }
 
-Dali::Integration::SceneHolder SceneHolder::Get( Dali::Actor actor )
+Dali::Integration::SceneHolder SceneHolder::Get(Dali::Actor actor)
 {
   Internal::Adaptor::SceneHolder* sceneHolderImpl = nullptr;
 
-  if ( Dali::Adaptor::IsAvailable() )
+  if(Dali::Adaptor::IsAvailable())
   {
-    sceneHolderImpl = AdaptorImpl::GetImpl( AdaptorImpl::Get() ).GetWindow( actor );
+    sceneHolderImpl = AdaptorImpl::GetImpl(AdaptorImpl::Get()).GetWindow(actor);
   }
 
-  return Dali::Integration::SceneHolder( sceneHolderImpl );
+  return Dali::Integration::SceneHolder(sceneHolderImpl);
 }
 
-void SceneHolder::Add( Actor actor )
+void SceneHolder::Add(Actor actor)
 {
-  GetImplementation( *this ).Add( actor );
+  GetImplementation(*this).Add(actor);
 }
 
-void SceneHolder::Remove( Actor actor )
+void SceneHolder::Remove(Actor actor)
 {
-  GetImplementation( *this ).Remove( actor );
+  GetImplementation(*this).Remove(actor);
 }
 
 Dali::Layer SceneHolder::GetRootLayer() const
 {
-  return GetImplementation( *this ).GetRootLayer();
+  return GetImplementation(*this).GetRootLayer();
 }
 
-void SceneHolder::SetBackgroundColor( Vector4 color )
+void SceneHolder::SetBackgroundColor(Vector4 color)
 {
-  GetImplementation( *this ).SetBackgroundColor( color );
+  GetImplementation(*this).SetBackgroundColor(color);
 }
 
 Vector4 SceneHolder::GetBackgroundColor() const
 {
-  return GetImplementation( *this ).GetBackgroundColor();
+  return GetImplementation(*this).GetBackgroundColor();
+}
+
+void SceneHolder::FeedTouchPoint(Dali::TouchPoint& point, int timeStamp)
+{
+  GetImplementation(*this).FeedTouchPoint(point, timeStamp);
 }
 
-void SceneHolder::FeedTouchPoint( Dali::TouchPoint& point, int timeStamp )
+void SceneHolder::FeedWheelEvent(Dali::WheelEvent& wheelEvent)
 {
-  GetImplementation( *this ).FeedTouchPoint( point, timeStamp );
+  GetImplementation(*this).FeedWheelEvent(wheelEvent);
 }
 
-void SceneHolder::FeedWheelEvent( Dali::WheelEvent& wheelEvent )
+void SceneHolder::FeedKeyEvent(Dali::KeyEvent& keyEvent)
 {
-  GetImplementation( *this ).FeedWheelEvent( wheelEvent );
+  GetImplementation(*this).FeedKeyEvent(keyEvent);
 }
 
-void SceneHolder::FeedKeyEvent( Dali::KeyEvent& keyEvent )
+RenderTaskList SceneHolder::GetRenderTaskList()
 {
-  GetImplementation( *this ).FeedKeyEvent( keyEvent );
+  return GetImplementation(*this).GetRenderTaskList();
 }
 
 SceneHolder::KeyEventSignalType& SceneHolder::KeyEventSignal()
 {
-  return GetImplementation( *this ).KeyEventSignal();
+  return GetImplementation(*this).KeyEventSignal();
 }
 
 SceneHolder::KeyEventGeneratedSignalType& SceneHolder::KeyEventGeneratedSignal()
 {
-  return GetImplementation( *this ).KeyEventGeneratedSignal();
+  return GetImplementation(*this).KeyEventGeneratedSignal();
 }
 
 SceneHolder::TouchEventSignalType& SceneHolder::TouchedSignal()
 {
-  return GetImplementation( *this ).TouchedSignal();
+  return GetImplementation(*this).TouchedSignal();
 }
 
 SceneHolder::WheelEventSignalType& SceneHolder::WheelEventSignal()
 {
-  return GetImplementation( *this ).WheelEventSignal();
+  return GetImplementation(*this).WheelEventSignal();
 }
 
 SceneHolder::WheelEventGeneratedSignalType& SceneHolder::WheelEventGeneratedSignal()
 {
-  return GetImplementation( *this ).WheelEventGeneratedSignal();
+  return GetImplementation(*this).WheelEventGeneratedSignal();
 }
 
-} // Integration
+} // namespace Integration
 
-} // Dali
+} // namespace Dali
index e7d6542..65298a2 100644 (file)
@@ -571,8 +571,18 @@ void SceneView::OnSceneConnection(int depth)
   Window window = DevelWindow::Get(Self());
   if(window)
   {
+    // Only for on-screen window
     window.ResizeSignal().Connect(this, &SceneView::OnWindowResized);
-    RenderTaskList taskList = window.GetRenderTaskList();
+
+    mWindow            = window;
+    mWindowOrientation = DevelWindow::GetPhysicalOrientation(window);
+  }
+
+  // On-screen / Off-screen window
+  mSceneHolder = Integration::SceneHolder::Get(Self());
+  if(mSceneHolder)
+  {
+    RenderTaskList taskList = mSceneHolder.GetRenderTaskList();
     mRenderTask             = taskList.CreateTask();
     mRenderTask.SetSourceActor(mRootLayer);
     mRenderTask.SetExclusive(true);
@@ -581,7 +591,6 @@ void SceneView::OnSceneConnection(int depth)
     mRenderTask.SetScreenToFrameBufferMappingActor(Self());
 
     UpdateRenderTask();
-    mWindow = window;
   }
 
   Control::OnSceneConnection(depth);
@@ -595,15 +604,20 @@ void SceneView::OnSceneDisconnection()
   if(window)
   {
     window.ResizeSignal().Disconnect(this, &SceneView::OnWindowResized);
-    RenderTaskList taskList = window.GetRenderTaskList();
+  }
+  mWindow.Reset();
+
+  if(mSceneHolder)
+  {
     if(mRenderTask)
     {
+      RenderTaskList taskList = mSceneHolder.GetRenderTaskList();
       taskList.RemoveTask(mRenderTask);
       mRenderTask.Reset();
-      mFrameBuffer.Reset();
     }
+    mSceneHolder.Reset();
   }
-  mWindow.Reset();
+  mFrameBuffer.Reset();
 
   Control::OnSceneDisconnection();
 }
index 0730a2c..79f7d90 100644 (file)
@@ -21,6 +21,7 @@
 // EXTERNAL INCLUDES
 #include <dali-toolkit/internal/visuals/image/image-visual.h>
 #include <dali-toolkit/public-api/controls/control-impl.h>
+#include <dali/integration-api/adaptor-framework/scene-holder.h>
 #include <dali/public-api/actors/camera-actor.h>
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/adaptor-framework/window.h>
@@ -327,6 +328,7 @@ private:
   /////////////////////////////////////////////////////////////
   // FrameBuffer and Rendertask to render child objects as a 3D Scene
   Dali::WeakHandle<Dali::Window>                           mWindow;
+  Integration::SceneHolder                                 mSceneHolder;
   CameraActor                                              mDefaultCamera;
   CameraActor                                              mSelectedCamera;
   std::vector<CameraActor>                                 mCameras;
index 2405862..03e51ef 100644 (file)
@@ -19,7 +19,7 @@
 #include <dali-toolkit/internal/text/controller/text-controller-impl.h>
 
 // EXTERNAL INCLUDES
-#include <dali/devel-api/adaptor-framework/window-devel.h>
+#include <dali/integration-api/adaptor-framework/scene-holder.h>
 #include <dali/integration-api/debug.h>
 #include <dali/public-api/actors/layer.h>
 #include <dali/public-api/rendering/renderer.h>
@@ -527,8 +527,8 @@ Dali::LayoutDirection::Type Controller::Impl::GetLayoutDirection(Dali::Actor& ac
   if(mModel->mMatchLayoutDirection == DevelText::MatchLayoutDirection::LOCALE ||
      (mModel->mMatchLayoutDirection == DevelText::MatchLayoutDirection::INHERIT && !mIsLayoutDirectionChanged))
   {
-    Window window = DevelWindow::Get(actor);
-    return static_cast<Dali::LayoutDirection::Type>(window ? window.GetRootLayer().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>() : LayoutDirection::LEFT_TO_RIGHT);
+    Integration::SceneHolder sceneHolder = Integration::SceneHolder::Get(actor);
+    return static_cast<Dali::LayoutDirection::Type>(sceneHolder ? sceneHolder.GetRootLayer().GetProperty(Dali::Actor::Property::LAYOUT_DIRECTION).Get<int>() : LayoutDirection::LEFT_TO_RIGHT);
   }
   else
   {