From 015ba79aa2f5a4da9b07d79f8252d635a752a0f3 Mon Sep 17 00:00:00 2001 From: Wonsik Jung Date: Wed, 2 Dec 2020 16:44:43 +0900 Subject: [PATCH] [Tizen] Fix the sync issue of window rotation. 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 | 7 +++--- dali/internal/render/common/render-manager.cpp | 18 ++------------ dali/internal/render/common/render-manager.h | 6 ----- dali/internal/update/common/scene-graph-scene.cpp | 13 +++++++++- dali/internal/update/common/scene-graph-scene.h | 29 +++++++++++++++++++++++ dali/internal/update/manager/update-manager.cpp | 11 --------- dali/internal/update/manager/update-manager.h | 17 ------------- 7 files changed, 46 insertions(+), 55 deletions(-) diff --git a/dali/internal/event/common/scene-impl.cpp b/dali/internal/event/common/scene-impl.cpp index 208c1f7..5d204cb 100755 --- a/dali/internal/event/common/scene-impl.cpp +++ b/dali/internal/event/common/scene-impl.cpp @@ -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 ); diff --git a/dali/internal/render/common/render-manager.cpp b/dali/internal/render/common/render-manager.cpp index f160f41..2d0f950 100755 --- a/dali/internal/render/common/render-manager.cpp +++ b/dali/internal/render/common/render-manager.cpp @@ -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( new Dali::ThreadPool() ); @@ -175,7 +174,6 @@ struct RenderManager::Impl std::unique_ptr threadPool; ///< The thread pool Vector boundTextures; ///< The textures bound for rendering Vector 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& 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> 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> 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 surfaceRect = mImpl->defaultSurfaceRect; Integration::DepthBufferAvailable depthBufferAvailable = mImpl->depthBufferAvailable; Integration::StencilBufferAvailable stencilBufferAvailable = mImpl->stencilBufferAvailable; - int surfaceOrientation = mImpl->defaultSurfaceOrientation; + int surfaceOrientation = sceneObject->GetSurfaceOrientation(); if ( instruction.mFrameBuffer ) { diff --git a/dali/internal/render/common/render-manager.h b/dali/internal/render/common/render-manager.h index dd6ce7a..2e3ea2d 100644 --- a/dali/internal/render/common/render-manager.h +++ b/dali/internal/render/common/render-manager.h @@ -131,12 +131,6 @@ public: void SetDefaultSurfaceRect( const Rect& 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 diff --git a/dali/internal/update/common/scene-graph-scene.cpp b/dali/internal/update/common/scene-graph-scene.cpp index 9b7ddcc..2008992 100644 --- a/dali/internal/update/common/scene-graph-scene.cpp +++ b/dali/internal/update/common/scene-graph-scene.cpp @@ -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 diff --git a/dali/internal/update/common/scene-graph-scene.h b/dali/internal/update/common/scene-graph-scene.h index 97af1d5..640189b 100644 --- a/dali/internal/update/common/scene-graph-scene.h +++ b/dali/internal/update/common/scene-graph-scene.h @@ -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; + + // 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 diff --git a/dali/internal/update/manager/update-manager.cpp b/dali/internal/update/manager/update-manager.cpp index f29997a..58fb0bc 100644 --- a/dali/internal/update/manager/update-manager.cpp +++ b/dali/internal/update/manager/update-manager.cpp @@ -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 ); diff --git a/dali/internal/update/manager/update-manager.h b/dali/internal/update/manager/update-manager.h index 194dd29..73e0f38 100644 --- a/dali/internal/update/manager/update-manager.h +++ b/dali/internal/update/manager/update-manager.h @@ -634,12 +634,6 @@ public: void SetDefaultSurfaceRect( const Rect& 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; -- 2.7.4