Renamed ConnectionObservers class, un-consted objects 20/38220/3
authorDavid Steele <david.steele@partner.samsung.com>
Tue, 14 Apr 2015 20:05:07 +0000 (21:05 +0100)
committerDavid Steele <david.steele@partner.samsung.com>
Tue, 14 Apr 2015 20:19:04 +0000 (21:19 +0100)
ConnectionObservers class is poorly named - have changed it to
ConnectionChangePropagator, as it enables connection changes to be observed
by 'parent' objects.

SceneGraph objects such as Geometry, Material, Sampler and Shader were stored
as const objects in their parent classes - this is incorrect, as the parent
objects were const-casting; instead they are now stored as non-const, and the
constness is cast away between Event thread objects and SceneGraph objects in
the message passing (i.e. they are const for Event side usage, but non-const
for Update thread usage). Also changed containers to store scene graph objects
rather than their DataProvider interfaces.

Change-Id: I9930e6eabf6bc71c46adf8f15a7e0ea1ba5eaf90
Signed-off-by: David Steele <david.steele@partner.samsung.com>
15 files changed:
dali/internal/file.list
dali/internal/render/data-providers/geometry-data-provider.h
dali/internal/render/data-providers/render-data-provider.cpp
dali/internal/render/data-providers/render-data-provider.h
dali/internal/update/common/scene-graph-connection-change-propagator.cpp [moved from dali/internal/update/common/scene-graph-connection-observers.cpp with 79% similarity]
dali/internal/update/common/scene-graph-connection-change-propagator.h [moved from dali/internal/update/common/scene-graph-connection-observers.h with 87% similarity]
dali/internal/update/common/uniform-map.cpp
dali/internal/update/effects/scene-graph-material.cpp
dali/internal/update/effects/scene-graph-material.h
dali/internal/update/effects/scene-graph-sampler.cpp
dali/internal/update/effects/scene-graph-sampler.h
dali/internal/update/geometry/scene-graph-geometry.cpp
dali/internal/update/geometry/scene-graph-geometry.h
dali/internal/update/node-attachments/scene-graph-renderer-attachment.cpp
dali/internal/update/node-attachments/scene-graph-renderer-attachment.h

index f0c1d7d..cea6515 100644 (file)
@@ -169,7 +169,7 @@ internal_src_files = \
   $(internal_src_dir)/update/common/property-condition-variable-step-functions.cpp \
   $(internal_src_dir)/update/common/property-owner.cpp \
   $(internal_src_dir)/update/common/scene-graph-buffers.cpp \
-  $(internal_src_dir)/update/common/scene-graph-connection-observers.cpp \
+  $(internal_src_dir)/update/common/scene-graph-connection-change-propagator.cpp \
   $(internal_src_dir)/update/common/scene-graph-property-buffer.cpp \
   $(internal_src_dir)/update/common/scene-graph-property-notification.cpp \
   $(internal_src_dir)/update/common/uniform-map.cpp \
