$(internal_src_dir)/update/animation/scene-graph-constraint-base.cpp \
$(internal_src_dir)/update/common/discard-queue.cpp \
$(internal_src_dir)/update/common/property-base.cpp \
- $(internal_src_dir)/update/common/property-buffer.cpp \
+ $(internal_src_dir)/update/common/scene-graph-property-buffer.cpp \
$(internal_src_dir)/update/common/property-condition-functions.cpp \
$(internal_src_dir)/update/common/property-condition-step-functions.cpp \
$(internal_src_dir)/update/common/property-condition-variable-step-functions.cpp \
}
}
+void DiscardQueue::Add( BufferIndex updateBufferIndex, Geometry* geometry )
+{
+ DALI_ASSERT_DEBUG( NULL != geometry );
+
+ // The GL resources will now be freed in frame N
+ // The Update for frame N+1 may occur in parallel with the rendering of frame N
+ // Queue the node for destruction in frame N+2
+ if ( 0u == updateBufferIndex )
+ {
+ mGeometryQueue0.PushBack( geometry );
+ }
+ else
+ {
+ mGeometryQueue1.PushBack( geometry );
+ }
+}
+
+void DiscardQueue::Add( BufferIndex updateBufferIndex, Material* material )
+{
+ DALI_ASSERT_DEBUG( NULL != material );
+
+ // The GL resources will now be freed in frame N
+ // The Update for frame N+1 may occur in parallel with the rendering of frame N
+ // Queue the node for destruction in frame N+2
+ if ( 0u == updateBufferIndex )
+ {
+ mMaterialQueue0.PushBack( material );
+ }
+ else
+ {
+ mMaterialQueue1.PushBack( material );
+ }
+}
+
+
void DiscardQueue::Add( BufferIndex updateBufferIndex, Shader* shader )
{
DALI_ASSERT_DEBUG( NULL != shader );
mNodeQueue0.Clear();
mAttachmentQueue0.Clear();
mShaderQueue0.Clear();
+ mGeometryQueue0.Clear();
+ mMaterialQueue0.Clear();
}
else
{
mNodeQueue1.Clear();
mAttachmentQueue1.Clear();
mShaderQueue1.Clear();
+ mGeometryQueue1.Clear();
+ mMaterialQueue1.Clear();
}
}
#include <dali/internal/common/owner-container.h>
#include <dali/internal/update/nodes/node-declarations.h>
#include <dali/internal/update/node-attachments/node-attachment-declarations.h>
+#include <dali/internal/update/geometry/scene-graph-geometry.h>
+#include <dali/internal/update/effects/scene-graph-material.h>
namespace Dali
{
public:
typedef OwnerContainer< Shader* > ShaderQueue;
+ typedef OwnerContainer< Geometry* > GeometryQueue;
+ typedef OwnerContainer< Material* > MaterialQueue;
/**
* Create a new DiscardQueue.
void Add( BufferIndex updateBufferIndex, NodeAttachment* attachment );
/**
+ * Adds an unwanted geometry to the discard queue.
+ * A message will be sent to clean up GL resources in the next Render
+ */
+ void Add( BufferIndex updateBufferIndex, Geometry* geometry );
+
+ /**
+ * Adds an unwanted material to the discard queue.
+ * A message will be sent to clean up GL resources in the next Render.
+ */
+ void Add( BufferIndex updateBufferIndex, Material* material );
+
+ /**
* Adds an unwanted shader to the discard queue.
* A message will be sent to clean-up GL resources in the next Render.
* @pre This method is not thread-safe, and should only be called from the update-thread.
NodeOwnerContainer mNodeQueue0;
NodeAttachmentOwnerContainer mAttachmentQueue0;
ShaderQueue mShaderQueue0;
+ GeometryQueue mGeometryQueue0;
+ MaterialQueue mMaterialQueue0;
// Messages are queued here when the update buffer index == 1
NodeOwnerContainer mNodeQueue1;
NodeAttachmentOwnerContainer mAttachmentQueue1;
ShaderQueue mShaderQueue1;
+ GeometryQueue mGeometryQueue1;
+ MaterialQueue mMaterialQueue1;
};
} // namespace SceneGraph
* limitations under the License.
*/
-#include "property-buffer.h"
+#include "scene-graph-property-buffer.h"
namespace Dali
{
class PropertyBuffer
{
public:
+ //@todo MESH_REWORK Remove when we have working property buffers
+ static PropertyBuffer* NewQuadVertices();
+
+ //@todo MESH_REWORK Remove when we have working property buffers
+ static PropertyBuffer* NewQuadIndices();
+
/**
* Constructor
*/
/**
* Constructor
*/
- UniformMap;
+ UniformMap();
+
+ /**
+ * Destructor
+ */
+ ~UniformMap();
private:
// data
{
Material::Material()
-: mShader(NULL),
- mCullFaceMode( CullNone ),
- mBlendingOptions()
+: mShader(NULL)
{
}
return mShader;
}
-void Material::AddSampler( Sampler* sampler )
+void Material::AddSampler( const Sampler* sampler )
{
// @todo MESH_REWORK
}
-void Material::RemoveSampler( Sampler* sampler )
+void Material::RemoveSampler( const Sampler* sampler )
{
// @todo MESH_REWORK
}
return mSamplers;
}
-void Material::SetFaceCulling( BufferIndex updateBufferIndex, Dali::CullFaceMode mode )
-{
- // @todo MESH_REWORK
-}
-
-CullFaceMode Material::GetFaceCulling() const
-{
- // @todo MESH_REWORK
- return mCullFaceMode;
-}
-
-void Material::SetBlendingOptions( BufferIndex updateBufferIndex, unsigned int options )
-{
- // @todo MESH_REWORK
-}
-
-void Material::SetBlendColor( BufferIndex updateBufferIndex, const Vector4& color )
-{
- // @todo MESH_REWORK
-}
} // namespace SceneGraph
#include <dali/public-api/actors/renderable-actor.h> // For CullFaceMode
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/common/blending-options.h>
+#include <dali/internal/common/event-to-update.h>
#include <dali/internal/update/common/double-buffered.h>
#include <dali/internal/update/common/property-owner.h>
#include <dali/internal/render/renderers/material-data-provider.h>
* Add a sampler (image + sampler modes) to the material
* @param[in] sampler A sampler to add
*/
- void AddSampler( Sampler* sampler );
+ void AddSampler( const Sampler* sampler );
/**
* Remove a sampler (image + sampler modes) from the material
* @param[in] sampler A sampler to remove
*/
- void RemoveSampler( Sampler* sampler );
+ void RemoveSampler( const Sampler* sampler );
/**
* Get the samplers this material uses.
*/
const Samplers& GetSamplers() const;
- /**
- * Set the face culling mode for geometry used by this material
- * @param[in] mode The face culling mode to use
- */
- void SetFaceCulling( BufferIndex updateBufferIndex, Dali::CullFaceMode mode );
+private:
+ Shader* mShader;
+ Samplers mSamplers; // Not owned (though who does?)
- /**
- * Get the face culling mode
- * @return the face culling mdoe
- */
- CullFaceMode GetFaceCulling() const ;
+ // @todo MESH_REWORK add property values for cull face mode, blending options, blend color
+ // Add getters/setters?
+};
- // @note Blending mode is per actor, not per material (requires actor color)
+inline void SetShaderMessage( EventToUpdate& eventToUpdate, const Material& material, Shader& shader )
+{
+ typedef MessageValue1< Material, Shader* > LocalType;
- /**
- * Set the blending options. This should only be called from the update-thread.
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] options A bitmask of blending options.
- */
- void SetBlendingOptions( BufferIndex updateBufferIndex, unsigned int options );
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
- /**
- * Set the blend-color. This should only be called from the update-thread.
- * @param[in] updateBufferIndex The current update buffer index.
- * @param[in] color The new blend-color.
- */
- void SetBlendColor( BufferIndex updateBufferIndex, const Vector4& color );
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &material, &Material::SetShader, &shader );
+}
-private:
- Shader* mShader;
- Samplers mSamplers; // Not owned (though who does?)
- Dali::CullFaceMode mCullFaceMode:3;
- BlendingOptions mBlendingOptions;
-};
+inline void AddSamplerMessage( EventToUpdate& eventToUpdate, const Material& material, const Sampler& sampler )
+{
+ typedef MessageValue1< Material, const Sampler* > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &material, &Material::AddSampler, &sampler );
+}
+
+inline void RemoveSamplerMessage( EventToUpdate& eventToUpdate, const Material& material, const Sampler& sampler )
+{
+ typedef MessageValue1< Material, const Sampler* > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &material, &Material::RemoveSampler, &sampler );
+}
} // namespace SceneGraph
} // namespace Internal
void Sampler::SetTextureId( ResourceId textureId )
{
+ mTextureId = textureId;
}
void Sampler::SetFilterMode( BufferIndex bufferIndex, FilterMode minFilter, FilterMode magFilter )
{
+ mMinFilter[bufferIndex] = minFilter;
+ mMagFilter[bufferIndex] = magFilter;
}
void Sampler::SetWrapMode( BufferIndex bufferIndex, WrapMode uWrap, WrapMode vWrap )
*/
#include <dali/public-api/shader-effects/sampler.h>
+#include <dali/internal/common/event-to-update.h>
#include <dali/internal/update/common/double-buffered.h>
#include <dali/internal/update/common/property-owner.h>
#include <dali/internal/render/renderers/sampler-data-provider.h>
DoubleBuffered<WrapMode> mVWrapMode; ///< The vertical wrap mode
};
+inline void SetUniformNameMessage( EventToUpdate& eventToUpdate, const Sampler& sampler, const std::string& name )
+{
+ typedef MessageValue1< Sampler, std::string > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &sampler, &Sampler::SetUniformName, name );
+}
+
+} // namespace SceneGraph
+
+// Declare enum as a message parameter type outside the SceneGraph namespace
+template <> struct ParameterType< SceneGraph::Sampler::FilterMode > : public BasicType< SceneGraph::Sampler::FilterMode > {};
+
+namespace SceneGraph
+{
+
+inline void SetFilterModeMessage( EventToUpdate& eventToUpdate, const Sampler& sampler, Sampler::FilterMode minFilter, Sampler::FilterMode magFilter )
+{
+ typedef MessageDoubleBuffered2< Sampler, Sampler::FilterMode, Sampler::FilterMode > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &sampler, &Sampler::SetFilterMode, minFilter, magFilter );
+}
+
+} // namespace SceneGraph
+
+// Declare enum as a message parameter type
+template <> struct ParameterType< SceneGraph::Sampler::WrapMode > : public BasicType< SceneGraph::Sampler::WrapMode > {};
+
+namespace SceneGraph
+{
+
+inline void SetWrapModeMessage( EventToUpdate& eventToUpdate, const SceneGraph::Sampler& sampler, SceneGraph::Sampler::WrapMode horizontalWrap, SceneGraph::Sampler::WrapMode verticalWrap )
+{
+ typedef MessageDoubleBuffered2< Sampler, Sampler::WrapMode, Sampler::WrapMode > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &sampler, &Sampler::SetWrapMode, horizontalWrap, verticalWrap );
+}
+
+
} // namespace SceneGraph
} // namespace Internal
} // namespace Dali
Geometry::Geometry()
: mGeometryType(Dali::Geometry::TRIANGLES)
{
+ // @todo MESH_REWORK Remove this code when we have working property buffers
+ // @todo It's also the wrong place to do this temporary work
+ PropertyBuffer* vertexPropertyBuffer = PropertyBuffer::NewQuadVertices();
+ mVertexBuffers.PushBack( vertexPropertyBuffer );
+
+ mIndexBuffer = PropertyBuffer::NewQuadIndices();
}
Geometry::~Geometry()
{
+ // @todo Inform renderers of deletion of buffers?
+}
+
+void Geometry::AddVertexBuffer( PropertyBuffer* vertexBuffer )
+{
+ mVertexBuffers.PushBack( vertexBuffer );
}
-void Geometry::AddVertexBuffer( PropertyBuffer vertexBuffer )
+void Geometry::RemoveVertexBuffer( PropertyBuffer* vertexBuffer )
{
+ DALI_ASSERT_DEBUG( NULL != vertexBuffer );
+
+ // Find the object and destroy it
+ for ( OwnerContainer< PropertyBuffer* >::Iterator iter = mVertexBuffers.Begin(); iter != mVertexBuffers.End(); ++iter )
+ {
+ PropertyBuffer* current = *iter;
+ if ( current == vertexBuffer )
+ {
+ mVertexBuffers.Erase( iter );
+ return;
+ }
+ }
+
+ DALI_ASSERT_DEBUG(false);
}
-void Geometry::RemoveVertexBuffer( PropertyBuffer vertexBuffer )
+void Geometry::SetIndexBuffer( PropertyBuffer* indexBuffer )
{
+ mIndexBuffer = indexBuffer;
}
-void Geometry::SetIndexBuffer( PropertyBuffer indexBuffer )
+void Geometry::ClearIndexBuffer()
{
+ // @todo Actually delete, or put on Discard Queue and tell Renderer in render thread?
+ mIndexBuffer.Reset();
}
void Geometry::SetGeometryType( Geometry::GeometryType geometryType )
{
+ mGeometryType = geometryType;
}
const Geometry::VertexBuffers& Geometry::GetVertexBuffers()
const PropertyBuffer& Geometry::GetIndexBuffer()
{
- return mIndexBuffer;
+ return *mIndexBuffer.Get();
}
Geometry::GeometryType Geometry::GetGeometryType( )
*/
#include <dali/public-api/geometry/geometry.h>
+#include <dali/internal/common/event-to-update.h>
#include <dali/internal/update/common/double-buffered.h>
#include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/common/property-buffer.h>
+#include <dali/internal/update/common/scene-graph-property-buffer.h>
namespace Dali
{
/**
* Add a property buffer to be used as a vertex buffer
*/
- void AddVertexBuffer( PropertyBuffer vertexBuffer );
+ void AddVertexBuffer( PropertyBuffer* vertexBuffer );
/**
* Remove a property buffer to be used as a vertex buffer
* @param[in] vertexBuffer the associated vertex buffer to remove
*/
- void RemoveVertexBuffer( PropertyBuffer vertexBuffer );
+ void RemoveVertexBuffer( PropertyBuffer* vertexBuffer );
/**
* Set the buffer to be used as a source of indices for the geometry
* @param[in] indexBuffer the Property buffer describing the indexes for Line, Triangle tyes.
*/
- void SetIndexBuffer( PropertyBuffer indexBuffer );
+ void SetIndexBuffer( PropertyBuffer* indexBuffer );
+
+ /**
+ * Clear the index buffer if it is no longer required, e.g. if changing geometry type
+ * to POINTS.
+ */
+ void ClearIndexBuffer();
/**
* Set the type of geometry to draw (Points, Lines, Triangles, etc)
private:
VertexBuffers mVertexBuffers; ///< The vertex buffers
- PropertyBuffer mIndexBuffer; ///< The index buffer if required
+ OwnerPointer<PropertyBuffer> mIndexBuffer; ///< The index buffer if required
GeometryType mGeometryType; ///< The type of geometry (tris/lines etc)
};
+inline void AddVertexBufferMessage( EventToUpdate& eventToUpdate, const Geometry& geometry, PropertyBuffer& vertexBuffer )
+{
+ typedef MessageValue1< Geometry, OwnerPointer<PropertyBuffer> > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &geometry, &Geometry::AddVertexBuffer, &vertexBuffer );
+}
+
+inline void RemoveVertexBufferMessage( EventToUpdate& eventToUpdate, const Geometry& geometry, PropertyBuffer& vertexBuffer )
+{
+ typedef MessageValue1< Geometry, PropertyBuffer* > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &geometry, &Geometry::RemoveVertexBuffer, &vertexBuffer );
+}
+
+inline void SetIndexBufferMessage( EventToUpdate& eventToUpdate, const Geometry& geometry, PropertyBuffer& indexBuffer )
+{
+ typedef MessageValue1< Geometry, OwnerPointer< PropertyBuffer > > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &geometry, &Geometry::SetIndexBuffer, &indexBuffer );
+}
+
+inline void ClearIndexBufferMessage( EventToUpdate& eventToUpdate, const Geometry& geometry )
+{
+ typedef Message< Geometry > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &geometry, &Geometry::ClearIndexBuffer );
+}
+
+} // namespace SceneGraph
+
+// Declare enum as a message parameter type
+template <> struct ParameterType< SceneGraph::Geometry::GeometryType > : public BasicType< SceneGraph::Geometry::GeometryType > {};
+
+namespace SceneGraph
+{
+
+inline void SetGeometryTypeMessage( EventToUpdate& eventToUpdate, const Geometry& geometry, SceneGraph::Geometry::GeometryType geometryType )
+{
+ typedef MessageValue1< Geometry, SceneGraph::Geometry::GeometryType > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &geometry, &Geometry::SetGeometryType, geometryType );
+}
+
} // namespace SceneGraph
} // namespace Internal
} // namespace Dali
#include <dali/internal/update/animation/scene-graph-animator.h>
#include <dali/internal/update/animation/scene-graph-animation.h>
#include <dali/internal/update/common/discard-queue.h>
+#include <dali/internal/update/common/scene-graph-buffers.h>
+#include <dali/internal/update/controllers/render-message-dispatcher.h>
+#include <dali/internal/update/controllers/scene-controller-impl.h>
+#include <dali/internal/update/effects/scene-graph-material.h>
+#include <dali/internal/update/geometry/scene-graph-geometry.h>
+#include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
#include <dali/internal/update/manager/prepare-render-algorithms.h>
#include <dali/internal/update/manager/process-render-tasks.h>
-#include <dali/internal/update/resources/resource-manager.h>
-#include <dali/internal/update/resources/complete-status-manager.h>
-#include <dali/internal/update/common/scene-graph-buffers.h>
-#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
-#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
#include <dali/internal/update/manager/sorted-layers.h>
#include <dali/internal/update/manager/update-algorithms.h>
-#include <dali/internal/update/queue/update-message-queue.h>
#include <dali/internal/update/manager/update-manager-debug.h>
-#include <dali/internal/update/controllers/render-message-dispatcher.h>
-#include <dali/internal/update/controllers/scene-controller-impl.h>
-#include <dali/internal/update/gestures/scene-graph-pan-gesture.h>
#include <dali/internal/update/node-attachments/scene-graph-camera-attachment.h>
#include <dali/internal/update/nodes/node.h>
#include <dali/internal/update/nodes/scene-graph-layer.h>
+#include <dali/internal/update/queue/update-message-queue.h>
+#include <dali/internal/update/render-tasks/scene-graph-render-task.h>
+#include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
+#include <dali/internal/update/resources/resource-manager.h>
+#include <dali/internal/update/resources/complete-status-manager.h>
#include <dali/internal/update/touch/touch-resampler.h>
#include <dali/internal/render/common/render-instruction-container.h>
} //namespace
+typedef OwnerContainer< Geometry* > GeometryContainer;
+typedef GeometryContainer::Iterator GeometryIter;
+typedef GeometryContainer::ConstIterator GeometryConstIter;
+
+typedef OwnerContainer< Material* > MaterialContainer;
+typedef MaterialContainer::Iterator MaterialIter;
+typedef MaterialContainer::ConstIterator MaterialConstIter;
+
typedef OwnerContainer< Shader* > ShaderContainer;
typedef ShaderContainer::Iterator ShaderIter;
typedef ShaderContainer::ConstIterator ShaderConstIter;
AnimationContainer animations; ///< A container of owned animations
PropertyNotificationContainer propertyNotifications; ///< A container of owner property notifications.
+ GeometryContainer geometries; ///< A container of geometries
+ MaterialContainer materials; ///< A container of materials
+
ShaderContainer shaders; ///< A container of owned shaders
MessageQueue messageQueue; ///< The messages queued from the event-thread
propertyNotification->SetNotifyMode( notifyMode );
}
+
+void UpdateManager::AddGeometry( Geometry* geometry )
+{
+ DALI_ASSERT_DEBUG( NULL != geometry );
+ mImpl->geometries.PushBack( geometry );
+}
+
+void UpdateManager::RemoveGeometry( Geometry* geometry )
+{
+ DALI_ASSERT_DEBUG(geometry != NULL);
+
+ GeometryContainer& geometries = mImpl->geometries;
+
+ // Find the geometry and destroy it
+ for ( GeometryIter iter = geometries.Begin(); iter != geometries.End(); ++iter )
+ {
+ Geometry& current = **iter;
+ if ( ¤t == geometry )
+ {
+ // Transfer ownership to the discard queue
+ // This keeps the geometry alive, until the render-thread has finished with it
+ mImpl->discardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), geometries.Release( iter ) );
+
+ return;
+ }
+ }
+
+ // Should not reach here
+ DALI_ASSERT_DEBUG(false);
+}
+
+void UpdateManager::AddMaterial( Material* material )
+{
+ DALI_ASSERT_DEBUG( NULL != material );
+
+ mImpl->materials.PushBack( material );
+}
+
+void UpdateManager::RemoveMaterial( Material* material )
+{
+ DALI_ASSERT_DEBUG(material != NULL);
+
+ MaterialContainer& materials = mImpl->materials;
+
+ // Find the material and destroy it
+ for ( MaterialIter iter = materials.Begin(); iter != materials.End(); ++iter )
+ {
+ Material& current = **iter;
+ if ( ¤t == material )
+ {
+ // Transfer ownership to the discard queue
+ // This keeps the material alive, until the render-thread has finished with it
+ mImpl->discardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), materials.Release( iter ) );
+
+ return;
+ }
+ }
+ // Should not reach here
+ DALI_ASSERT_DEBUG(false);
+}
+
void UpdateManager::AddShader( Shader* shader )
{
DALI_ASSERT_DEBUG( NULL != shader );
shader->Initialize( mImpl->renderQueue, mImpl->sceneController->GetTextureCache() );
}
-void UpdateManager::RemoveShader(Shader* shader)
+void UpdateManager::RemoveShader( Shader* shader )
{
DALI_ASSERT_DEBUG(shader != NULL);
(*iter)->ResetToBaseValues( mSceneGraphBuffers.GetUpdateBufferIndex() );
}
+ // Reset animatable material properties to base values
+ for (MaterialIter iter = mImpl->materials.Begin(); iter != mImpl->materials.End(); ++iter)
+ {
+ (*iter)->ResetToBaseValues( mSceneGraphBuffers.GetUpdateBufferIndex() );
+ }
+
+ // Reset animatable geometry properties to base values
+ for (GeometryIter iter = mImpl->geometries.Begin(); iter != mImpl->geometries.End(); ++iter)
+ {
+ (*iter)->ResetToBaseValues( mSceneGraphBuffers.GetUpdateBufferIndex() );
+ }
+
// Reset animatable shader properties to base values
for (ShaderIter iter = mImpl->shaders.Begin(); iter != mImpl->shaders.End(); ++iter)
{
mImpl->activeConstraints += ConstrainPropertyOwner( task, mSceneGraphBuffers.GetUpdateBufferIndex() );
}
+ // Constrain Materials and geometries
+ MaterialContainer& materials = mImpl->materials;
+ for ( MaterialIter iter = materials.Begin(); iter != materials.End(); ++iter )
+ {
+ Material& material = **iter;
+ mImpl->activeConstraints += ConstrainPropertyOwner( material, mSceneGraphBuffers.GetUpdateBufferIndex() );
+ }
+
+ GeometryContainer& geometries = mImpl->geometries;
+ for ( GeometryIter iter = geometries.Begin(); iter != geometries.End(); ++iter )
+ {
+ Geometry& geometry = **iter;
+ mImpl->activeConstraints += ConstrainPropertyOwner( geometry, mSceneGraphBuffers.GetUpdateBufferIndex() );
+ }
+
// constrain shaders... (in construction order)
ShaderContainer& shaders = mImpl->shaders;
// INTERNAL INCLUDES
#include <dali/public-api/common/vector-wrapper.h>
#include <dali/public-api/common/dali-common.h>
+
#include <dali/integration-api/resource-declarations.h>
+
#include <dali/internal/common/message.h>
#include <dali/internal/common/event-to-update.h>
-#include <dali/internal/render/shaders/scene-graph-shader.h>
-#include <dali/internal/update/nodes/node.h>
-#include <dali/internal/update/node-attachments/node-attachment.h>
-#include <dali/internal/update/common/scene-graph-buffers.h>
+#include <dali/internal/common/type-abstraction-enums.h>
+
#include <dali/internal/update/animation/scene-graph-animation.h>
+#include <dali/internal/update/common/scene-graph-buffers.h>
#include <dali/internal/update/common/scene-graph-property-notification.h>
+#include <dali/internal/update/geometry/scene-graph-geometry.h>
+#include <dali/internal/update/effects/scene-graph-material.h>
+#include <dali/internal/update/node-attachments/node-attachment.h>
+#include <dali/internal/update/nodes/node.h>
#include <dali/internal/update/nodes/scene-graph-layer.h>
-#include <dali/internal/common/type-abstraction-enums.h>
+
+#include <dali/internal/render/shaders/scene-graph-shader.h>
namespace Dali
{
*/
void PropertyNotificationSetNotify( PropertyNotification* propertyNotification, PropertyNotification::NotifyMode notifyMode );
+
+ /**
+ * Add a geometry to the scene graph
+ * @param[in] geometry The geometry to add
+ */
+ void AddGeometry( Geometry* geometry );
+
+ /**
+ * Remove a geometry from the scene graph
+ * @param[in] geometry The geometry to remove
+ */
+ void RemoveGeometry( Geometry* geometry );
+
+ /**
+ * Add a material to the scene graph
+ * @param[in] material The material to add
+ */
+ void AddMaterial( Material* material );
+
+ /**
+ * Remove a material from the scene graph
+ * @param[in] material The material to remove
+ */
+ void RemoveMaterial( Material* material );
+
// Shaders
/**
new (slot) LocalType( &manager, &UpdateManager::PropertyNotificationSetNotify, propertyNotification, notifyMode );
}
+inline void AddGeometryMessage( UpdateManager& manager, Geometry& geometry )
+{
+ typedef MessageValue1< UpdateManager, OwnerPointer< Geometry > > 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::AddGeometry, &geometry );
+}
+
+// The render thread can safely change the Geometry
+inline void RemoveGeometryMessage( UpdateManager& manager, Geometry& geometry )
+{
+ typedef MessageValue1< UpdateManager, Geometry* > 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::RemoveGeometry, &geometry );
+}
+
+inline void AddMaterialMessage( UpdateManager& manager, Material& material )
+{
+ typedef MessageValue1< UpdateManager, OwnerPointer< Material > > 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::AddMaterial, &material );
+}
+
+// The render thread can safely change the Material
+inline void RemoveMaterialMessage( UpdateManager& manager, Material& material )
+{
+ typedef MessageValue1< UpdateManager, Material* > 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::RemoveMaterial, &material );
+}
+
+
// The render thread can safely change the Shader
inline void AddShaderMessage( UpdateManager& manager, Shader& shader )
{
mGeometry=NULL;
}
-void RendererAttachment::SetMaterial(const Material& material)
+void RendererAttachment::SetMaterial(const Material* material)
{
// @todo MESH_REWORK
- mMaterial = &material;
+ mMaterial = material;
}
const Material& RendererAttachment::GetMaterial() const
return *mMaterial;
}
-void RendererAttachment::SetGeometry(const Geometry& geometry)
+void RendererAttachment::SetGeometry(const Geometry* geometry)
{
// @todo MESH_REWORK
- mGeometry = &geometry;
+ mGeometry = geometry;
}
const Geometry& RendererAttachment::GetGeometry() const
* Set the material for the renderer
* @param[in] material The material this renderer will use
*/
- void SetMaterial(const Material& material);
+ void SetMaterial(const Material* material);
/**
* Get the material of this renderer
* Set the geometry for the renderer
* @param[in] geometry The geometry this renderer will use
*/
- void SetGeometry(const Geometry& geometry);
+ void SetGeometry(const Geometry* geometry);
/**
* Get the geometry of this renderer
int mDepthIndex; ///< Used only in PrepareRenderInstructions
};
+// Messages for RendererAttachment
+
+inline void SetMaterialMessage( EventToUpdate& eventToUpdate, const RendererAttachment& attachment, const Material& material )
+{
+ typedef MessageValue1< RendererAttachment, const Material* > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &attachment, &RendererAttachment::SetMaterial, &material );
+}
+
+inline void SetGeometryMessage( EventToUpdate& eventToUpdate, const RendererAttachment& attachment, const Geometry& geometry )
+{
+ typedef MessageValue1< RendererAttachment, const Geometry* > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &attachment, &RendererAttachment::SetGeometry, &geometry );
+}
+
+inline void SetDepthIndexMessage( EventToUpdate& eventToUpdate, const RendererAttachment& attachment, int depthIndex )
+{
+ typedef MessageValue1< RendererAttachment, int > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+ // Construct message in the message queue memory; note that delete should not be called on the return value
+ new (slot) LocalType( &attachment, &RendererAttachment::SetDepthIndex, depthIndex );
+}
+
} // namespace SceneGraph
} // namespace Internal
} // namespace Dali