X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Fmanager%2Fupdate-manager.h;h=ae691e3eb33e0620cbea5259a372318d861fc0b7;hb=79881246746f65474b24ea4fe14151ccef8df3f4;hp=401eb8b427cfd753636a3a7bcfc3e6df768ac68d;hpb=cd0ce6e412df8961b1a5e28b496369fa49fd72d7;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/update/manager/update-manager.h b/dali/internal/update/manager/update-manager.h index 401eb8b..ae691e3 100644 --- a/dali/internal/update/manager/update-manager.h +++ b/dali/internal/update/manager/update-manager.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H /* - * Copyright (c) 2018 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -32,12 +32,15 @@ #include #include #include +#include #include #include +#include // for OwnerPointer< FrameCallback > #include // for OwnerPointer< Renderer > #include // for OwnerPointer< TextureSet > #include #include +#include #include // for OwnerPointer< Shader > #include #include @@ -149,14 +152,21 @@ public: /** * Installs a new layer as the root node. - * @pre The UpdateManager does not already have an installed root node. * @pre The layer is of derived Node type Layer. * @pre The layer does not have a parent. * @param[in] layer The new root node. - * @param[in] systemLevel True if using the system-level overlay. * @post The node is owned by UpdateManager. */ - void InstallRoot( OwnerPointer& layer, bool systemLevel ); + void InstallRoot( OwnerPointer& layer ); + + /** + * Uninstalls the root node. + * @pre The layer is of derived Node type Layer. + * @pre The layer does not have a parent. + * @param[in] layer The root node. + * @post The node is owned by UpdateManager. + */ + void UninstallRoot( Layer* layer ); /** * Add a Node; UpdateManager takes ownership. @@ -201,7 +211,7 @@ public: * Remove a camera from scene * @param[in] camera to remove */ - void RemoveCamera( const Camera* camera ); + void RemoveCamera( Camera* camera ); /** * Add a newly created object. @@ -216,6 +226,32 @@ public: */ void RemoveObject( PropertyOwner* object ); + /** + * Add a newly created render task list. + * @param[in] taskList The render task list to add. + * @post The render task list is owned by UpdateManager. + */ + void AddRenderTaskList( OwnerPointer& taskList ); + + /** + * Remove a render task list. + * @param[in] taskList The render task list to remove. + */ + void RemoveRenderTaskList( RenderTaskList* taskList ); + + /** + * Add a newly created scene. + * @param[in] scene The scene to add. + * @post The scene is owned by UpdateManager. + */ + void AddScene( OwnerPointer& scene ); + + /** + * Remove a scene. + * @param[in] scene The scene to remove. + */ + void RemoveScene( Scene* scene ); + // Animations /** @@ -536,7 +572,7 @@ public: * @param[in] frameBuffer The framebuffer to add * The framebuffer will be owned by RenderManager */ - void AddFrameBuffer( Render::FrameBuffer* frameBuffer ); + void AddFrameBuffer( OwnerPointer< Render::FrameBuffer >& frameBuffer ); /** * Removes a FrameBuffer from the render manager @@ -554,6 +590,12 @@ public: */ void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel, uint32_t face ); + /** + * This is called when the surface of the scene has been replaced. + * @param[in] scene The scene. + */ + void SurfaceReplaced( Scene* scene ); + public: /** @@ -572,12 +614,6 @@ public: bool isRenderingToFbo ); /** - * Set the background color i.e. the glClear color used at the beginning of each frame. - * @param[in] color The new background color. - */ - void SetBackgroundColor(const Vector4& color); - - /** * Set the default surface rect. * @param[in] rect The rect value representing the surface. */ @@ -596,9 +632,9 @@ public: /** * Sets the depths of all layers. * @param layers The layers in depth order. - * @param[in] systemLevel True if using the system-level overlay. + * @param[in] rootLayer The root layer of the sorted layers. */ - void SetLayerDepths( const std::vector< Layer* >& layers, bool systemLevel ); + void SetLayerDepths( const std::vector< Layer* >& layers, const Layer* rootLayer ); /** * Set the depth indices of all nodes (in LayerUI's) @@ -614,10 +650,10 @@ public: /** * Adds an implementation of the FrameCallbackInterface. - * @param[in] frameCallback A pointer to the implementation of the FrameCallbackInterface + * @param[in] frameCallback An OwnerPointer to the SceneGraph FrameCallback object * @param[in] rootNode A pointer to the root node to apply the FrameCallback to */ - void AddFrameCallback( FrameCallbackInterface* frameCallback, const Node* rootNode ); + void AddFrameCallback( OwnerPointer< FrameCallback >& frameCallback, const Node* rootNode ); /** * Removes the specified implementation of FrameCallbackInterface. @@ -715,16 +751,30 @@ private: // Messages for UpdateManager -inline void InstallRootMessage( UpdateManager& manager, OwnerPointer& root, bool systemLevel ) +inline void InstallRootMessage( UpdateManager& manager, OwnerPointer& root ) { // Message has ownership of Layer while in transit from event -> update - typedef MessageValue2< UpdateManager, OwnerPointer, bool > LocalType; + typedef MessageValue1< UpdateManager, OwnerPointer > LocalType; + + // Reserve some memory inside the message queue + uint32_t* 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::InstallRoot, root ); +} + +inline void UninstallRootMessage( UpdateManager& manager, const Layer* constRoot ) +{ + // Scene graph thread can destroy this object. + Layer* root = const_cast< Layer* >( constRoot ); + + typedef MessageValue1< UpdateManager, Layer* > LocalType; // Reserve some memory inside the message queue uint32_t* 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::InstallRoot, root, systemLevel ); + new (slot) LocalType( &manager, &UpdateManager::UninstallRoot, root ); } inline void AddNodeMessage( UpdateManager& manager, OwnerPointer& node ) @@ -796,13 +846,13 @@ inline void AddCameraMessage( UpdateManager& manager, OwnerPointer< Camera >& ca inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera ) { - typedef MessageValue1< UpdateManager, const Camera* > LocalType; + typedef MessageValue1< UpdateManager, Camera* > LocalType; // Reserve some memory inside the message queue uint32_t* 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::RemoveCamera, camera ); + new (slot) LocalType( &manager, &UpdateManager::RemoveCamera, const_cast( camera ) ); } inline void AddObjectMessage( UpdateManager& manager, OwnerPointer& object ) @@ -817,7 +867,7 @@ inline void AddObjectMessage( UpdateManager& manager, OwnerPointer LocalType; @@ -825,7 +875,7 @@ inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object ) uint32_t* 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::RemoveObject, object ); + new (slot) LocalType( &manager, &UpdateManager::RemoveObject, const_cast( object ) ); } inline void AddAnimationMessage( UpdateManager& manager, OwnerPointer< SceneGraph::Animation >& animation ) @@ -867,6 +917,56 @@ inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& con new (slot) LocalType( &manager, &UpdateManager::RemoveAnimation, &animation ); } +inline void AddRenderTaskListMessage( UpdateManager& manager, OwnerPointer< SceneGraph::RenderTaskList >& taskList ) +{ + typedef MessageValue1< UpdateManager, OwnerPointer< SceneGraph::RenderTaskList > > LocalType; + + // Reserve some memory inside the message queue + uint32_t* 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::AddRenderTaskList, taskList ); +} + +inline void RemoveRenderTaskListMessage( UpdateManager& manager, const RenderTaskList& constTaskList ) +{ + // The scene-graph thread owns this object so it can safely edit it. + RenderTaskList& taskList = const_cast< RenderTaskList& >( constTaskList ); + + typedef MessageValue1< UpdateManager, RenderTaskList* > LocalType; + + // Reserve some memory inside the message queue + uint32_t* 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::RemoveRenderTaskList, &taskList ); +} + +inline void AddSceneMessage( UpdateManager& manager, OwnerPointer< SceneGraph::Scene >& scene ) +{ + typedef MessageValue1< UpdateManager, OwnerPointer< SceneGraph::Scene > > LocalType; + + // Reserve some memory inside the message queue + uint32_t* 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::AddScene, scene ); +} + +inline void RemoveSceneMessage( UpdateManager& manager, const SceneGraph::Scene& constScene ) +{ + // The scene-graph thread owns this object so it can safely edit it. + Scene& scene = const_cast< Scene& >( constScene ); + + typedef MessageValue1< UpdateManager, Scene* > LocalType; + + // Reserve some memory inside the message queue + uint32_t* 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::RemoveScene, &scene ); +} + inline void AddPropertyNotificationMessage( UpdateManager& manager, OwnerPointer< PropertyNotification >& propertyNotification ) { // Message has ownership of PropertyNotification while in transit from event -> update @@ -922,7 +1022,7 @@ inline void AddShaderMessage( UpdateManager& manager, OwnerPointer< Shader >& sh } // The render thread can safely change the Shader -inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader ) +inline void RemoveShaderMessage( UpdateManager& manager, const Shader* shader ) { typedef MessageValue1< UpdateManager, Shader* > LocalType; @@ -930,11 +1030,11 @@ inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader ) uint32_t* 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::RemoveShader, &shader ); + new (slot) LocalType( &manager, &UpdateManager::RemoveShader, const_cast( shader ) ); } inline void SetShaderProgramMessage( UpdateManager& manager, - Shader& shader, + const Shader& shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry ) { @@ -944,29 +1044,32 @@ inline void SetShaderProgramMessage( UpdateManager& manager, uint32_t* 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::SetShaderProgram, &shader, shaderData, modifiesGeometry ); + new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, const_cast( &shader ), shaderData, modifiesGeometry ); } -inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color ) +inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect& rect ) { - typedef MessageValue1< UpdateManager, Vector4 > LocalType; + typedef MessageValue1< UpdateManager, Rect > LocalType; // Reserve some memory inside the message queue uint32_t* 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::SetBackgroundColor, color ); + new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceRect, rect ); } -inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect& rect ) +inline void SurfaceReplacedMessage( UpdateManager& manager, const SceneGraph::Scene& constScene ) { - typedef MessageValue1< UpdateManager, Rect > LocalType; + // The scene-graph thread owns this object so it can safely edit it. + Scene& scene = const_cast< Scene& >( constScene ); + + typedef MessageValue1< UpdateManager, Scene* > LocalType; // Reserve some memory inside the message queue uint32_t* 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::SetDefaultSurfaceRect, rect ); + new (slot) LocalType( &manager, &UpdateManager::SurfaceReplaced, &scene ); } inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds ) @@ -995,17 +1098,17 @@ inline void SetRenderingBehaviorMessage( UpdateManager& manager, DevelStage::Ren * Create a message for setting the depth of a layer * @param[in] manager The update manager * @param[in] layers list of layers - * @param[in] systemLevel True if the layers are added via the SystemOverlay API + * @param[in] rootLayer The rool layer */ -inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< Layer* >& layers, bool systemLevel ) +inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< Layer* >& layers, const Layer* rootLayer ) { - typedef MessageValue2< UpdateManager, std::vector< Layer* >, bool > LocalType; + typedef MessageValue2< UpdateManager, std::vector< Layer* >, const Layer* > LocalType; // Reserve some memory inside the message queue uint32_t* 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::SetLayerDepths, layers, systemLevel ); + new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, rootLayer ); } inline void AddRendererMessage( UpdateManager& manager, OwnerPointer< Renderer >& object ) @@ -1018,14 +1121,14 @@ inline void AddRendererMessage( UpdateManager& manager, OwnerPointer< Renderer > new (slot) LocalType( &manager, &UpdateManager::AddRenderer, object ); } -inline void RemoveRendererMessage( UpdateManager& manager, Renderer& object ) +inline void RemoveRendererMessage( UpdateManager& manager, const Renderer& object ) { typedef MessageValue1< UpdateManager, Renderer* > LocalType; // Reserve some memory inside the message queue uint32_t* 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::RemoveRenderer, &object ); + new (slot) LocalType( &manager, &UpdateManager::RemoveRenderer, const_cast( &object ) ); } // The render thread can safely change the Shader @@ -1297,15 +1400,15 @@ inline void GenerateMipmapsMessage( UpdateManager& manager, Render::Texture& tex } -inline void AddFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer ) +inline void AddFrameBuffer( UpdateManager& manager, OwnerPointer< Render::FrameBuffer >& frameBuffer ) { - typedef MessageValue1< UpdateManager, Render::FrameBuffer* > LocalType; + typedef MessageValue1< UpdateManager, OwnerPointer< Render::FrameBuffer > > LocalType; // Reserve some memory inside the message queue uint32_t* 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::AddFrameBuffer, &frameBuffer ); + new (slot) LocalType( &manager, &UpdateManager::AddFrameBuffer, frameBuffer ); } inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer ) @@ -1352,15 +1455,15 @@ inline void AddResetterMessage( UpdateManager& manager, OwnerPointer& frameCallback, const Node& rootNode ) { - typedef MessageValue2< UpdateManager, FrameCallbackInterface*, const Node* > LocalType; + typedef MessageValue2< UpdateManager, OwnerPointer< FrameCallback >, const Node* > LocalType; // Reserve some memory inside the message queue uint32_t* 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::AddFrameCallback, &frameCallback, &rootNode ); + new (slot) LocalType( &manager, &UpdateManager::AddFrameCallback, frameCallback, &rootNode ); } inline void RemoveFrameCallbackMessage( UpdateManager& manager, FrameCallbackInterface& frameCallback )