index bc593e6..56018c1 100644 (file)
@@ -31,16 +31,12 @@ namespace SceneGraph
 class PropertyBuffer;
 
 /**
- * An interface to provide geometry data, such as the vertex buffers
- * and index buffers (if present).  It provides a means of getting the
- * vertex attribute meta data and vertex data from each buffer.  It
- * provides the geometry type;
+ * An interface to provide geometry properties to the render thread.
  */
 class GeometryDataProvider
 {
 public:
   typedef Dali::Geometry::GeometryType GeometryType;
-  typedef Dali::Vector< const PropertyBufferDataProvider* > VertexBuffers;
 
   /**
    * Constructor. Nothing to do as a pure interface.
index eb4d462..8b7cf23 100644 (file)
@@ -24,22 +24,12 @@ namespace Internal
 namespace SceneGraph
 {
 
-RenderDataProvider::RenderDataProvider(
-  const GeometryDataProvider&   geometryDataProvider,
-  const MaterialDataProvider&   materialDataProvider,
-  const UniformMapDataProvider& uniformMapDataProvider,
-  Shader&                       shader,
-  const PropertyBufferDataProvider* indexBuffer,
-  const VertexBuffers&          vertexBuffers,
-  const Samplers&               samplers )
-
-: mGeometryDataProvider( &geometryDataProvider ),
-  mMaterialDataProvider( &materialDataProvider ),
-  mUniformMapDataProvider( &uniformMapDataProvider ),
-  mShader( &shader ),
-  mIndexBuffer( indexBuffer ),
-  mVertexBuffers( vertexBuffers ),
-  mSamplers( samplers )
+RenderDataProvider::RenderDataProvider()
+: mGeometryDataProvider( NULL ),
+  mMaterialDataProvider( NULL ),
+  mUniformMapDataProvider( NULL ),
+  mShader( NULL ),
+  mIndexBuffer( NULL )
 {
 }
 
index a068a57..ea83092 100644 (file)
@@ -51,14 +51,10 @@ public:
 
   /**
    * Constructor.
+   * The RendererAttachment that creates this object will initialize the members
+   * directly.
    */
-  RenderDataProvider( const GeometryDataProvider&   mGeometryDataProvider,
-                      const MaterialDataProvider&   mMaterialDataProvider,
-                      const UniformMapDataProvider& mUniformMapDataProvider,
-                      Shader&                       mShader,
-                      const PropertyBufferDataProvider* mIndexBuffer,
-                      const VertexBuffers&          mVertexBuffers,
-                      const Samplers&               mSamplers );
+  RenderDataProvider();
 
   /**
    * Destructor
@@ -157,6 +153,9 @@ private:
   const PropertyBufferDataProvider* mIndexBuffer;
   VertexBuffers                 mVertexBuffers;
   Samplers                      mSamplers;
+
+// Give RendererAttachment access to our private data to reduce copying vectors on construction.
+  friend class RendererAttachment;
 };
 
 } // SceneGraph
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "scene-graph-connection-observers.h"
+#include "scene-graph-connection-change-propagator.h"
 
 namespace Dali
 {
@@ -23,15 +23,15 @@ namespace Internal
 namespace SceneGraph
 {
 
-ConnectionObservers::ConnectionObservers()
+ConnectionChangePropagator::ConnectionChangePropagator()
 {
 }
 
-ConnectionObservers::~ConnectionObservers()
+ConnectionChangePropagator::~ConnectionChangePropagator()
 {
 }
 
-void ConnectionObservers::Add(Observer& observer)
+void ConnectionChangePropagator::Add(Observer& observer)
 {
   bool foundObserver = false;
   for( ObserversIterator iter = mObservers.Begin(); iter != mObservers.End(); ++iter )
@@ -48,7 +48,7 @@ void ConnectionObservers::Add(Observer& observer)
   }
 }
 
-void ConnectionObservers::Remove(Observer& observer)
+void ConnectionChangePropagator::Remove(Observer& observer)
 {
   for( ObserversIterator iter = mObservers.Begin(); iter != mObservers.End(); ++iter )
   {
@@ -60,7 +60,7 @@ void ConnectionObservers::Remove(Observer& observer)
   }
 }
 
-void ConnectionObservers::ConnectionsChanged(PropertyOwner& object)
+void ConnectionChangePropagator::ConnectionsChanged(PropertyOwner& object)
 {
   // Inform observers that the object's children have changed
   for( ObserversIterator iter = mObservers.Begin(); iter != mObservers.End(); ++iter )
@@ -70,7 +70,7 @@ void ConnectionObservers::ConnectionsChanged(PropertyOwner& object)
   }
 }
 
-void ConnectionObservers::ConnectedUniformMapChanged()
+void ConnectionChangePropagator::ConnectedUniformMapChanged()
 {
   // Inform observers that the object's uniform map has changed
   for( ObserversIterator iter = mObservers.Begin(); iter != mObservers.End(); ++iter )
@@ -1,5 +1,5 @@
-#ifndef DALI_INTERNAL_SCENE_GRAPH_CONNECTION_H
-#define DALI_INTERNAL_SCENE_GRAPH_CONNECTION_H
+#ifndef DALI_INTERNAL_SCENE_GRAPH_CONNECTION_CHANGE_PROPAGATOR_H
+#define DALI_INTERNAL_SCENE_GRAPH_CONNECTION_CHANGE_PROPAGATOR_H
 
 /*
  * Copyright (c) 2015 Samsung Electronics Co., Ltd.
@@ -31,7 +31,7 @@ class PropertyOwner;
  * This class maintains a list of observers that are informed when
  * it's owner changes it's connections.
  */
-class ConnectionObservers
+class ConnectionChangePropagator
 {
 public:
   class Observer
@@ -53,12 +53,12 @@ public:
   /**
    * Constructor
    */
-  ConnectionObservers();
+  ConnectionChangePropagator();
 
   /**
    * Destructor
    */
-  ~ConnectionObservers();
+  ~ConnectionChangePropagator();
 
   /**
    * Add an observer
@@ -94,4 +94,4 @@ private:
 } // Internal
 } // Dali
 
-#endif // DALI_INTERNAL_SCENE_GRAPH_CONNECTION_H
+#endif // DALI_INTERNAL_SCENE_GRAPH_CONNECTION_CHANGE_PROPAGATOR_H
index 58de329..a1400e5 100644 (file)
@@ -70,7 +70,7 @@ void UniformMap::MappingChanged()
   }
 }
 
-//
+// @todo MESH_REWORK Benchmark and test
 // The uniform map can never grow beyond the limits of GL - so really, the
 // map size is likely to be small; if retaining an unsorted map proves to be
 // slow, then it should be changed to perform an insertion sort.
index c0ee2ca..90ae5fa 100644 (file)
@@ -43,7 +43,7 @@ Material::~Material()
 {
 }
 
-void Material::SetShader( const Shader* shader )
+void Material::SetShader( Shader* shader )
 {
   mShader = shader;
   // Inform NewRenderer about this shader: (Will force a re-load of the
@@ -54,42 +54,29 @@ void Material::SetShader( const Shader* shader )
 Shader* Material::GetShader() const
 {
   // @todo - Fix this - move shader setup to the Renderer connect to stage...
-  return const_cast<Shader*>(mShader);
+  return mShader;
 }
 
-void Material::AddSampler( const Sampler* sampler )
+void Material::AddSampler( Sampler* sampler )
 {
-  const SamplerDataProvider* sdp = static_cast< const SamplerDataProvider*>( sampler );
-  mSamplers.PushBack( sdp );
+  mSamplers.PushBack( sampler );
 
-  Sampler* mutableSampler = const_cast<Sampler*>(sampler);
-  mutableSampler->AddConnectionObserver( *this );
-  mutableSampler->AddUniformMapObserver( *this );
+  sampler->AddConnectionObserver( *this );
+  sampler->AddUniformMapObserver( *this );
 
   mConnectionObservers.ConnectionsChanged(*this);
 }
 
-void Material::RemoveSampler( const Sampler* sampler )
+void Material::RemoveSampler( Sampler* sampler )
 {
-  const SamplerDataProvider* samplerDataProvider = sampler;
-  bool found = false;
+  Vector<Sampler*>::Iterator match = std::find( mSamplers.Begin(), mSamplers.End(), sampler );
 
-  RenderDataProvider::Samplers::Iterator iter = mSamplers.Begin();
-  for( ; iter != mSamplers.End(); ++iter )
+  DALI_ASSERT_DEBUG( mSamplers.End() != match );
+  if( mSamplers.End() != match )
   {
-    if( *iter == samplerDataProvider )
-    {
-      found = true;
-      break;
-    }
-  }
-
-  if( found )
-  {
-    Sampler* mutableSampler = const_cast<Sampler*>(sampler);
-    mutableSampler->RemoveConnectionObserver( *this );
-    mutableSampler->RemoveUniformMapObserver( *this );
-    mSamplers.Erase(iter);
+    sampler->RemoveConnectionObserver( *this );
+    sampler->RemoveUniformMapObserver( *this );
+    mSamplers.Erase( match );
     mConnectionObservers.ConnectionsChanged(*this);
   }
   else
@@ -98,7 +85,7 @@ void Material::RemoveSampler( const Sampler* sampler )
   }
 }
 
-const RenderDataProvider::Samplers& Material::GetSamplers() const
+Vector<Sampler*>& Material::GetSamplers()
 {
   return mSamplers;
 }
@@ -111,12 +98,12 @@ void Material::DisconnectFromSceneGraph( SceneController& sceneController, Buffe
 {
 }
 
-void Material::AddConnectionObserver( ConnectionObservers::Observer& observer )
+void Material::AddConnectionObserver( ConnectionChangePropagator::Observer& observer )
 {
   mConnectionObservers.Add(observer);
 }
 
-void Material::RemoveConnectionObserver( ConnectionObservers::Observer& observer )
+void Material::RemoveConnectionObserver( ConnectionChangePropagator::Observer& observer )
 {
   mConnectionObservers.Remove(observer);
 }
index f4e7f56..a450620 100644 (file)
@@ -24,9 +24,9 @@
 #include <dali/internal/update/common/animatable-property.h>
 #include <dali/internal/update/common/double-buffered-property.h>
 #include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/common/scene-graph-connection-observers.h>
+#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
 #include <dali/internal/update/common/uniform-map.h>
-#include <dali/internal/render/data-providers/render-data-provider.h>
+#include <dali/internal/render/data-providers/material-data-provider.h>
 
 namespace Dali
 {
@@ -39,7 +39,7 @@ class Shader;
 class ConnectionObserver;
 class SceneController;
 
-class Material : public PropertyOwner, public MaterialDataProvider, public UniformMap::Observer, public ConnectionObservers::Observer
+class Material : public PropertyOwner, public MaterialDataProvider, public UniformMap::Observer, public ConnectionChangePropagator::Observer
 {
 public:
   /**
@@ -56,19 +56,19 @@ public:
    * Set the shader effect for this material
    * @param[in] shader The shader effect to use
    */
-  void SetShader( const Shader* shader );
+  void SetShader( Shader* shader );
 
   /**
    * Add a sampler (image + sampler modes) to the material
    * @param[in] sampler A sampler to add
    */
-  void AddSampler( const Sampler* sampler );
+  void AddSampler( Sampler* sampler );
 
   /**
    * Remove a sampler (image + sampler modes) from the material
    * @param[in] sampler A sampler to remove
    */
-  void RemoveSampler( const Sampler* sampler );
+  void RemoveSampler( Sampler* sampler );
 
   /**
    * Connect the object to the scene graph
@@ -86,27 +86,27 @@ public:
   void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
 
   /**
-   * @copydoc ConnectionObservers::AddObserver
+   * @copydoc ConnectionChangePropagator::AddObserver
    */
-  void AddConnectionObserver(ConnectionObservers::Observer& observer);
+  void AddConnectionObserver(ConnectionChangePropagator::Observer& observer);
 
   /**
-   * @copydoc ConnectionObservers::RemoveObserver
+   * @copydoc ConnectionChangePropagator::RemoveObserver
    */
-  void RemoveConnectionObserver(ConnectionObservers::Observer& observer);
+  void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer);
 
-public: // MaterialDataProvider implementation
+public:
   /**
    * Get the shader effect of this material
    * @return the shader effect;
    */
-  virtual Shader* GetShader() const;
+  Shader* GetShader() const;
 
   /**
    * Get the samplers this material uses.
    * @return the samplers
    */
-  virtual const RenderDataProvider::Samplers& GetSamplers() const;
+  Vector<Sampler*>& GetSamplers();
 
 public: // UniformMap::Observer
   /**
@@ -114,15 +114,15 @@ public: // UniformMap::Observer
    */
   virtual void UniformMappingsChanged( const UniformMap& mappings );
 
-public: // ConnectionObserver::Observer
+public: // ConnectionChangePropagator::Observer
 
   /**
-   * @copydoc ConnectionObservers::ConnectionsChanged
+   * @copydoc ConnectionChangePropagator::ConnectionsChanged
    */
   virtual void ConnectionsChanged( PropertyOwner& owner );
 
   /**
-   * @copydoc ConnectionObservers::ConnectedUniformMapChanged
+   * @copydoc ConnectionChangePropagator::ConnectedUniformMapChanged
    */
   virtual void ConnectedUniformMapChanged( );
 
@@ -138,9 +138,9 @@ public: // Property data
   DoubleBufferedProperty<int> mFaceCullingMode;
 
 private:
-  const Shader* mShader;
-  RenderDataProvider::Samplers mSamplers; // Not owned
-  ConnectionObservers mConnectionObservers;
+  Shader* mShader;
+  Vector<Sampler*> mSamplers; // Not owned
+  ConnectionChangePropagator mConnectionObservers;
 
   // @todo MESH_REWORK add property values for cull face mode, blending options, blend color
   // Add getters/setters?
@@ -148,35 +148,35 @@ private:
 
 inline void SetShaderMessage( EventThreadServices& eventThreadServices, const Material& material, const Shader& shader )
 {
-  typedef MessageValue1< Material, const Shader* > LocalType;
+  typedef MessageValue1< Material, Shader* > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &material, &Material::SetShader, &shader );
+  new (slot) LocalType( &material, &Material::SetShader, const_cast<Shader*>(&shader) );
 }
 
 inline void AddSamplerMessage( EventThreadServices& eventThreadServices, const Material& material, const Sampler& sampler )
 {
-  typedef MessageValue1< Material, const Sampler* > LocalType;
+  typedef MessageValue1< Material, Sampler* > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &material, &Material::AddSampler, &sampler );
+  new (slot) LocalType( &material, &Material::AddSampler, const_cast<Sampler*>(&sampler) );
 }
 
