X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Fmanager%2Fupdate-manager.h;h=e90ab9dbacca43df6c6ac25ac631f2ec46d2c231;hb=485765dab55e1b81644d15aa867abf8173c6e0ee;hp=67c2daf3eb190b8411c2773172c8a164b993d303;hpb=105be35126450c450798c552555db75de42eb409;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 67c2daf..e90ab9d 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) 2014 Samsung Electronics Co., Ltd. + * Copyright (c) 2016 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. @@ -21,20 +21,23 @@ // INTERNAL INCLUDES #include #include + #include + #include -#include -#include -#include -#include -#include +#include +#include +#include #include +#include #include -#include -#include +#include +#include #include -#include -#include +#include +#include +#include +#include namespace Dali { @@ -43,22 +46,23 @@ namespace Integration { class GlSyncAbstraction; class RenderController; -struct DynamicsWorldSettings; } // namespace Integration namespace Internal { -class AnimationFinishedNotifier; class PropertyNotifier; -class EventToUpdate; -struct DynamicsWorldSettings; class NotificationManager; +class CompleteNotificationInterface; class ResourceManager; -class RenderTaskList; class TouchResampler; +namespace Render +{ +struct Sampler; +class FrameBuffer; +} // value types used by messages template <> struct ParameterType< PropertyNotification::NotifyMode > : public BasicType< PropertyNotification::NotifyMode > {}; @@ -66,82 +70,55 @@ template <> struct ParameterType< PropertyNotification::NotifyMode > namespace SceneGraph { -class AnimatableMesh; class Animation; class DiscardQueue; -class Material; class PanGesture; class RenderManager; class RenderTaskList; class RenderQueue; -class DynamicsWorld; -class TextureCache; -typedef OwnerContainer< AnimatableMesh* > AnimatableMeshContainer; -typedef OwnerContainer< Material* > MaterialContainer; +class TextureCacheDispatcher; +class PropertyBuffer; +class TextureSet; +class Camera; /** - * UpdateManager holds a scene graph i.e. a tree of nodes. + * 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 + * disconnected from the scene graph. */ -class UpdateManager +class UpdateManager : public ShaderSaver { public: /** * Construct a new UpdateManager. * @param[in] notificationManager This should be notified when animations have finished. - * @param[in] glSyncAbstraction Used to determine when framebuffers are ready - * @param[in] animationFinishedNotifier The AnimationFinishedNotifier + * @param[in] animationFinishedNotifier The CompleteNotificationInterface that handles animation completions * @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] textureCacheDispatcher Used for sending messages to texture cache. */ UpdateManager( NotificationManager& notificationManager, - Integration::GlSyncAbstraction& glSyncAbstraction, - AnimationFinishedNotifier& animationFinishedNotifier, + CompleteNotificationInterface& animationFinishedNotifier, PropertyNotifier& propertyNotifier, ResourceManager& resourceManager, DiscardQueue& discardQueue, Integration::RenderController& controller, RenderManager& renderManager, RenderQueue& renderQueue, - TextureCache& textureCache, - TouchResampler& touchResampler ); - - /** - * Destructor. Not virtual as this is not a base class - */ - ~UpdateManager(); - - /** - * Sets a pointer to the internal render task list. - * - * The render task list is used to notify which render tasks with refresh rate REFRESH_ONCE have finished. - * - * @param[in] renderTaskList A pointer to the internal render task list. - */ - void SetRenderTaskList( Internal::RenderTaskList* renderTaskList ); - - /** - * The event-thread uses this interface to queue messages for the next update. - * @return The event-to-update interface. - */ - EventToUpdate& GetEventToUpdate(); + TextureCacheDispatcher& textureCacheDispatcher ); /** - * @return the event buffer index + * Destructor. */ - BufferIndex GetEventBufferIndex() const - { - // inlined as its called often - return mSceneGraphBuffers.GetEventBufferIndex(); - } + virtual ~UpdateManager(); // Node connection methods @@ -174,8 +151,7 @@ public: * Connect a Node to the scene-graph. * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained. * @pre The node does not already have a parent. - * @param[in] node The new parent node. - * @param[in] node The node to connect. + * @param[in] parent The new parent node. */ void ConnectNode( Node* parent, Node* node ); @@ -188,14 +164,6 @@ public: void DisconnectNode( Node* node ); /** - * Called when a property is set on a disconnected Node (via public API) - * A disconnected Node has has no parent or children, and its properties cannot be animated/constrained. - * @pre The node does not have a parent. - * @param[in] node The node to set as "active". - */ - void SetNodeActive( Node* node ); - - /** * Destroy a Node owned by UpdateManager. * This is not immediate; Nodes are passed to the RenderQueue to allow GL resources to be deleted. * In the following update, the previously queued Nodes may be deleted. @@ -205,12 +173,16 @@ 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 to add + */ + void AddCamera( 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. @@ -274,13 +246,22 @@ public: */ void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode ); - // Shaders + /** + * @brief Get the renderer owner + * + * @return The renderer owner + */ + ObjectOwnerContainer< Renderer >& GetRendererOwner(); /** - * Retrieve the default shader. - * @return The default shader. + * @brief Get the property buffer owner + * + * @return The property buffer owner */ - Shader* GetDefaultShader(); + ObjectOwnerContainer< PropertyBuffer >& GetPropertyBufferOwner(); + + + // Shaders /** * Add a newly created shader. @@ -298,43 +279,42 @@ public: void RemoveShader(Shader* shader); /** - * Set the shader program for a specified GeometryType to a Shader object - * @param[in] shader The shader to modify - * @param[in] geometryType The GeometryType to map to the program - * @param[in] subType The program subtype - * @param[in] resourceId A ResourceManager ticket ID for the program data (source and compiled binary) - * @param[in] shaderHash hash key created with vertex and fragment shader code - * @param[in] modifiesGeometry True if the vertex shader modifies geometry + * Add a newly created TextureSet. + * @param[in] textureSet The texture set to add. + * @post The TextureSet is owned by the UpdateManager. */ - void SetShaderProgram( Shader* shader, GeometryType geometryType, ShaderSubTypes subType, Integration::ResourceId resourceId, size_t shaderHash, bool modifiesGeometry ); + void AddTextureSet(TextureSet* textureSet); /** - * Add an animatable mesh - * @param[in] animatableMesh The animatable mesh to add. - * @post the animatableMesh is owned by the UpdateManager. + * 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 AddAnimatableMesh( AnimatableMesh* animatableMesh ); + void RemoveTextureSet(TextureSet* textureSet); /** - * Remove an animatable mesh - * @pre The animatable mesh has been added to the update manager - * @param[in] animatableMesh The animatable mesh to add. + * Set the shader program for a Shader object + * @param[in] shader The shader to modify + * @param[in] shaderData Source code, hash over source, and optional compiled binary for the shader program + * @param[in] modifiesGeometry True if the vertex shader modifies geometry */ - void RemoveAnimatableMesh( AnimatableMesh* animatableMesh ); + void SetShaderProgram( Shader* shader, Internal::ShaderDataPtr shaderData, bool modifiesGeometry ); /** - * Add a material - * @param[in] material The material to add - * @post the material remains owned by its event object + * @brief Accept compiled shaders passed back on render thread for saving. + * @param[in] shaderData Source code, hash over source, and corresponding compiled binary to be saved. */ - void AddMaterial(Material* material); + virtual void SaveBinary( Internal::ShaderDataPtr shaderData ); /** - * Remove a material - * @pre The material has been added to the UpdateManager - * @param[in] material The material to remove + * @brief Set the destination for compiled shader binaries to be passed on to. + * The dispatcher passed in will be called from the update thread. + * @param[in] upstream A sink for ShaderDatas to be passed into. */ - void RemoveMaterial(Material* material); + void SetShaderSaver( ShaderSaver& upstream ); + + // Gestures /** * Add a newly created gesture. @@ -351,16 +331,210 @@ public: */ void RemoveGesture( PanGesture* gesture ); +// Message queue handling + + /** + * Reserve space for another message in the queue; this must then be initialized by the caller. + * The message will be read from the update-thread after the next FlushMessages is called. + * @post Calling this method may invalidate any previously returned slots. + * @param[in] size The message size with respect to the size of type "char". + * @param[in] updateScene A flag, when true denotes that the message will cause the scene-graph node tree to require an update. + * @note the default value of updateScene should match that in EventThreadServices::ReserveMessageSlot. + * @return A pointer to the first char allocated for the message. + */ + unsigned int* ReserveMessageSlot( std::size_t size, bool updateScene = true ); + + /** + * @return the current event-buffer index. + */ + BufferIndex GetEventBufferIndex() const + { + // inlined as its called often from event thread + return mSceneGraphBuffers.GetEventBufferIndex(); + } + + /** + * Called by the event-thread to signal that FlushQueue will be called + * e.g. when it has finished event processing. + */ + void EventProcessingStarted(); + + /** + * Flush the set of messages, which were previously stored with QueueMessage(). + * Calls to this thread-safe method should be minimized, to avoid thread blocking. + * + * @return True if there are messages to process. + */ + bool FlushQueue(); + + /** + * Add a new sampler to RenderManager + * @param[in] sampler The sampler to add + * @post Sends a message to RenderManager to add the sampler. + * The sampler will be owned by RenderManager + */ + void AddSampler( Render::Sampler* sampler ); + + /** + * Removes an existing sampler from RenderManager + * @param[in] sampler The sampler to remove + * @post The sampler will be destroyed in the render thread + */ + void RemoveSampler( Render::Sampler* sampler ); + + /** + * Sets the filter modes for an existing sampler + * @param[in] sampler The sampler + * @param[in] minFilterMode The filter to use under minification + * @param[in] magFilterMode The filter to use under magnification + */ + void SetFilterMode( Render::Sampler* sampler, unsigned int minFilterMode, unsigned int magFilterMode ); + + /** + * Sets the wrap mode for an existing sampler + * @param[in] sampler The sampler + * @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 rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode ); + + /** + * Add a new property buffer to RenderManager + * @param[in] propertryBuffer The property buffer to add + * @post Sends a message to RenderManager to add the property buffer. + * The property buffer will be owned by RenderManager + */ + void AddPropertyBuffer( Render::PropertyBuffer* propertryBuffer ); + + /** + * Removes an existing PropertyBuffer from RenderManager + * @param[in] propertryBuffer The property buffer to remove + * @post The property buffer will be destroyed in the render thread + */ + void RemovePropertyBuffer( Render::PropertyBuffer* propertryBuffer ); + + /** + * Sets the format of an existing property buffer + * @param[in] propertyBuffer The property buffer. + * @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 ); + + /** + * Sets the data of an existing property buffer + * @param[in] propertyBuffer The property buffer. + * @param[in] data The new data of the buffer + * @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); + + /** + * Adds a geometry to the RenderManager + * @param[in] geometry The geometry to add + * @post Sends a message to RenderManager to add the Geometry + * The geometry will be owned by RenderManager + */ + void AddGeometry( Render::Geometry* geometry ); + + /** + * Removes an existing Geometry from RenderManager + * @param[in] geometry The geometry to remove + * @post The geometry will be destroyed in the render thread + */ + void RemoveGeometry( Render::Geometry* geometry ); + + /** + * Sets the geometry type of an existing Geometry + * @param[in] geometry The geometry + * @param[in] geometryType The type of the geometry + */ + void SetGeometryType( Render::Geometry* geometry, unsigned int geometryType ); + + /** + * Sets the index buffer to be used by a geometry + * @param[in] geometry The geometry + * @param[in] indices A vector containing the indices for the geometry + */ + void SetIndexBuffer( Render::Geometry* geometry, Dali::Vector& indices ); + + /** + * Adds a vertex buffer to a geomtry + * @param[in] geometry The geometry + * @param[in] propertyBuffer The property buffer + */ + void AddVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer ); + + /** + * Removes a vertex buffer from a geometry + * @param[in] geometry The geometry + * @param[in] propertyBuffer The property buffer + */ + 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( Render::NewTexture* 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::NewTexture* 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::NewTexture* texture, PixelDataPtr pixelData, const NewTexture::UploadParams& params ); + + /** + * Generates mipmaps for a texture owned by the RenderManager + * @param[in] texture The texture + */ + void GenerateMipmaps( Render::NewTexture* 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::NewTexture* texture, unsigned int mipmapLevel, unsigned int face ); + public: /** * Performs an Update traversal on the scene-graph. * @param[in] elapsedSeconds The elapsed time that should be applied to animations. - * @param[in] lastVSyncTime The last time, in milliseconds, that we had a VSync. - * @param[in] nextVSyncTime The estimated time, in milliseconds, of the next VSync. + * @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. * @return True if further updates are required e.g. during animations. */ - unsigned int Update( float elapsedSeconds, unsigned int lastVSyncTime, unsigned int nextVSyncTime ); + unsigned int Update( float elapsedSeconds, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds ); /** * Set the background color i.e. the glClear color used at the beginning of each frame. @@ -386,23 +560,6 @@ public: */ void SetLayerDepths( const std::vector< Layer* >& layers, bool systemLevel ); -#ifdef DYNAMICS_SUPPORT - - /** - * Initialize the dynamics world - * @param[in] world The dynamics world - * @param[in] worldSettings The dynamics world settings - * @param[in] debugShader The shader used for rendering dynamics debug information - */ - void InitializeDynamicsWorld( DynamicsWorld* world, Integration::DynamicsWorldSettings* worldSettings ); - - /** - * Terminate the dynamics world - */ - void TerminateDynamicsWorld(); - -#endif // DYNAMICS_SUPPORT - private: // Undefined @@ -419,80 +576,77 @@ 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 a Node properties. - * @param[in] node The node. - */ - void ResetNodeProperty( Node& node ); - - /** * Helper to reset all Node properties + * @param[in] bufferIndex to use */ - void ResetProperties(); + void ResetProperties( BufferIndex bufferIndex ); /** * Perform gesture updates. - * @param[in] lastVSyncTime The last VSync time. - * @param[in] nextVSyncTime The estimated time of the next VSync. + * @param[in] bufferIndex to use + * @param[in] lastVSyncTime The last VSync time in milliseconds. + * @param[in] nextVSyncTime The estimated time of the next VSync in milliseconds. * @return true, if any properties were updated. */ - bool ProcessGestures( unsigned int lastVSyncTime, unsigned int nextVSyncTime ); + bool ProcessGestures( BufferIndex bufferIndex, unsigned int lastVSyncTimeMilliseconds, unsigned int nextVSyncTimeMilliseconds ); /** * Perform animation updates + * @param[in] bufferIndex to use * @param[in] elapsedSeconds time since last frame */ - void Animate( float elapsedSeconds ); + void Animate( BufferIndex bufferIndex, float elapsedSeconds ); /** - * Perform constraint updates. - * @note Applies constraints to nodes first (depth first search order). - * Then shader constraints second (construction order) + * Applies constraints to CustomObjects + * @param[in] bufferIndex to use */ - void ApplyConstraints(); + void ConstrainCustomObjects( BufferIndex bufferIndex ); /** - * Perform property notification updates + * Applies constraints to RenderTasks + * @param[in] bufferIndex to use */ - void ProcessPropertyNotifications(); + void ConstrainRenderTasks( BufferIndex bufferIndex ); /** - * 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. + * Applies constraints to Shaders + * @param[in] bufferIndex to use */ - void UpdateDefaultCamera( int updateBuffer ); + void ConstrainShaders( BufferIndex bufferIndex ); /** - * Update node shaders, opacity, geometry etc. + * Perform property notification updates + * @param[in] bufferIndex to use + */ + void ProcessPropertyNotifications( BufferIndex bufferIndex ); + + /** + * Prepare textures for rendering */ - void UpdateNodes(); + void PrepareTextureSets( BufferIndex bufferIndex ); /** - * Update animatable meshes + * Pass shader binaries queued here on to event thread. */ - void UpdateMeshes( BufferIndex updateBufferIndex, AnimatableMeshContainer& meshes ); + void ForwardCompiledShadersToEventThread(); /** - * Update materials - Ensure all render materials are updated with texture pointers - * when ready. + * Update node shaders, opacity, geometry etc. + * @param[in] bufferIndex to use */ - void UpdateMaterials( BufferIndex updateBufferIndex, MaterialContainer& materials ); + void UpdateNodes( BufferIndex bufferIndex ); /** - * PrepareMaterials - Ensure updated material properties are sent to render materials + * Update Renderers + * @param[in] bufferIndex to use */ - void PrepareMaterials( BufferIndex updateBufferIndex, MaterialContainer& materials ); + void UpdateRenderers( BufferIndex bufferIndex ); private: @@ -511,7 +665,7 @@ inline void InstallRootMessage( UpdateManager& manager, Layer& root, bool system typedef MessageValue2< UpdateManager, Layer*, bool > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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 ); @@ -522,7 +676,7 @@ inline void AddNodeMessage( UpdateManager& manager, Node& node ) typedef MessageValue1< UpdateManager, OwnerPointer > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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 ); @@ -537,7 +691,7 @@ inline void ConnectNodeMessage( UpdateManager& manager, const Node& constParent, typedef MessageValue2< UpdateManager, Node*, Node* > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::ConnectNode, &parent, &child ); @@ -551,7 +705,7 @@ inline void DisconnectNodeMessage( UpdateManager& manager, const Node& constNode typedef MessageValue1< UpdateManager, Node* > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::DisconnectNode, &node ); @@ -565,24 +719,33 @@ inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode ) typedef MessageValue1< UpdateManager, Node* > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::DestroyNode, &node ); } -inline void AttachToNodeMessage( UpdateManager& manager, const Node& constParent, NodeAttachment* attachment ) +inline void AddCameraMessage( UpdateManager& manager, const Camera* constCamera ) { - // Scene graph thread can modify this object. - Node& parent = const_cast< Node& >( constParent ); + typedef MessageValue1< UpdateManager, Camera* > LocalType; + + Camera* camera = const_cast( constCamera ); + // 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 ); +} - typedef MessageValue2< UpdateManager, Node*, NodeAttachmentOwner > LocalType; +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.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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 ) @@ -590,7 +753,7 @@ inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object ) typedef MessageValue1< UpdateManager, OwnerPointer > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::AddObject, object ); @@ -601,7 +764,7 @@ inline void RemoveObjectMessage( UpdateManager& manager, PropertyOwner* object ) typedef MessageValue1< UpdateManager, PropertyOwner* > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::RemoveObject, object ); @@ -612,7 +775,7 @@ inline void AddAnimationMessage( UpdateManager& manager, Animation* animation ) typedef MessageValue1< UpdateManager, Animation* > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::AddAnimation, animation ); @@ -626,7 +789,7 @@ inline void StopAnimationMessage( UpdateManager& manager, const Animation& const typedef MessageValue1< UpdateManager, Animation* > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::StopAnimation, &animation ); @@ -640,7 +803,7 @@ inline void RemoveAnimationMessage( UpdateManager& manager, const Animation& con typedef MessageValue1< UpdateManager, Animation* > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::RemoveAnimation, &animation ); @@ -651,7 +814,7 @@ inline void AddPropertyNotificationMessage( UpdateManager& manager, PropertyNoti typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::AddPropertyNotification, propertyNotification ); @@ -665,7 +828,7 @@ inline void RemovePropertyNotificationMessage( UpdateManager& manager, const Pro typedef MessageValue1< UpdateManager, PropertyNotification* > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::RemovePropertyNotification, &propertyNotification ); @@ -681,7 +844,7 @@ inline void PropertyNotificationSetNotifyModeMessage( UpdateManager& manager, typedef MessageValue2< UpdateManager, PropertyNotification*, PropertyNotification::NotifyMode > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::PropertyNotificationSetNotify, propertyNotification, notifyMode ); @@ -693,7 +856,7 @@ inline void AddShaderMessage( UpdateManager& manager, Shader& shader ) typedef MessageValue1< UpdateManager, OwnerPointer< Shader > > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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 ); @@ -705,7 +868,7 @@ inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader ) typedef MessageValue1< UpdateManager, Shader* > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::RemoveShader, &shader ); @@ -713,52 +876,24 @@ inline void RemoveShaderMessage( UpdateManager& manager, Shader& shader ) inline void SetShaderProgramMessage( UpdateManager& manager, Shader& shader, - GeometryType geometryType, - ShaderSubTypes subType, - Integration::ResourceId resourceId, - size_t shaderHash, + Internal::ShaderDataPtr shaderData, bool modifiesGeometry ) { - typedef MessageValue6< UpdateManager, Shader*, GeometryType, ShaderSubTypes, Integration::ResourceId, size_t, bool > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().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, geometryType, subType, resourceId, shaderHash, modifiesGeometry ); -} - -// The render thread can safely change the AnimatableMesh -inline void AddAnimatableMeshMessage( UpdateManager& manager, AnimatableMesh& animatableMesh ) -{ - typedef MessageValue1< UpdateManager, AnimatableMesh* > LocalType; - - // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().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::AddAnimatableMesh, &animatableMesh ); -} - -// The render thread can safely change the AnimatableMesh -inline void RemoveAnimatableMeshMessage( UpdateManager& manager, AnimatableMesh& animatableMesh ) -{ - typedef MessageValue1< UpdateManager, AnimatableMesh* > LocalType; + typedef MessageValue3< UpdateManager, Shader*, Internal::ShaderDataPtr, bool > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::RemoveAnimatableMesh, &animatableMesh ); + new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, &shader, shaderData, modifiesGeometry ); } - inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color ) { typedef MessageValue1< UpdateManager, Vector4 > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::SetBackgroundColor, color ); @@ -769,7 +904,7 @@ inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::SetDefaultSurfaceRect, rect ); @@ -780,7 +915,7 @@ inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds typedef MessageValue1< UpdateManager, float > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::KeepRendering, durationSeconds ); @@ -797,82 +932,351 @@ inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< La typedef MessageValue2< UpdateManager, std::vector< Layer* >, bool > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::SetLayerDepths, layers, systemLevel ); } -inline void AddMaterialMessage( UpdateManager& manager, Material* material ) +inline void AddGestureMessage( 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::AddGesture, gesture ); +} + +inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture ) { - typedef MessageValue1< UpdateManager, Material* > LocalType; + typedef MessageValue1< UpdateManager, PanGesture* > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::AddMaterial, material ); + new (slot) LocalType( &manager, &UpdateManager::RemoveGesture, gesture ); } -inline void RemoveMaterialMessage( UpdateManager& manager, Material* material ) +template< typename T > +inline void AddMessage( UpdateManager& manager, ObjectOwnerContainer& owner, T& object ) { - typedef MessageValue1< UpdateManager, Material* > LocalType; + typedef MessageValue1< ObjectOwnerContainer, OwnerPointer< T > > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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( &manager, &UpdateManager::RemoveMaterial, material ); + new (slot) LocalType( &owner, &ObjectOwnerContainer::Remove, &object ); } -inline void AddGestureMessage( UpdateManager& manager, PanGesture* gesture ) +// The render thread can safely change the Shader +inline void AddTextureSetMessage( UpdateManager& manager, TextureSet& textureSet ) { - typedef MessageValue1< UpdateManager, PanGesture* > LocalType; + typedef MessageValue1< UpdateManager, OwnerPointer< TextureSet > > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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 ); + new (slot) LocalType( &manager, &UpdateManager::AddTextureSet, &textureSet ); } -inline void RemoveGestureMessage( UpdateManager& manager, PanGesture* gesture ) +// The render thread can safely change the Shader +inline void RemoveTextureSetMessage( UpdateManager& manager, TextureSet& textureSet ) { - typedef MessageValue1< UpdateManager, PanGesture* > LocalType; + typedef MessageValue1< UpdateManager, TextureSet* > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::RemoveTextureSet, &textureSet ); +} + +inline void AddSamplerMessage( UpdateManager& manager, Render::Sampler& sampler ) +{ + typedef MessageValue1< UpdateManager, 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 ); +} + +inline void RemoveSamplerMessage( UpdateManager& manager, Render::Sampler& sampler ) +{ + typedef MessageValue1< UpdateManager, 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::RemoveSampler, &sampler ); +} + +inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int minFilterMode, unsigned int magFilterMode ) +{ + typedef MessageValue3< UpdateManager, Render::Sampler*, 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::SetFilterMode, &sampler, minFilterMode, magFilterMode ); +} + +inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode ) +{ + 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, rWrapMode, sWrapMode, tWrapMode ); +} + +inline void AddPropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer ) +{ + typedef MessageValue1< UpdateManager, 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 ); +} + +inline void RemovePropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer ) +{ + typedef MessageValue1< UpdateManager, 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::RemovePropertyBuffer, &propertyBuffer ); +} + +inline void SetPropertyBufferFormat( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Render::PropertyBuffer::Format* format ) +{ + typedef MessageValue2< UpdateManager, Render::PropertyBuffer*, Render::PropertyBuffer::Format* > 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::SetPropertyBufferFormat, &propertyBuffer, format ); +} + +inline void SetPropertyBufferData( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer, Vector* data, size_t size ) +{ + typedef MessageValue3< UpdateManager, Render::PropertyBuffer*, Vector*, size_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( &manager, &UpdateManager::SetPropertyBufferData, &propertyBuffer, data, size ); +} + +inline void AddGeometry( UpdateManager& manager, Render::Geometry& geometry ) +{ + typedef MessageValue1< UpdateManager, 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 ); +} + +inline void RemoveGeometry( UpdateManager& manager, Render::Geometry& geometry ) +{ + typedef MessageValue1< UpdateManager, 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::RemoveGeometry, &geometry ); +} + +inline void AddVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer ) +{ + typedef MessageValue2< UpdateManager, Render::Geometry*, 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::AddVertexBuffer, &geometry, const_cast(&vertexBuffer) ); +} + +inline void RemoveVertexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, const Render::PropertyBuffer& vertexBuffer ) +{ + typedef MessageValue2< UpdateManager, Render::Geometry*, 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::RemoveVertexBuffer, &geometry, const_cast(&vertexBuffer) ); +} + +// Custom message type for SetIndexBuffer() used to move data with Vector::Swap() +template< typename T > +class IndexBufferMessage : public MessageBase +{ +public: + + /** + * Constructor which does a Vector::Swap() + */ + IndexBufferMessage( T* manager, Render::Geometry* geometry, Dali::Vector& indices ) + : MessageBase(), + mManager( manager ), + mRenderGeometry( geometry ) + { + mIndices.Swap( indices ); + } + + /** + * Virtual destructor + */ + virtual ~IndexBufferMessage() + { + } + + /** + * @copydoc MessageBase::Process + */ + virtual void Process( BufferIndex /*bufferIndex*/ ) + { + DALI_ASSERT_DEBUG( mManager && "Message does not have an object" ); + mManager->SetIndexBuffer( mRenderGeometry, mIndices ); + } + +private: + + T* mManager; + Render::Geometry* mRenderGeometry; + Dali::Vector mIndices; +}; + +inline void SetIndexBufferMessage( UpdateManager& manager, Render::Geometry& geometry, Dali::Vector& indices ) +{ + typedef IndexBufferMessage< UpdateManager > 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, &geometry, indices ); +} + +inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& geometry, unsigned int geometryType ) +{ + typedef MessageValue2< UpdateManager, Render::Geometry*, 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::SetGeometryType, &geometry, geometryType ); +} + +inline void AddTexture( UpdateManager& manager, Render::NewTexture& texture ) +{ + typedef MessageValue1< UpdateManager, Render::NewTexture* > 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::NewTexture& texture ) +{ + typedef MessageValue1< UpdateManager, Render::NewTexture* > 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::NewTexture& texture, PixelDataPtr pixelData, const NewTexture::UploadParams& params ) +{ + typedef MessageValue3< UpdateManager, Render::NewTexture*, PixelDataPtr, NewTexture::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::NewTexture& texture ) +{ + typedef MessageValue1< UpdateManager, Render::NewTexture* > 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 ); } -#ifdef DYNAMICS_SUPPORT -// Dynamics messages -inline void InitializeDynamicsWorldMessage( UpdateManager& manager, DynamicsWorld* dynamicsworld, Integration::DynamicsWorldSettings* worldSettings ) +inline void AddFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer ) { - typedef MessageValue2< UpdateManager, DynamicsWorld*, Integration::DynamicsWorldSettings* > LocalType; + typedef MessageValue1< UpdateManager, Render::FrameBuffer* > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::InitializeDynamicsWorld, dynamicsworld, worldSettings ); + new (slot) LocalType( &manager, &UpdateManager::AddFrameBuffer, &frameBuffer ); } -inline void TerminateDynamicsWorldMessage(UpdateManager& manager) +inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer ) { - typedef Message< UpdateManager > LocalType; + typedef MessageValue1< UpdateManager, Render::FrameBuffer* > LocalType; // Reserve some memory inside the message queue - unsigned int* slot = manager.GetEventToUpdate().ReserveMessageSlot( sizeof( LocalType ) ); + 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::TerminateDynamicsWorld ); + new (slot) LocalType( &manager, &UpdateManager::RemoveFrameBuffer, &frameBuffer ); } -#endif // DYNAMICS_SUPPORT +inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int layer ) +{ + typedef MessageValue4< UpdateManager, Render::FrameBuffer*, Render::NewTexture*, 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 ); +} } // namespace SceneGraph