[Tizen] Fix the sync issue of window rotation. 92/248792/2
authorWonsik Jung <sidein@samsung.com>
Wed, 2 Dec 2020 07:44:43 +0000 (16:44 +0900)
committerJoogab Yun <joogab.yun@samsung.com>
Wed, 2 Dec 2020 08:49:01 +0000 (17:49 +0900)
To support window rotation, render-manger had a orientation value.
It has effect to the viewport and scissor function in context.
If multiple windows works, this value is reset by the second window.
To fix, the scene should have the orientation value and use each scene/surface/window.

Change-Id: I06c5b55efe94222d56f87ce70e8f4488c09e8c87

dali/internal/event/common/scene-impl.cpp
dali/internal/render/common/render-manager.cpp
dali/internal/render/common/render-manager.h
dali/internal/update/common/scene-graph-scene.cpp
dali/internal/update/common/scene-graph-scene.h
dali/internal/update/manager/update-manager.cpp
dali/internal/update/manager/update-manager.h

index 208c1f7..5d204cb 100755 (executable)
@@ -141,14 +141,13 @@ void Scene::Initialize( Size size, int orientation )
   // Create the default render-task and ensure clear is enabled on it to show the background color
   RenderTaskPtr renderTask = mRenderTaskList->CreateTask( mRootLayer.Get(), mDefaultCamera.Get() );
   renderTask->SetClearEnabled(true);
-  mSurfaceOrientation = orientation;
-
-  SurfaceResized( size.width, size.height, mSurfaceOrientation, false );
 
   // Create scene graph object
   mSceneObject = new SceneGraph::Scene();
   OwnerPointer< SceneGraph::Scene > transferOwnership( const_cast< SceneGraph::Scene* >( mSceneObject ) );
   AddSceneMessage( updateManager, transferOwnership );
+
+  SurfaceResized( size.width, size.height, orientation, false );
 }
 
 void Scene::Add(Actor& actor)