-inline void RemoveSamplerMessage( EventThreadServices& eventThreadServices, const Material& material, const Sampler& sampler )
+inline void RemoveSamplerMessage( EventThreadServices& eventThreadServices, const Material& material, Sampler& sampler )
 {
-  typedef MessageValue1< Material, const Sampler* > LocalType;
+  typedef MessageValue1< Material, Sampler* > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &material, &Material::RemoveSampler, &sampler );
+  new (slot) LocalType( &material, &Material::RemoveSampler, const_cast<Sampler*>(&sampler) );
 }
 
 } // namespace SceneGraph
index dcb3b33..5b08856 100644 (file)
@@ -120,12 +120,12 @@ void Sampler::DisconnectFromSceneGraph(SceneController& sceneController, BufferI
 {
 }
 
-void Sampler::AddConnectionObserver( ConnectionObservers::Observer& observer )
+void Sampler::AddConnectionObserver( ConnectionChangePropagator::Observer& observer )
 {
   mConnectionObservers.Add(observer);
 }
 
-void Sampler::RemoveConnectionObserver( ConnectionObservers::Observer& observer )
+void Sampler::RemoveConnectionObserver( ConnectionChangePropagator::Observer& observer )
 {
   mConnectionObservers.Remove(observer);
 }
index 98f6070..fa85734 100644 (file)
@@ -23,7 +23,7 @@
 #include <dali/internal/update/common/double-buffered.h>
 #include <dali/internal/update/common/double-buffered-property.h>
 #include <dali/internal/update/common/property-owner.h>
-#include <dali/internal/update/common/scene-graph-connection-observers.h>
+#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
 #include <dali/internal/update/resources/bitmap-metadata.h>
 #include <dali/internal/render/data-providers/sampler-data-provider.h>
 
@@ -157,15 +157,16 @@ public: // SamplerDataProvider interface - called from RenderThread
    * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
    */
   void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
+
   /**
-   * @copydoc ConnectionObservers::AddObserver
+   * @copydoc ConnectionChangePropagator::AddObserver
    */
-  void AddConnectionObserver(ConnectionObservers::Observer& observer);
+  void AddConnectionObserver(ConnectionChangePropagator::Observer& observer);
 
   /**
-   * @copydoc ConnectionObservers::RemoveObserver
+   * @copydoc ConnectionChangePropagator::RemoveObserver
    */
-  void RemoveConnectionObserver(ConnectionObservers::Observer& observer);
+  void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer);
 
 public: // PropertyOwner implementation
   /**
@@ -183,7 +184,7 @@ public: // Properties
 private:
   std::string mTextureUnitUniformName; ///< The name of the uniform of the texture unit
   DoubleBufferedProperty<unsigned int> mTextureId;
-  ConnectionObservers mConnectionObservers; ///< Connection observers that will be informed when textures change.
+  ConnectionChangePropagator mConnectionObservers; ///< Connection observers that will be informed when textures change.
   bool mFullyOpaque; // Update only flag - no need for double buffering
 };
 
index e4cf29d..c91a3eb 100644 (file)
@@ -41,38 +41,37 @@ Geometry::~Geometry()
   // could remove self from own uniform map observer, but it's about to be destroyed.
 }
 
-void Geometry::AddVertexBuffer( const PropertyBuffer* vertexBuffer )
+void Geometry::AddVertexBuffer( PropertyBuffer* vertexBuffer )
 {
   mVertexBuffers.PushBack( vertexBuffer );
-  PropertyBuffer* theVertexBuffer = const_cast<PropertyBuffer*>(vertexBuffer);
-  theVertexBuffer->AddUniformMapObserver(*this);
+  vertexBuffer->AddUniformMapObserver(*this);
   mConnectionObservers.ConnectionsChanged(*this);
 }
 
-void Geometry::RemoveVertexBuffer( const PropertyBuffer* vertexBuffer )
+void Geometry::RemoveVertexBuffer( PropertyBuffer* vertexBuffer )
 {
   DALI_ASSERT_DEBUG( NULL != vertexBuffer );
 
   // Find the object and destroy it
-  VertexBuffers::Iterator match = std::find( mVertexBuffers.Begin(),
-                                             mVertexBuffers.End(),
-                                             vertexBuffer );
+  Vector<PropertyBuffer*>::Iterator match = std::find( mVertexBuffers.Begin(),
+                                                       mVertexBuffers.End(),
+                                                       vertexBuffer );
 
   DALI_ASSERT_DEBUG( mVertexBuffers.End() != match );
   if( mVertexBuffers.End() != match )
   {
-    PropertyBuffer* theVertexBuffer = const_cast<PropertyBuffer*>(vertexBuffer);
-    theVertexBuffer->RemoveUniformMapObserver(*this);
+    vertexBuffer->RemoveUniformMapObserver(*this);
     mVertexBuffers.Erase( match );
     mConnectionObservers.ConnectionsChanged(*this);
   }
 }
 
-void Geometry::SetIndexBuffer( const PropertyBuffer* indexBuffer )
+void Geometry::SetIndexBuffer( PropertyBuffer* indexBuffer )
 {
   if( mIndexBuffer != indexBuffer )
   {
     mIndexBuffer = indexBuffer;
+    indexBuffer->AddUniformMapObserver(*this);
     mConnectionObservers.ConnectionsChanged(*this);
   }
 }
@@ -80,6 +79,10 @@ void Geometry::SetIndexBuffer( const PropertyBuffer* indexBuffer )
 void Geometry::ClearIndexBuffer()
 {
   // @todo Actually delete, or put on Discard Queue and tell Renderer in render thread?
+  if( mIndexBuffer )
+  {
+    mIndexBuffer->RemoveUniformMapObserver(*this);
+  }
   mIndexBuffer = 0;
   mConnectionObservers.ConnectionsChanged(*this);
 }
@@ -89,12 +92,12 @@ void Geometry::SetGeometryType( BufferIndex bufferIndex, Geometry::GeometryType
   mGeometryType[bufferIndex] = geometryType;
 }
 
-const GeometryDataProvider::VertexBuffers& Geometry::GetVertexBuffers() const
+Vector<PropertyBuffer*>& Geometry::GetVertexBuffers()
 {
   return mVertexBuffers;
 }
 
-const PropertyBuffer* Geometry::GetIndexBuffer() const
+PropertyBuffer* Geometry::GetIndexBuffer()
 {
   return mIndexBuffer;
 }
@@ -129,12 +132,12 @@ void Geometry::DisconnectFromSceneGraph( SceneController& sceneController, Buffe
 {
 }
 
-void Geometry::AddConnectionObserver( ConnectionObservers::Observer& observer )
+void Geometry::AddConnectionObserver( ConnectionChangePropagator::Observer& observer )
 {
   mConnectionObservers.Add(observer);
 }
 
-void Geometry::RemoveConnectionObserver( ConnectionObservers::Observer& observer )
+void Geometry::RemoveConnectionObserver( ConnectionChangePropagator::Observer& observer )
 {
   mConnectionObservers.Remove(observer);
 }
index d2ca22c..94e56a2 100644 (file)
@@ -25,7 +25,7 @@
 #include <dali/internal/update/common/property-owner.h>
 #include <dali/internal/update/common/property-boolean.h>
 #include <dali/internal/update/common/uniform-map.h>
-#include <dali/internal/update/common/scene-graph-connection-observers.h>
+#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
 #include <dali/internal/update/common/scene-graph-property-buffer.h>
 #include <dali/internal/render/data-providers/geometry-data-provider.h>
 
@@ -58,19 +58,19 @@ public:
   /**
    * Add a property buffer to be used as a vertex buffer
    */
