X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Fmanager%2Fupdate-manager.h;h=d87d2800e2e581d8ed7e8f4596bdd7744fd4f1bf;hb=9a41846041641c88506ce68ab9fd64e6b3ab0d9d;hp=8ccae95991962c6e13af5cdeb05c0c46b966a6e0;hpb=fe734e2366230b39aec4063f1b07f567fc0523a6;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 8ccae95..d87d280 100644 --- a/dali/internal/update/manager/update-manager.h +++ b/dali/internal/update/manager/update-manager.h @@ -1,8 +1,8 @@ -#ifndef __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__ -#define __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__ +#ifndef DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H +#define DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H /* - * Copyright (c) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 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. @@ -22,26 +22,31 @@ #include #include -#include +#include #include #include #include #include #include +#include #include #include -#include -#include #include #include -#include -#include +#include // for OwnerPointer< Renderer > +#include // for OwnerPointer< TextureSet > +#include +#include +#include // for OwnerPointer< Shader > #include +#include namespace Dali { +class FrameCallbackInterface; + namespace Integration { class GlSyncAbstraction; @@ -55,12 +60,12 @@ namespace Internal class PropertyNotifier; class NotificationManager; class CompleteNotificationInterface; -class ResourceManager; class TouchResampler; namespace Render { -class Sampler; +struct Sampler; +class FrameBuffer; } // value types used by messages template <> struct ParameterType< PropertyNotification::NotifyMode > @@ -71,17 +76,41 @@ namespace SceneGraph class Animation; class DiscardQueue; -class PanGesture; class RenderManager; class RenderTaskList; +class RenderTaskProcessor; class RenderQueue; -class TextureCache; class PropertyBuffer; -class TextureSet; + +struct NodeDepthPair +{ + SceneGraph::Node* node; + uint32_t sortedDepth; + NodeDepthPair( SceneGraph::Node* node, uint32_t sortedDepth ) + : node(node), + sortedDepth(sortedDepth) + { + } +}; + +struct NodeDepths +{ + NodeDepths() + { + } + + void Add( SceneGraph::Node* node, uint32_t sortedDepth ) + { + nodeDepths.push_back( NodeDepthPair( node, sortedDepth ) ); + } + + std::vector nodeDepths; +}; + /** - * UpdateManager maintains a scene graph i.e. a tree of nodes and attachments and - * other property owner objects. + * UpdateManager maintains a scene graph i.e. a tree of nodes as well as + * other scene graph property owning objects. * It controls the Update traversal, in which nodes are repositioned/animated, * and organizes the the culling and rendering of the scene. * It also maintains the lifecycle of nodes and other property owners that are @@ -94,26 +123,22 @@ public: /** * Construct a new UpdateManager. * @param[in] notificationManager This should be notified when animations have finished. - * @param[in] animationFinishedNotifier The CompleteNotificationInterface that handles animation completions + * @param[in] animationPlaylist The CompleteNotificationInterface that handles the animations * @param[in] propertyNotifier The PropertyNotifier - * @param[in] resourceManager The resource manager used to load textures etc. * @param[in] discardQueue Nodes are added here when disconnected from the scene-graph. * @param[in] controller After messages are flushed, we request a render from the RenderController. * @param[in] renderManager This is responsible for rendering the results of each "update". * @param[in] renderQueue Used to queue messages for the next render. - * @param[in] textureCache Used for caching textures. - * @param[in] touchResampler Used for re-sampling touch events. + * @param[in] renderTaskProcessor Handles RenderTasks and RenderInstrucitons. */ UpdateManager( NotificationManager& notificationManager, - CompleteNotificationInterface& animationFinishedNotifier, + CompleteNotificationInterface& animationPlaylist, PropertyNotifier& propertyNotifier, - ResourceManager& resourceManager, DiscardQueue& discardQueue, Integration::RenderController& controller, RenderManager& renderManager, RenderQueue& renderQueue, - TextureCache& textureCache, - TouchResampler& touchResampler ); + RenderTaskProcessor& renderTaskProcessor ); /** * Destructor. @@ -123,13 +148,6 @@ public: // Node connection methods /** - * Get the scene graph side list of RenderTasks. - * @param[in] systemLevel True if using the system-level overlay. - * @return The list of render tasks - */ - RenderTaskList* GetRenderTaskList( bool systemLevel ); - - /** * 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. @@ -138,14 +156,15 @@ public: * @param[in] systemLevel True if using the system-level overlay. * @post The node is owned by UpdateManager. */ - void InstallRoot( Layer* layer, bool systemLevel ); + void InstallRoot( OwnerPointer& layer, bool systemLevel ); /** * Add a Node; UpdateManager takes ownership. * @pre The node does not have a parent. + * @note even though nodes are pool allocated, they also contain other heap allocated data, thus using OwnerPointer when transferring the data * @param[in] node The node to add. */ - void AddNode( Node* node ); + void AddNode( OwnerPointer& node ); /** * Connect a Node to the scene-graph. @@ -173,19 +192,23 @@ public: void DestroyNode( Node* node ); /** - * Attach an object to a Node. - * The UpdateManager is responsible for calling NodeAttachment::Initialize(). - * @param[in] node The node which will own the attachment. - * @param[in] attachment The object to attach. + * Add a camera on scene + * @param[in] camera The camera to add + */ + void AddCamera( OwnerPointer< Camera >& camera ); + + /** + * Remove a camera from scene + * @param[in] camera to remove */ - void AttachToNode( Node* node, NodeAttachment* attachment ); + void RemoveCamera( const Camera* camera ); /** * Add a newly created object. * @param[in] object The object to add. * @post The object is owned by UpdateManager. */ - void AddObject( PropertyOwner* object ); + void AddObject( OwnerPointer& object ); /** * Remove an object. @@ -200,7 +223,7 @@ public: * @param[in] animation The animation to add. * @post The animation is owned by UpdateManager. */ - void AddAnimation( Animation* animation ); + void AddAnimation( OwnerPointer< SceneGraph::Animation >& animation ); /** * Stop an animation. @@ -220,6 +243,13 @@ public: */ bool IsAnimationRunning() const; + /** + * Add a property resetter. UpdateManager takes ownership of the object. + * It will be killed by UpdateManager when the associated animator or + * constraint has finished; or the property owner of the property is destroyed. + */ + void AddPropertyResetter( OwnerPointer& propertyResetter ); + // Property Notification /** @@ -227,7 +257,7 @@ public: * @param[in] propertyNotification The notification to add * @post The propertyNotification is owned by UpdateManager. */ - void AddPropertyNotification( PropertyNotification* propertyNotification ); + void AddPropertyNotification( OwnerPointer< PropertyNotification >& propertyNotification ); /** * Remove a property notification @@ -242,21 +272,6 @@ public: */ void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode ); - /** - * @brief Get the renderer owner - * - * @return The renderer owner - */ - ObjectOwnerContainer< Renderer >& GetRendererOwner(); - - /** - * @brief Get the property buffer owner - * - * @return The property buffer owner - */ - ObjectOwnerContainer< PropertyBuffer >& GetPropertyBufferOwner(); - - // Shaders /** @@ -264,7 +279,7 @@ public: * @param[in] shader The shader to add. * @post The shader is owned by the UpdateManager. */ - void AddShader(Shader* shader); + void AddShader( OwnerPointer< Shader >& shader ); /** * Remove a shader. @@ -272,22 +287,7 @@ public: * @param[in] shader The shader to remove. * @post The shader is destroyed. */ - void RemoveShader(Shader* shader); - - /** - * Add a newly created TextureSet. - * @param[in] textureSet The texture set to add. - * @post The TextureSet is owned by the UpdateManager. - */ - void AddTextureSet(TextureSet* textureSet); - - /** - * Remove a TextureSet. - * @pre The TextureSet has been added to the UpdateManager. - * @param[in] textureSet The TextureSet to remove. - * @post The TextureSet is destroyed. - */ - void RemoveTextureSet(TextureSet* textureSet); + void RemoveShader( Shader* shader ); /** * Set the shader program for a Shader object @@ -310,22 +310,55 @@ public: */ void SetShaderSaver( ShaderSaver& upstream ); + // Renderers + + /** + * Add a new renderer to scene + * @param renderer to add + */ + void AddRenderer( OwnerPointer< Renderer >& renderer ); + + /** + * Add a renderer from scene + * @param renderer to remove + */ + void RemoveRenderer( Renderer* renderer ); + // Gestures /** - * Add a newly created gesture. - * @param[in] gesture The gesture to add. - * @post The gesture is owned by the UpdateManager. + * Set the pan gesture processor. + * Pan Gesture processor lives for the lifetime of UpdateManager + * @param[in] gesture The gesture processor. + * @post The gestureProcessor is owned by the UpdateManager. */ - void AddGesture( PanGesture* gesture ); + void SetPanGestureProcessor( PanGesture* gestureProcessor ); + + // Textures /** - * Remove a gesture. - * @pre The gesture has been added to the UpdateManager. - * @param[in] gesture The gesture to remove. - * @post The gesture is destroyed. + * Add a newly created TextureSet. + * @param[in] textureSet The texture set to add. + * @post The TextureSet is owned by the UpdateManager. */ - void RemoveGesture( PanGesture* gesture ); + void AddTextureSet( OwnerPointer< TextureSet >& textureSet ); + + /** + * Remove a TextureSet. + * @pre The TextureSet has been added to the UpdateManager. + * @param[in] textureSet The TextureSet to remove. + * @post The TextureSet is destroyed. + */ + void RemoveTextureSet( TextureSet* textureSet ); + + // Render tasks + + /** + * Get the scene graph side list of RenderTasks. + * @param[in] systemLevel True if using the system-level overlay. + * @return The list of render tasks + */ + RenderTaskList* GetRenderTaskList( bool systemLevel ); // Message queue handling @@ -369,7 +402,7 @@ public: * @post Sends a message to RenderManager to add the sampler. * The sampler will be owned by RenderManager */ - void AddSampler( Render::Sampler* sampler ); + void AddSampler( OwnerPointer< Render::Sampler >& sampler ); /** * Removes an existing sampler from RenderManager @@ -389,10 +422,11 @@ public: /** * Sets the wrap mode for an existing sampler * @param[in] sampler The sampler - * @param[in] uWrapMode Wrapping mode in x direction - * @param[in] vWrapMode Wrapping mode in y direction + * @param[in] rWrapMode Wrapping mode in z direction + * @param[in] sWrapMode Wrapping mode in x direction + * @param[in] tWrapMode Wrapping mode in y direction */ - void SetWrapMode( Render::Sampler* sampler, unsigned int uWrapMode, unsigned int vWrapMode ); + void SetWrapMode( Render::Sampler* sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode ); /** * Add a new property buffer to RenderManager @@ -400,7 +434,7 @@ public: * @post Sends a message to RenderManager to add the property buffer. * The property buffer will be owned by RenderManager */ - void AddPropertyBuffer( Render::PropertyBuffer* propertryBuffer ); + void AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertryBuffer ); /** * Removes an existing PropertyBuffer from RenderManager @@ -415,7 +449,7 @@ public: * @param[in] format The new format of the buffer * @post Sends a message to RenderManager to set the new format to the property buffer. */ - void SetPropertyBufferFormat(Render::PropertyBuffer* propertyBuffer, Render::PropertyBuffer::Format* format ); + void SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format ); /** * Sets the data of an existing property buffer @@ -424,7 +458,7 @@ public: * @param[in] size The new size of the buffer * @post Sends a message to RenderManager to set the new data to the property buffer. */ - void SetPropertyBufferData(Render::PropertyBuffer* propertyBuffer, Dali::Vector* data, size_t size); + void SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector >& data, size_t size ); /** * Adds a geometry to the RenderManager @@ -432,7 +466,7 @@ public: * @post Sends a message to RenderManager to add the Geometry * The geometry will be owned by RenderManager */ - void AddGeometry( Render::Geometry* geometry ); + void AddGeometry( OwnerPointer< Render::Geometry >& geometry ); /** * Removes an existing Geometry from RenderManager @@ -456,11 +490,11 @@ public: void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector& indices ); /** - * Adds a vertex buffer to a geomtry + * Adds a vertex buffer to a geometry * @param[in] geometry The geometry * @param[in] propertyBuffer The property buffer */ - void AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer ); + void AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer ); /** * Removes a vertex buffer from a geometry @@ -469,6 +503,56 @@ public: */ void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer ); + /** + * Adds a texture to the render manager + * @param[in] texture The texture to add + * The texture will be owned by RenderManager + */ + void AddTexture( OwnerPointer< Render::Texture >& texture ); + + /** + * Removes a texture from the render manager + * @param[in] texture The texture to remove + * @post The texture will be destroyed in the render thread + */ + void RemoveTexture( Render::Texture* texture ); + + /** + * Uploads data to a texture owned by the RenderManager + * @param[in] texture The texture + * @param[in] pixelData The pixel data object + * @param[in] params The parameters for the upload + */ + void UploadTexture( Render::Texture* texture, PixelDataPtr pixelData, const Texture::UploadParams& params ); + + /** + * Generates mipmaps for a texture owned by the RenderManager + * @param[in] texture The texture + */ + void GenerateMipmaps( Render::Texture* texture ); + + /** + * Adds a framebuffer to the render manager + * @param[in] frameBuffer The framebuffer to add + * The framebuffer will be owned by RenderManager + */ + void AddFrameBuffer( Render::FrameBuffer* frameBuffer ); + + /** + * Removes a FrameBuffer from the render manager + * @param[in] frameBuffer The FrameBuffer to remove + * @post The FrameBuffer will be destroyed in the render thread + */ + void RemoveFrameBuffer( Render::FrameBuffer* frameBuffer ); + + /** + * Attach a texture as color output to an existing FrameBuffer + * @param[in] frameBuffer The FrameBuffer + * @param[in] texture The texture that will be used as output when rendering + * @param[in] mipmapLevel The mipmap of the texture to be attached + * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures + */ + void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int face ); public: @@ -477,9 +561,15 @@ public: * @param[in] elapsedSeconds The elapsed time that should be applied to animations. * @param[in] lastVSyncTimeMilliseconds The last time, in milliseconds, that we had a VSync. * @param[in] nextVSyncTimeMilliseconds The estimated time, in milliseconds, of the next VSync. + * @param[in] renderToFboEnabled Whether rendering into the Frame Buffer Object is enabled. + * @param[in] isRenderingToFbo Whether this frame is being rendered into the Frame Buffer Object. * @return True if further updates are required e.g. during animations. */ - unsigned int Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds ); + unsigned int Update( float elapsedSeconds, + unsigned int lastVSyncTimeMilliseconds, + unsigned int nextVSyncTimeMilliseconds, + bool renderToFboEnabled, + bool isRenderingToFbo ); /** * Set the background color i.e. the glClear color used at the beginning of each frame. @@ -499,12 +589,42 @@ public: void KeepRendering( float durationSeconds ); /** + * @copydoc Dali::DevelStage::SetRenderingBehavior() + */ + void SetRenderingBehavior( DevelStage::Rendering renderingBehavior ); + + /** * Sets the depths of all layers. * @param layers The layers in depth order. * @param[in] systemLevel True if using the system-level overlay. */ void SetLayerDepths( const std::vector< Layer* >& layers, bool systemLevel ); + /** + * Set the depth indices of all nodes (in LayerUI's) + * @param[in] nodeDepths A vector of nodes and associated depth indices + */ + void SetDepthIndices( OwnerPointer< NodeDepths >& nodeDepths ); + + /** + * Query wheter the default surface rect is changed or not. + * @return true if the default surface rect is changed. + */ + bool IsDefaultSurfaceRectChanged(); + + /** + * Adds an implementation of the FrameCallbackInterface. + * @param[in] frameCallback A pointer to the implementation of the FrameCallbackInterface + * @param[in] rootNode A pointer to the root node to apply the FrameCallback to + */ + void AddFrameCallback( FrameCallbackInterface* frameCallback, const Node* rootNode ); + + /** + * Removes the specified implementation of FrameCallbackInterface. + * @param[in] frameCallback A pointer to the implementation of the FrameCallbackInterface to remove. + */ + void RemoveFrameCallback( FrameCallbackInterface* frameCallback ); + private: // Undefined @@ -521,17 +641,6 @@ private: unsigned int KeepUpdatingCheck( float elapsedSeconds ) const; /** - * Helper to calculate new camera setup when root node resizes. - * @param[in] updateBuffer The buffer to read the root node size from. - */ - void UpdateProjectionAndViewMatrices(int updateBuffer); - - /** - * Post process resources that have been updated by renderer - */ - void PostProcessResources(); - - /** * Helper to reset all Node properties * @param[in] bufferIndex to use */ @@ -578,23 +687,11 @@ private: void ProcessPropertyNotifications( BufferIndex bufferIndex ); /** - * Prepare textures for rendering - */ - void PrepareTextureSets( BufferIndex bufferIndex ); - - /** * Pass shader binaries queued here on to event thread. */ void ForwardCompiledShadersToEventThread(); /** - * Update the default camera. - * This must be altered to match the root Node for 2D layouting. - * @param[in] updateBuffer The buffer to read the root node size from. - */ - void UpdateDefaultCamera( int updateBuffer ); - - /** * Update node shaders, opacity, geometry etc. * @param[in] bufferIndex to use */ @@ -618,26 +715,28 @@ private: // Messages for UpdateManager -inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool systemLevel ) +inline void InstallRootMessage( UpdateManager& manager, OwnerPointer& root, bool systemLevel ) { - typedef MessageValue2< UpdateManager, Layer*, bool > LocalType; + // Message has ownership of Layer while in transit from event -> update + typedef MessageValue2< UpdateManager, OwnerPointer, bool > 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::InstallRoot, &root, systemLevel ); + new (slot) LocalType( &manager, &UpdateManager::InstallRoot, root, systemLevel ); } -inline void AddNodeMessage( UpdateManager& manager, Node& node ) +inline void AddNodeMessage( UpdateManager& manager, OwnerPointer& node ) { + // Message has ownership of Node while in transit from event -> update typedef MessageValue1< UpdateManager, OwnerPointer > 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::AddNode, &node ); + new (slot) LocalType( &manager, &UpdateManager::AddNode, node ); } inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, const Node& constChild ) @@ -683,22 +782,32 @@ inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode ) new (slot) LocalType( &manager, &UpdateManager::DestroyNode, &node ); } -inline void AttachToNodeMessage( UpdateManager& manager, const Node& constParent, NodeAttachment* attachment ) +inline void AddCameraMessage( UpdateManager& manager, OwnerPointer< Camera >& camera ) { - // Scene graph thread can modify this object. - Node& parent = const_cast< Node& >( constParent ); + // Message has ownership of Camera while in transit from event -> update + typedef MessageValue1< UpdateManager, OwnerPointer< Camera > > LocalType; - typedef MessageValue2< UpdateManager, Node*, NodeAttachmentOwner > 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::AddCamera, camera ); +} + +inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera ) +{ + typedef MessageValue1< UpdateManager, const Camera* > 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::AttachToNode, &parent, attachment ); + new (slot) LocalType( &manager, &UpdateManager::RemoveCamera, camera ); } -inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object ) +inline void AddObjectMessage( UpdateManager& manager, OwnerPointer& object ) { + // Message has ownership of object while in transit from event -> update typedef MessageValue1< UpdateManager, OwnerPointer > LocalType; // Reserve some memory inside the message queue @@ -719,9 +828,9 @@ inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object ) new (slot) LocalType( &manager, &UpdateManager::RemoveObject, object ); } -inline void AddAnimationMessage( UpdateManager& manager, Animation* animation ) +inline void AddAnimationMessage( UpdateManager& manager, OwnerPointer< SceneGraph::Animation >& animation ) { - typedef MessageValue1< UpdateManager, Animation* > LocalType; + typedef MessageValue1< UpdateManager, OwnerPointer< SceneGraph::Animation > > LocalType; // Reserve some memory inside the message queue unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); @@ -758,9 +867,10 @@ inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& con new (slot) LocalType( &manager, &UpdateManager::RemoveAnimation, &animation ); } -inline void AddPropertyNotificationMessage( UpdateManager& manager, PropertyNotification* propertyNotification ) +inline void AddPropertyNotificationMessage( UpdateManager& manager, OwnerPointer< PropertyNotification >& propertyNotification ) { - typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType; + // Message has ownership of PropertyNotification while in transit from event -> update + typedef MessageValue1< UpdateManager, OwnerPointer< PropertyNotification > > LocalType; // Reserve some memory inside the message queue unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); @@ -800,7 +910,7 @@ inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager, } // The render thread can safely change the Shader -inline void AddShaderMessage( UpdateManager& manager, Shader& shader ) +inline void AddShaderMessage( UpdateManager& manager, OwnerPointer< Shader >& shader ) { typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > LocalType; @@ -808,7 +918,7 @@ inline void AddShaderMessage( UpdateManager& manager, Shader& shader ) 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::AddShader, &shader ); + new (slot) LocalType( &manager, &UpdateManager::AddShader, shader ); } // The render thread can safely change the Shader @@ -870,6 +980,17 @@ inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds new (slot) LocalType( &manager, &UpdateManager::KeepRendering, durationSeconds ); } +inline void SetRenderingBehaviorMessage( UpdateManager& manager, DevelStage::Rendering renderingBehavior ) +{ + typedef MessageValue1< UpdateManager, DevelStage::Rendering > 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::SetRenderingBehavior, renderingBehavior ); +} + /** * Create a message for setting the depth of a layer * @param[in] manager The update manager @@ -887,52 +1008,28 @@ inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< La new (slot) LocalType( &manager, &UpdateManager::SetLayerDepths, layers, systemLevel ); } -inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture ) +inline void AddRendererMessage( UpdateManager& manager, OwnerPointer< Renderer >& object ) { - typedef MessageValue1< UpdateManager, PanGesture* > LocalType; + typedef MessageValue1< UpdateManager, OwnerPointer< Renderer > > 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::AddGesture, gesture ); -} - -inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture ) -{ - typedef MessageValue1< UpdateManager, PanGesture* > 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::RemoveGesture, gesture ); + new (slot) LocalType( &manager, &UpdateManager::AddRenderer, object ); } -template< typename T > -inline void AddMessage( UpdateManager& manager, ObjectOwnerContainer& owner, T& object ) +inline void RemoveRendererMessage( UpdateManager& manager, Renderer& object ) { - typedef MessageValue1< ObjectOwnerContainer, OwnerPointer< T > > LocalType; + typedef MessageValue1< UpdateManager, Renderer* > 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( &owner, &ObjectOwnerContainer::Add, &object ); -} - -template< typename T > -inline void RemoveMessage( UpdateManager& manager, ObjectOwnerContainer& owner, T& object ) -{ - typedef MessageValue1< ObjectOwnerContainer, T* > 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( &owner, &ObjectOwnerContainer::Remove, &object ); + new (slot) LocalType( &manager, &UpdateManager::RemoveRenderer, &object ); } // The render thread can safely change the Shader -inline void AddTextureSetMessage( UpdateManager& manager, TextureSet& textureSet ) +inline void AddTextureSetMessage( UpdateManager& manager, OwnerPointer< TextureSet >& textureSet ) { typedef MessageValue1< UpdateManager, OwnerPointer< TextureSet > > LocalType; @@ -940,7 +1037,7 @@ inline void AddTextureSetMessage( UpdateManager& manager, TextureSet& textureSet 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::AddTextureSet, &textureSet ); + new (slot) LocalType( &manager, &UpdateManager::AddTextureSet, textureSet ); } // The render thread can safely change the Shader @@ -955,15 +1052,16 @@ inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& texture new (slot) LocalType( &manager, &UpdateManager::RemoveTextureSet, &textureSet ); } -inline void AddSamplerMessage( UpdateManager& manager, Render::Sampler& sampler ) +inline void AddSamplerMessage( UpdateManager& manager, OwnerPointer< Render::Sampler >& sampler ) { - typedef MessageValue1< UpdateManager, Render::Sampler* > LocalType; + // Message has ownership of Sampler while in transit from event -> update + typedef MessageValue1< UpdateManager, OwnerPointer< Render::Sampler > > 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::AddSampler, &sampler ); + new (slot) LocalType( &manager, &UpdateManager::AddSampler, sampler ); } inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler ) @@ -988,26 +1086,27 @@ inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampl new (slot) LocalType( &manager, &UpdateManager::SetFilterMode, &sampler, minFilterMode, magFilterMode ); } -inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int uWrapMode, unsigned int vWrapMode ) +inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode ) { - typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int > LocalType; + typedef MessageValue4< UpdateManager, Render::Sampler*, unsigned int, unsigned int, unsigned 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::SetWrapMode, &sampler, uWrapMode, vWrapMode ); + new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, rWrapMode, sWrapMode, tWrapMode ); } -inline void AddPropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer ) +inline void AddPropertyBuffer( UpdateManager& manager, OwnerPointer< Render::PropertyBuffer >& propertyBuffer ) { - typedef MessageValue1< UpdateManager, Render::PropertyBuffer* > LocalType; + // Message has ownership of propertyBuffer while in transit from event -> update + typedef MessageValue1< UpdateManager, OwnerPointer< Render::PropertyBuffer > > 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::AddPropertyBuffer, &propertyBuffer ); + new (slot) LocalType( &manager, &UpdateManager::AddPropertyBuffer, propertyBuffer ); } inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer ) @@ -1021,9 +1120,10 @@ inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer new (slot) LocalType( &manager, &UpdateManager::RemovePropertyBuffer, &propertyBuffer ); } -inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Render::PropertyBuffer::Format* format ) +inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format ) { - typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, Render::PropertyBuffer::Format* > LocalType; + // Message has ownership of PropertyBuffer::Format while in transit from event -> update + typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, OwnerPointer< Render::PropertyBuffer::Format> > LocalType; // Reserve some memory inside the message queue unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); @@ -1032,9 +1132,10 @@ inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuf new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferFormat, &propertyBuffer, format ); } -inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Vector* data, size_t size ) +inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, OwnerPointer< Vector >& data, size_t size ) { - typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, Vector*, size_t > LocalType; + // Message has ownership of PropertyBuffer data while in transit from event -> update + typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, OwnerPointer< Vector >, size_t > LocalType; // Reserve some memory inside the message queue unsigned int* slot = manager.ReserveMessageSlot( sizeof( LocalType ) ); @@ -1043,15 +1144,16 @@ inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffe new (slot) LocalType( &manager, &UpdateManager::SetPropertyBufferData, &propertyBuffer, data, size ); } -inline void AddGeometry( UpdateManager& manager, Render::Geometry& geometry ) +inline void AddGeometry( UpdateManager& manager, OwnerPointer< Render::Geometry >& geometry ) { - typedef MessageValue1< UpdateManager, Render::Geometry* > LocalType; + // Message has ownership of Geometry while in transit from event -> update + typedef MessageValue1< UpdateManager, OwnerPointer< Render::Geometry > > 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::AddGeometry, &geometry ); + new (slot) LocalType( &manager, &UpdateManager::AddGeometry, geometry ); } inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry ) @@ -1065,7 +1167,7 @@ inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry ) new (slot) LocalType( &manager, &UpdateManager::RemoveGeometry, &geometry ); } -inline void AddVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer ) +inline void AttachVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer ) { typedef MessageValue2< UpdateManager, Render::Geometry*, Render::PropertyBuffer* > LocalType; @@ -1073,7 +1175,7 @@ inline void AddVertexBufferMessage( UpdateManager& manager, Render::Geometry& ge 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::AddVertexBuffer, &geometry, const_cast(&vertexBuffer) ); + new (slot) LocalType( &manager, &UpdateManager::AttachVertexBuffer, &geometry, const_cast(&vertexBuffer) ); } inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer ) @@ -1149,10 +1251,133 @@ inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& ge new (slot) LocalType( &manager, &UpdateManager::SetGeometryType, &geometry, geometryType ); } +inline void AddTexture( UpdateManager& manager, OwnerPointer< Render::Texture >& texture ) +{ + // Message has ownership of Texture while in transit from event -> update + typedef MessageValue1< UpdateManager, OwnerPointer< Render::Texture > > 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::AddTexture, texture ); +} + +inline void RemoveTexture( UpdateManager& manager, Render::Texture& texture ) +{ + typedef MessageValue1< UpdateManager, Render::Texture* > 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::RemoveTexture, &texture ); +} + +inline void UploadTextureMessage( UpdateManager& manager, Render::Texture& texture, PixelDataPtr pixelData, const Texture::UploadParams& params ) +{ + typedef MessageValue3< UpdateManager, Render::Texture*, PixelDataPtr, Texture::UploadParams > 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::UploadTexture, &texture, pixelData, params ); +} + +inline void GenerateMipmapsMessage( UpdateManager& manager, Render::Texture& texture ) +{ + typedef MessageValue1< UpdateManager, Render::Texture* > 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::GenerateMipmaps, &texture ); +} + + +inline void AddFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer ) +{ + typedef MessageValue1< UpdateManager, Render::FrameBuffer* > 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::AddFrameBuffer, &frameBuffer ); +} + +inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer ) +{ + typedef MessageValue1< UpdateManager, Render::FrameBuffer* > 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::RemoveFrameBuffer, &frameBuffer ); +} + +inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer, Render::Texture* texture, unsigned int mipmapLevel, unsigned int layer ) +{ + typedef MessageValue4< UpdateManager, Render::FrameBuffer*, Render::Texture*, unsigned int, unsigned 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::AttachColorTextureToFrameBuffer, &frameBuffer, texture, mipmapLevel, layer ); +} + +inline void SetDepthIndicesMessage( UpdateManager& manager, OwnerPointer< NodeDepths >& nodeDepths ) +{ + typedef MessageValue1< UpdateManager, OwnerPointer< NodeDepths > > 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::SetDepthIndices, nodeDepths ); +} + +inline void AddResetterMessage( UpdateManager& manager, OwnerPointer resetter ) +{ + typedef MessageValue1< UpdateManager, OwnerPointer > 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::AddPropertyResetter, resetter ); +} + +inline void AddFrameCallbackMessage( UpdateManager& manager, FrameCallbackInterface& frameCallback, const Node& rootNode ) +{ + typedef MessageValue2< UpdateManager, FrameCallbackInterface*, const Node* > 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::AddFrameCallback, &frameCallback, &rootNode ); +} + +inline void RemoveFrameCallbackMessage( UpdateManager& manager, FrameCallbackInterface& frameCallback ) +{ + typedef MessageValue1< UpdateManager, FrameCallbackInterface* > 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::RemoveFrameCallback, &frameCallback ); +} + } // namespace SceneGraph } // namespace Internal } // namespace Dali -#endif // __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__ +#endif // DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H