@@ -231,7 +230,7 @@ void Scene::SurfaceResized( float width, float height, int orientation, bool for
     ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal();
     SceneGraph::UpdateManager& updateManager = tls->GetUpdateManager();
     SetDefaultSurfaceRectMessage( updateManager, newSize );
-    SetDefaultSurfaceOrientationMessage( updateManager, mSurfaceOrientation );
+    SetSurfaceOrientationMessage( tls->GetEventThreadServices(), *mSceneObject, mSurfaceOrientation );
 
     // set default render-task viewport parameters
     RenderTaskPtr defaultRenderTask = mRenderTaskList->GetTask( 0u );
index f160f41..2d0f950 100755 (executable)
@@ -77,8 +77,7 @@ struct RenderManager::Impl
     programController( glAbstraction ),
     depthBufferAvailable( depthBufferAvailableParam ),
     stencilBufferAvailable( stencilBufferAvailableParam ),
-    partialUpdateAvailable( partialUpdateAvailableParam ),
-    defaultSurfaceOrientation( 0 )
+    partialUpdateAvailable( partialUpdateAvailableParam )
   {
      // Create thread pool with just one thread ( there may be a need to create more threads in the future ).
     threadPool = std::unique_ptr<Dali::ThreadPool>( new Dali::ThreadPool() );
@@ -175,7 +174,6 @@ struct RenderManager::Impl
   std::unique_ptr<Dali::ThreadPool>         threadPool;               ///< The thread pool
   Vector<GLuint>                            boundTextures;            ///< The textures bound for rendering
   Vector<GLuint>                            textureDependencyList;    ///< The dependency list of binded textures
-  int                                       defaultSurfaceOrientation; ///< defaultSurfaceOrientation for the default surface we are rendering to
 };
 
 RenderManager* RenderManager::New( Integration::GlAbstraction& glAbstraction,
@@ -259,11 +257,6 @@ void RenderManager::SetDefaultSurfaceRect(const Rect<int32_t>& rect)
   mImpl->defaultSurfaceRect = rect;
 }
 
-void RenderManager::SetDefaultSurfaceOrientation( int orientation )
-{
-  mImpl->defaultSurfaceOrientation = orientation;
-}
-
 void RenderManager::AddRenderer( OwnerPointer< Render::Renderer >& renderer )
 {
   // Initialize the renderer as we are now in render thread
@@ -573,12 +566,6 @@ void RenderManager::PreRender( Integration::Scene& scene, std::vector<Rect<int>>
     return;
   }
 
-  // @TODO We need to do partial rendering rotation.
-  if( mImpl->defaultSurfaceOrientation != 0 )
-  {
-    return;
-  }
-
   class DamagedRectsCleaner
   {
   public:
@@ -612,7 +599,6 @@ void RenderManager::PreRender( Integration::Scene& scene, std::vector<Rect<int>>
   DamagedRectsCleaner damagedRectCleaner(damagedRects);
 
 
-
   Internal::Scene& sceneInternal = GetImplementation(scene);
   SceneGraph::Scene* sceneObject = sceneInternal.GetSceneObject();
 
@@ -835,7 +821,7 @@ void RenderManager::RenderScene( Integration::RenderStatus& status, Integration:
     Rect<int32_t> surfaceRect = mImpl->defaultSurfaceRect;
     Integration::DepthBufferAvailable depthBufferAvailable = mImpl->depthBufferAvailable;
     Integration::StencilBufferAvailable stencilBufferAvailable = mImpl->stencilBufferAvailable;
-    int surfaceOrientation = mImpl->defaultSurfaceOrientation;
+    int surfaceOrientation = sceneObject->GetSurfaceOrientation();
 
     if ( instruction.mFrameBuffer )
     {
index dd6ce7a..2e3ea2d 100644 (file)
@@ -131,12 +131,6 @@ public:
   void SetDefaultSurfaceRect( const Rect<int>& rect );
 
   /**
-   * Returns the orintation for the default surface (probably the application window).
-   * @return Orientation for the surface.
-   */
-  void SetDefaultSurfaceOrientation( int orientation );
-
-  /**
    * Add a Renderer to the render manager.
    * @param[in] renderer The renderer to add.
    * @post renderer is owned by RenderManager
index 9b7ddcc..2008992 100644 (file)
@@ -31,7 +31,8 @@ namespace SceneGraph
 Scene::Scene()
 : mContext( nullptr ),
   mFrameRenderedCallbacks(),
-  mFramePresentedCallbacks()
+  mFramePresentedCallbacks(),
+  mSurfaceOrientation( 0 )
 {
 }
 
@@ -88,6 +89,16 @@ void Scene::GetFramePresentedCallback( Dali::Integration::Scene::FrameCallbackCo
   mFramePresentedCallbacks.clear();
 }
 
+void Scene::SetSurfaceOrientation( int orientation )
+{
+  mSurfaceOrientation = orientation;
+}
+
+int Scene::GetSurfaceOrientation() const
+{
+  return mSurfaceOrientation;
+}
+
 } //SceneGraph
 
 } //Internal
index 97af1d5..640189b 100644 (file)
@@ -115,6 +115,22 @@ public:
    */
   void GetFramePresentedCallback( Dali::Integration::Scene::FrameCallbackContainer& callbacks );
 
+  /**
+   * Set the surface orientation when surface is rotated.
+   *
+   * @param[in] scene The rotated scene.
+   * @param[in] orientation The orientation value representing the surface.
+   */
+  void SetSurfaceOrientation( int orientation );
+
+  /**
+   * Get the surface orientation.
+   *
+   * @param[in] scene The rotated scene.
+   * @return the current surface orientation
+   */
+  int GetSurfaceOrientation() const;
+
 private:
 
   Context*                    mContext;   ///< The context holding the GL state of rendering for the scene, not owned
@@ -126,6 +142,8 @@ private:
 
   Dali::Integration::Scene::FrameCallbackContainer mFrameRenderedCallbacks;   ///< Frame rendered callbacks
   Dali::Integration::Scene::FrameCallbackContainer mFramePresentedCallbacks;  ///< Frame presented callbacks
+
+  int                         mSurfaceOrientation;
 };
 
 /// Messages
@@ -151,6 +169,17 @@ inline void AddFramePresentedCallbackMessage( EventThreadServices& eventThreadSe
   new (slot) LocalType( &scene, &Scene::AddFramePresentedCallback, const_cast< CallbackBase* >( callback ), frameId );
 }
 
+inline void SetSurfaceOrientationMessage( EventThreadServices& eventThreadServices, const Scene& scene, int orientation )
+{
+  using LocalType = MessageValue1<Scene, int>;
+
+  // Reserve some memory inside the message queue
+  uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &scene, &Scene::SetSurfaceOrientation, orientation );
+}
+
 } // namespace SceneGraph
 
 } // namespace Internal
index f29997a..58fb0bc 100644 (file)
@@ -1129,17 +1129,6 @@ void UpdateManager::SurfaceReplaced( Scene* scene )
   new (slot) DerivedType( &mImpl->renderManager,  &RenderManager::SurfaceReplaced, scene );
 }
 
-void UpdateManager::SetDefaultSurfaceOrientation( int orientation )
-{
-  typedef MessageValue1< RenderManager, int > DerivedType;
-
-  // Reserve some memory inside the render queue
-  unsigned int* slot = mImpl->renderQueue.ReserveMessageSlot( mSceneGraphBuffers.GetUpdateBufferIndex(), sizeof( DerivedType ) );
-
-  // Construct message in the render queue memory; note that delete should not be called on the return value
-  new (slot) DerivedType( &mImpl->renderManager,  &RenderManager::SetDefaultSurfaceOrientation, orientation );
-}
-
 void UpdateManager::KeepRendering( float durationSeconds )
 {
   mImpl->keepRenderingSeconds = std::max( mImpl->keepRenderingSeconds, durationSeconds );
index 194dd29..73e0f38 100644 (file)
@@ -634,12 +634,6 @@ public:
   void SetDefaultSurfaceRect( const Rect<int>& rect );
 
   /**
-   * Set the default surface orientation.
-   * @param[in] orientation The orientation value representing the surface.
-   */
-  void SetDefaultSurfaceOrientation( int orientation );
-
-  /**
    * @copydoc Dali::Stage::KeepRendering()
    */
   void KeepRendering( float durationSeconds );
@@ -1092,17 +1086,6 @@ inline void SurfaceReplacedMessage( UpdateManager& manager, const SceneGraph::Sc
   new (slot) LocalType( &manager, &UpdateManager::SurfaceReplaced, &scene );
 }
 
-inline void SetDefaultSurfaceOrientationMessage( UpdateManager& manager, int orientation  )
-{
-  typedef MessageValue1< UpdateManager, int > LocalType;
-
-  // Reserve some memory inside the message queue
-  unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
-
-  // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceOrientation, orientation );
-}
-
 inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
 {
   using LocalType = MessageValue1<UpdateManager, float>;