-  void AddVertexBuffer( const 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( const 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( const PropertyBuffer* indexBuffer );
+  void SetIndexBuffer( PropertyBuffer* indexBuffer );
 
   /**
    * Clear the index buffer if it is no longer required, e.g. if changing geometry type
@@ -102,12 +102,12 @@ public:
   /**
    * @copydoc ConnectionObservers::AddObserver
    */
-  void AddConnectionObserver(ConnectionObservers::Observer& observer);
+  void AddConnectionObserver(ConnectionChangePropagator::Observer& observer);
 
   /**
    * @copydoc ConnectionObservers::RemoveObserver
    */
-  void RemoveConnectionObserver(ConnectionObservers::Observer& observer);
+  void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer);
 
 public: // UniformMap::Observer
   /**
@@ -119,13 +119,13 @@ public: // UniformMap::Observer
    * Get the vertex buffers of the geometry
    * @return A const reference to the vertex buffers
    */
-  const GeometryDataProvider::VertexBuffers& GetVertexBuffers() const;
+  Vector<PropertyBuffer*>& GetVertexBuffers();
 
   /**
    * Get the index buffer of the geometry
-   * @return A const pointer to the index buffer if it exists, or NULL if it doesn't.
+   * @return A pointer to the index buffer if it exists, or NULL if it doesn't.
    */
-  const PropertyBuffer* GetIndexBuffer() const;
+   PropertyBuffer* GetIndexBuffer();
 
 public: // GeometryDataProvider
   /**
@@ -146,9 +146,9 @@ protected: // From PropertyOwner
   virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
 
 private:
-  VertexBuffers mVertexBuffers; ///< The vertex buffers
-  const PropertyBuffer* mIndexBuffer;  ///< The index buffer if required
-  ConnectionObservers mConnectionObservers;
+  Vector<PropertyBuffer*> mVertexBuffers; ///< The vertex buffers
+  PropertyBuffer* mIndexBuffer;  ///< The index buffer if required
+  ConnectionChangePropagator mConnectionObservers;
 
 public: // Properties
   AnimatableProperty<Vector3>  mCenter;
@@ -159,35 +159,35 @@ public: // Properties
 
 inline void AddVertexBufferMessage( EventThreadServices& eventThreadServices , const Geometry& geometry, const PropertyBuffer& vertexBuffer )
 {
-  typedef MessageValue1< Geometry, const PropertyBuffer* > LocalType;
+  typedef MessageValue1< Geometry, PropertyBuffer* > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &geometry, &Geometry::AddVertexBuffer, &vertexBuffer );
+  new (slot) LocalType( &geometry, &Geometry::AddVertexBuffer, const_cast<PropertyBuffer*>(&vertexBuffer) );
 }
 
 inline void RemoveVertexBufferMessage( EventThreadServices& eventThreadServices, const Geometry& geometry, const PropertyBuffer& vertexBuffer )
 {
-  typedef MessageValue1< Geometry, const PropertyBuffer* > LocalType;
+  typedef MessageValue1< Geometry, PropertyBuffer* > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &geometry, &Geometry::RemoveVertexBuffer, &vertexBuffer );
+  new (slot) LocalType( &geometry, &Geometry::RemoveVertexBuffer, const_cast<PropertyBuffer*>(&vertexBuffer) );
 }
 
 inline void SetIndexBufferMessage( EventThreadServices& eventThreadServices, const Geometry& geometry, const PropertyBuffer& indexBuffer )
 {
-  typedef MessageValue1< Geometry, const PropertyBuffer* > LocalType;
+  typedef MessageValue1< Geometry, PropertyBuffer* > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &geometry, &Geometry::SetIndexBuffer, &indexBuffer );
+  new (slot) LocalType( &geometry, &Geometry::SetIndexBuffer, const_cast<PropertyBuffer*>(&indexBuffer) );
 }
 
 inline void ClearIndexBufferMessage( EventThreadServices& eventThreadServices, const Geometry& geometry )
index ec07650..dce9ce6 100644 (file)
@@ -103,13 +103,7 @@ void RendererAttachment::ConnectedToSceneGraph()
 
   DALI_ASSERT_DEBUG( mParent != NULL );
 
-  RenderDataProvider* dataProvider = new RenderDataProvider( *mGeometry,
-                                                             *mMaterial,
-                                                             *this,
-                                                             *mMaterial->GetShader(),
-                                                             mGeometry->GetIndexBuffer(),
-                                                             mGeometry->GetVertexBuffers(),
-                                                             mMaterial->GetSamplers() );
+  RenderDataProvider* dataProvider = NewRenderDataProvider();
 
   mRenderer = NewRenderer::New( *mParent, dataProvider );
   mSceneController->GetRenderMessageDispatcher().AddRenderer( *mRenderer );
@@ -125,34 +119,34 @@ void RendererAttachment::DisconnectedFromSceneGraph()
   mRenderer = NULL;
 }
 
-void RendererAttachment::SetMaterial( BufferIndex updateBufferIndex, const Material* material)
+void RendererAttachment::SetMaterial( BufferIndex updateBufferIndex, Material* material)
 {
   DALI_ASSERT_DEBUG( material != NULL && "Material pointer is NULL" );
 
-  mMaterial = const_cast<Material*>(material); // Need this to be non-const to add observer only.
+  mMaterial = material;
   mMaterial->AddConnectionObserver( *this );
   mRegenerateUniformMap = REGENERATE_UNIFORM_MAP;
 
   mResendDataProviders = true;
 }
 
-const Material& RendererAttachment::GetMaterial() const
+Material& RendererAttachment::GetMaterial()
 {
   return *mMaterial;
 }
 
-void RendererAttachment::SetGeometry( BufferIndex updateBufferIndex, const Geometry* geometry)
+void RendererAttachment::SetGeometry( BufferIndex updateBufferIndex, Geometry* geometry)
 {
   DALI_ASSERT_DEBUG( geometry != NULL && "Geometry pointer is NULL");
 
-  mGeometry = const_cast<Geometry*>(geometry); // Need this to be non-const to add observer only
+  mGeometry = geometry;
   mGeometry->AddConnectionObserver( *this ); // Observe geometry connections / uniform mapping changes
   mRegenerateUniformMap = REGENERATE_UNIFORM_MAP;
 
   mResendDataProviders = true;
 }
 
-const Geometry& RendererAttachment::GetGeometry() const
+Geometry& RendererAttachment::GetGeometry()
 {
   return *mGeometry;
 }
@@ -199,12 +193,12 @@ void RendererAttachment::DoPrepareRender( BufferIndex updateBufferIndex )
       AddMappings( localMap, actorUniformMap );
 
       AddMappings( localMap, mMaterial->GetUniformMap() );
-      const RenderDataProvider::Samplers& samplers = mMaterial->GetSamplers();
-      for( RenderDataProvider::Samplers::ConstIterator iter = samplers.Begin(), end = samplers.End();
+      Vector<Sampler*>& samplers = mMaterial->GetSamplers();
+      for( Vector<Sampler*>::ConstIterator iter = samplers.Begin(), end = samplers.End();
            iter != end ;
            ++iter )
       {
-        const SceneGraph::Sampler* sampler = static_cast<const SceneGraph::Sampler*>( *iter );
+        const SceneGraph::Sampler* sampler = (*iter);
         AddMappings( localMap, sampler->GetUniformMap() );
       }
 
@@ -212,15 +206,21 @@ void RendererAttachment::DoPrepareRender( BufferIndex updateBufferIndex )
 
       AddMappings( localMap, mGeometry->GetUniformMap() );
 
-      const GeometryDataProvider::VertexBuffers& vertexBuffers = mGeometry->GetVertexBuffers();
-      for( GeometryDataProvider::VertexBuffers::ConstIterator iter = vertexBuffers.Begin(), end = vertexBuffers.End() ;
+      Vector<PropertyBuffer*>& vertexBuffers = mGeometry->GetVertexBuffers();
+      for( Vector<PropertyBuffer*>::ConstIterator iter = vertexBuffers.Begin(), end = vertexBuffers.End() ;
            iter != end ;
            ++iter )
       {
-        const SceneGraph::PropertyBuffer* vertexBuffer = static_cast<const SceneGraph::PropertyBuffer*>( *iter );
+        const SceneGraph::PropertyBuffer* vertexBuffer = *iter;
         AddMappings( localMap, vertexBuffer->GetUniformMap() );
       }
 
+      PropertyBuffer* indexBuffer = mGeometry->GetIndexBuffer();
+      if( indexBuffer )
+      {
+        AddMappings( localMap, indexBuffer->GetUniformMap() );
+      }
+
       mUniformMapChanged[updateBufferIndex] = true;
     }
     else if( mRegenerateUniformMap == COPY_UNIFORM_MAP )
@@ -245,13 +245,7 @@ void RendererAttachment::DoPrepareRender( BufferIndex updateBufferIndex )
 
   if( mResendDataProviders )
   {
-    RenderDataProvider* dataProvider = new RenderDataProvider( *mGeometry,
-                                                               *mMaterial,
-                                                               *this,
-                                                               *mMaterial->GetShader(),
-                                                               mGeometry->GetIndexBuffer(),
-                                                               mGeometry->GetVertexBuffers(),
-                                                               mMaterial->GetSamplers() );
+    RenderDataProvider* dataProvider = NewRenderDataProvider();
 
     // Tell renderer about a new provider
     // @todo MESH_REWORK Should we instead create a new renderer when these change?
@@ -259,7 +253,6 @@ void RendererAttachment::DoPrepareRender( BufferIndex updateBufferIndex )
     typedef MessageValue1< NewRenderer, OwnerPointer<RenderDataProvider> > DerivedType;
     unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
     new (slot) DerivedType( mRenderer, &NewRenderer::SetRenderDataProvider, dataProvider );
-
     mResendDataProviders = false;
   }
 }
@@ -279,11 +272,11 @@ bool RendererAttachment::IsFullyOpaque( BufferIndex updateBufferIndex )
     unsigned int opaqueCount=0;
     unsigned int affectingCount=0;
 
-    const RenderDataProvider::Samplers& samplers = mMaterial->GetSamplers();
-    for( RenderDataProvider::Samplers::ConstIterator iter = samplers.Begin();
+    Vector<Sampler*>& samplers = mMaterial->GetSamplers();
+    for( Vector<Sampler*>::ConstIterator iter = samplers.Begin();
          iter != samplers.End(); ++iter )
     {
-      const Sampler* sampler = static_cast<const Sampler*>(*iter);
+      const Sampler* sampler = *iter;
       if( sampler != NULL )
       {
         if( sampler->AffectsTransparency( updateBufferIndex ) )
@@ -328,17 +321,16 @@ bool RendererAttachment::DoPrepareResources(
     unsigned int neverCount = 0;
     unsigned int frameBufferCount = 0;
 
-    const RenderDataProvider::Samplers& samplers = mMaterial->GetSamplers();
-    for( RenderDataProvider::Samplers::ConstIterator iter = samplers.Begin();
+    Vector<Sampler*>& samplers = mMaterial->GetSamplers();
+    for( Vector<Sampler*>::ConstIterator iter = samplers.Begin();
          iter != samplers.End(); ++iter )
     {
-      const Sampler* sampler = static_cast<const Sampler*>(*iter);
+      Sampler* sampler = *iter;
 
       ResourceId textureId = sampler->GetTextureId( updateBufferIndex );
       BitmapMetadata metaData = resourceManager.GetBitmapMetadata( textureId );
 
-      Sampler* mutableSampler = const_cast<Sampler*>(sampler);
-      mutableSampler->SetFullyOpaque( metaData.IsFullyOpaque() );
+      sampler->SetFullyOpaque( metaData.IsFullyOpaque() );
 
       switch( completeStatusManager.GetStatus( textureId ) )
       {
@@ -454,6 +446,36 @@ void RendererAttachment::AddMappings( CollectedUniformMap& localMap, const Unifo
   }
 }
 
+RenderDataProvider* RendererAttachment::NewRenderDataProvider()
+{
+  RenderDataProvider* dataProvider = new RenderDataProvider();
+
+  dataProvider->mGeometryDataProvider = mGeometry;
+  dataProvider->mMaterialDataProvider = mMaterial;
+  dataProvider->mUniformMapDataProvider = this;
+  dataProvider->mShader = mMaterial->GetShader();
+  dataProvider->mIndexBuffer = mGeometry->GetIndexBuffer();
+
+  Vector<PropertyBuffer*>& vertexBuffers = mGeometry->GetVertexBuffers();
+  dataProvider->mVertexBuffers.Reserve( vertexBuffers.Count() );
+
+  for( Vector<PropertyBuffer*>::Iterator iter = vertexBuffers.Begin() ;
+       iter != vertexBuffers.End();
+       ++iter )
+  {
+    dataProvider->mVertexBuffers.PushBack(*iter); // Convert from derived type to base type
+  }
+
+  Vector<Sampler*>& samplers = mMaterial->GetSamplers();
+  dataProvider->mSamplers.Reserve( samplers.Count() );
+  for( Vector<Sampler*>::Iterator iter = samplers.Begin() ;
+       iter != samplers.End();
+       ++iter )
+  {
+    dataProvider->mSamplers.PushBack(*iter); // Convert from derived type to base type
+  }
+  return dataProvider;
+}
 
 
 } // namespace SceneGraph
index f3a61e2..fe210c4 100644 (file)
@@ -21,7 +21,7 @@
 #include <dali/internal/update/common/double-buffered.h>
 #include <dali/internal/update/common/property-owner.h>
 #include <dali/internal/update/common/animatable-property.h>
-#include <dali/internal/update/common/scene-graph-connection-observers.h>
+#include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
 #include <dali/internal/update/controllers/render-message-dispatcher.h>
 #include <dali/internal/update/controllers/scene-controller.h>
 #include <dali/internal/update/node-attachments/scene-graph-renderable-attachment.h>
@@ -59,7 +59,7 @@ class RendererAttachment : public RenderableAttachment,
                            public PropertyOwner,
                            public UniformMapDataProvider,
                            public UniformMap::Observer,
-                           public ConnectionObservers::Observer
+                           public ConnectionChangePropagator::Observer
 {
 public:
   /**
@@ -103,26 +103,26 @@ public:
    * @param[in] bufferIndex The current frame's buffer index
    * @param[in] material The material this renderer will use
    */
-  void SetMaterial( BufferIndex bufferIndex, const Material* material);
+  void SetMaterial( BufferIndex bufferIndex, Material* material);
 
   /**
    * Get the material of this renderer
    * @return the material this renderer uses
    */
-  const Material& GetMaterial() const;
+  Material& GetMaterial();
 
   /**
    * Set the geometry for the renderer
    * @param[in] bufferIndex The current frame's buffer index
    * @param[in] geometry The geometry this renderer will use
    */
-  void SetGeometry( BufferIndex bufferIndex, const Geometry* geometry);
+  void SetGeometry( BufferIndex bufferIndex, Geometry* geometry);
 
   /**
    * Get the geometry of this renderer
    * @return the geometry this renderer uses
    */
-  const Geometry& GetGeometry() const;
+  Geometry& GetGeometry();
 
   /**
    * Get the depth index
@@ -199,6 +199,12 @@ private:
    */
   void AddMappings( CollectedUniformMap& localMap, const UniformMap& map );
 
+  /**
+   * Create a new render data provider
+   * @return the new (initialized) data provider
+   */
+  RenderDataProvider* NewRenderDataProvider();
+
 private:
   NewRenderer* mRenderer; ///< Raw pointer to the new renderer (that's owned by RenderManager)
 
@@ -219,24 +225,24 @@ public: // Properties
 
 inline void SetMaterialMessage( EventThreadServices& eventThreadServices, const RendererAttachment& attachment, const Material& material )
 {
-  typedef MessageDoubleBuffered1< RendererAttachment, const Material* > LocalType;
+  typedef MessageDoubleBuffered1< RendererAttachment, Material* > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &attachment, &RendererAttachment::SetMaterial, &material );
+  new (slot) LocalType( &attachment, &RendererAttachment::SetMaterial, const_cast<Material*>(&material) );
 }
 
 inline void SetGeometryMessage( EventThreadServices& eventThreadServices, const RendererAttachment& attachment, const Geometry& geometry )
 {
-  typedef MessageDoubleBuffered1< RendererAttachment, const Geometry* > LocalType;
+  typedef MessageDoubleBuffered1< RendererAttachment, Geometry* > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &attachment, &RendererAttachment::SetGeometry, &geometry );
+  new (slot) LocalType( &attachment, &RendererAttachment::SetGeometry, const_cast<Geometry*>(&geometry) );
 }
 
 } // namespace SceneGraph