Glue glue and more glue 03/36803/5
authorDavid Steele <david.steele@partner.samsung.com>
Fri, 13 Mar 2015 16:50:11 +0000 (16:50 +0000)
committerFrancisco Santos <f1.santos@samsung.com>
Wed, 18 Mar 2015 11:58:15 +0000 (11:58 +0000)
Change-Id: Ifc894d222519f9c9328a8d7aa9e3bf325a1ba11b

26 files changed:
dali/internal/event/actor-attachments/renderer-attachment-impl.cpp
dali/internal/event/actors/renderer-impl.cpp
dali/internal/event/actors/renderer-impl.h
dali/internal/event/common/property-buffer-impl.cpp
dali/internal/event/common/property-buffer-impl.h
dali/internal/event/effects/material-impl.cpp
dali/internal/event/effects/material-impl.h
dali/internal/event/effects/sampler-impl.cpp
dali/internal/event/effects/sampler-impl.h
dali/internal/event/effects/shader-impl.cpp
dali/internal/event/effects/shader-impl.h
dali/internal/event/geometry/geometry-impl.cpp
dali/internal/event/geometry/geometry-impl.h
dali/internal/render/data-providers/material-data-provider.h
dali/internal/render/renderers/render-geometry.cpp
dali/internal/render/renderers/render-renderer.h
dali/internal/render/renderers/scene-graph-renderer.cpp
dali/internal/update/common/scene-graph-property-buffer.cpp
dali/internal/update/effects/scene-graph-material.cpp
dali/internal/update/effects/scene-graph-material.h
dali/internal/update/manager/object-owner-container.h
dali/internal/update/manager/update-manager.cpp
dali/internal/update/manager/update-manager.h
dali/internal/update/node-attachments/scene-graph-renderable-attachment.cpp
dali/internal/update/node-attachments/scene-graph-renderer-attachment.cpp
dali/internal/update/node-attachments/scene-graph-renderer-attachment.h

index c940c3e..cd31d59 100644 (file)
@@ -33,7 +33,7 @@ RendererAttachmentPtr RendererAttachment::New( Stage& stage, const SceneGraph::N
   RendererAttachmentPtr attachment( new RendererAttachment( stage ) );
 
   // Transfer object ownership of scene-object to message
-  SceneGraph::RendererAttachment* sceneObject = CreateSceneObject();
+  SceneGraph::RendererAttachment* sceneObject = renderer.GetRendererSceneObject();
   AttachToNodeMessage( stage.GetUpdateManager(), parentNode, sceneObject );
 
   // Keep raw pointer for message passing
index ff76a98..61622cc 100644 (file)
@@ -22,6 +22,7 @@
 #include <dali/public-api/actors/renderer.h> // Dali::Renderer
 #include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
 #include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
+#include <dali/internal/event/common/stage-impl.h>
 #include <dali/internal/update/node-attachments/scene-graph-renderer-attachment.h>
 
 namespace Dali
@@ -45,17 +46,23 @@ const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> RENDERER_IMPL = { DEFAULT_PROPERT
 
 RendererPtr Renderer::New()
 {
-  return RendererPtr( new Renderer() );
+  RendererPtr rendererPtr( new Renderer() );
+  rendererPtr->Initialize();
+  return rendererPtr;
 }
 
 void Renderer::SetGeometry( Geometry& geometry )
 {
   mGeometryConnector.Set( geometry, OnStage() );
+  const SceneGraph::Geometry* geometrySceneObject = geometry.GetGeometrySceneObject();
+  SetGeometryMessage( Stage::GetCurrent()->GetUpdateInterface(), *mSceneObject, *geometrySceneObject );
 }
 
 void Renderer::SetMaterial( Material& material )
 {
   mMaterialConnector.Set( material, OnStage() );
+  const SceneGraph::Material* materialSceneObject = material.GetMaterialSceneObject();
+  SetMaterialMessage( Stage::GetCurrent()->GetUpdateInterface(), *mSceneObject, *materialSceneObject );
 }
 
 void Renderer::SetDepthIndex( int depthIndex )
@@ -65,6 +72,11 @@ void Renderer::SetDepthIndex( int depthIndex )
   DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
 }
 
+SceneGraph::RendererAttachment* Renderer::GetRendererSceneObject()
+{
+  return mSceneObject;
+}
+
 unsigned int Renderer::GetDefaultPropertyCount() const
 {
   return RENDERER_IMPL.GetDefaultPropertyCount();
@@ -151,8 +163,8 @@ int Renderer::GetPropertyComponentIndex( Property::Index index ) const
 bool Renderer::OnStage() const
 {
   // TODO: MESH_REWORK
-  DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
-  return false;
+  //DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
+  return mOnStage;
 }
 
 void Renderer::Connect()
@@ -160,6 +172,7 @@ void Renderer::Connect()
   // TODO: MESH_REWORK : check this
   mGeometryConnector.OnStageConnect();
   mMaterialConnector.OnStageConnect();
+  mOnStage = true;
 }
 
 void Renderer::Disconnect()
@@ -167,12 +180,24 @@ void Renderer::Disconnect()
   // TODO: MESH_REWORK : check this
   mGeometryConnector.OnStageDisconnect();
   mMaterialConnector.OnStageDisconnect();
+  mOnStage = false;
 }
 
 Renderer::Renderer()
-: mSceneObject(NULL)
+: mSceneObject(NULL),
+  mOnStage(false)
 {
 }
 
+void Renderer::Initialize()
+{
+  // Transfer object ownership of scene-object to message
+  mSceneObject = SceneGraph::RendererAttachment::New();
+
+  // Send message to update to connect to scene graph:
+  AttachToSceneGraphMessage( Stage::GetCurrent()->GetUpdateManager(), mSceneObject );
+}
+
+
 } // namespace Internal
 } // namespace Dali
index e33b31d..ca341ff 100644 (file)
@@ -68,6 +68,13 @@ public:
    */
   void SetDepthIndex( int depthIndex );
 
+  /**
+   * @brief Get the scene graph object ( the node attachment )
+   *
+   * @return the scene object
+   */
+  SceneGraph::RendererAttachment* GetRendererSceneObject();
+
 public: // Default property extensions from Object
 
   /**
@@ -169,6 +176,8 @@ public: // Functions from Connectable
 private: // implementation
   Renderer();
 
+  void Initialize();
+
 private: // unimplemented methods
   Renderer( const Renderer& );
   Renderer& operator=( const Renderer& );
@@ -177,7 +186,7 @@ private: // data
   SceneGraph::RendererAttachment* mSceneObject;
   ObjectConnector<Geometry> mGeometryConnector; ///< Connector that holds the geometry used by this renderer
   ObjectConnector<Material> mMaterialConnector; ///< Connector that holds the material used by this renderer
-
+  bool mOnStage;
 };
 
 } // namespace Internal
index 7c03946..d3fb1db 100644 (file)
@@ -22,6 +22,7 @@
 #include <dali/public-api/object/property-buffer.h>     // Dali::Internal::PropertyBuffer
 #include <dali/internal/event/common/object-impl-helper.h> // Dali::Internal::ObjectHelper
 #include <dali/internal/event/common/property-helper.h> // DALI_PROPERTY_TABLE_BEGIN, DALI_PROPERTY, DALI_PROPERTY_TABLE_END
+#include <dali/internal/event/common/stage-impl.h>
 #include <dali/internal/update/common/scene-graph-property-buffer.h>
 
 namespace Dali
@@ -76,6 +77,11 @@ Dali::Property::Index PropertyBuffer::GetPropertyIndex( const std::string name,
   return 0;
 }
 
+const SceneGraph::PropertyBuffer* PropertyBuffer::GetPropertyBufferSceneObject() const
+{
+  return mSceneObject;
+}
+
 unsigned int PropertyBuffer::GetDefaultPropertyCount() const
 {
   return PROPERTY_BUFFER_IMPL.GetDefaultPropertyCount();
index ea53b72..de318ad 100644 (file)
@@ -71,6 +71,13 @@ public:
    */
   Dali::Property::Index GetPropertyIndex( const std::string name, std::size_t index );
 
+  /**
+   * @brief Get the propertyBuffer scene object
+   *
+   * @return the propertyBuffer scene object
+   */
+  const SceneGraph::PropertyBuffer* GetPropertyBufferSceneObject() const;
+
 public: // Default property extensions from Object
 
   /**
index d9418d5..12f17d1 100644 (file)
@@ -169,6 +169,11 @@ const Vector4& Material::GetBlendColor() const
   return Color::WHITE;
 }
 
+const SceneGraph::Material* Material::GetMaterialSceneObject() const
+{
+  return mSceneObject;
+}
+
 unsigned int Material::GetDefaultPropertyCount() const
 {
   return MATERIAL_IMPL.GetDefaultPropertyCount();
index 43a3c18..da51a7f 100644 (file)
@@ -135,6 +135,13 @@ public:
    */
   const Vector4& GetBlendColor() const;
 
+  /**
+   * @brief Get the material scene object
+   *
+   * @return the material scene object
+   */
+  const SceneGraph::Material* GetMaterialSceneObject() const;
+
 public: // Default property extensions from Object
 
   /**
index 55f6142..a94c10f 100644 (file)
@@ -93,6 +93,11 @@ void Sampler::SetAffectsTransparency( bool affectsTransparency )
   DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
 }
 
+const SceneGraph::Sampler* Sampler::GetSamplerSceneObject() const
+{
+  return mSceneObject;
+}
+
 unsigned int Sampler::GetDefaultPropertyCount() const
 {
   return SAMPLER_IMPL.GetDefaultPropertyCount();
index f62dad3..efefc94 100644 (file)
@@ -78,6 +78,13 @@ public:
    */
   void SetAffectsTransparency( bool affectsTransparency );
 
+  /**
+   * @brief Get the sampler scene object
+   *
+   * @return the sampler scene object
+   */
+  const SceneGraph::Sampler* GetSamplerSceneObject() const;
+
 public: // Default property extensions from Object
 
   /**
index e82b4e3..c3612dd 100644 (file)
@@ -60,6 +60,11 @@ ShaderPtr Shader::New( const std::string& vertexShader,
   return shader;
 }
 
+const SceneGraph::Shader* Shader::GetShaderSceneObject() const
+{
+  return mSceneObject;
+}
+
 unsigned int Shader::GetDefaultPropertyCount() const
 {
   return SHADER_IMPL.GetDefaultPropertyCount();
index 3f49ac2..7a5948b 100644 (file)
@@ -54,6 +54,13 @@ public:
                         const std::string& fragmentShader,
                         Dali::Shader::ShaderHints hints );
 
+  /**
+   * @brief Get the shader scene object
+   *
+   * @return the shader scene object
+   */
+  const SceneGraph::Shader* GetShaderSceneObject() const;
+
 public: // Default property extensions from Object
 
   /**
index efc93ef..8cff883 100644 (file)
@@ -101,6 +101,11 @@ bool Geometry::GetRequiresDepthTesting() const
   return false;
 }
 
+const SceneGraph::Geometry* Geometry::GetGeometrySceneObject() const
+{
+  return mSceneObject;
+}
+
 unsigned int Geometry::GetDefaultPropertyCount() const
 {
   return GEOMETRY_IMPL.GetDefaultPropertyCount();
index 5f667d8..83549c4 100644 (file)
@@ -96,6 +96,13 @@ public:
    */
   bool GetRequiresDepthTesting() const;
 
+  /**
+   * @brief Get the geometry scene object
+   *
+   * @return the geometry scene object
+   */
+  const SceneGraph::Geometry* GetGeometrySceneObject() const;
+
 public: // Default property extensions from Object
 
   /**
index 0be80e5..ddeb8f8 100644 (file)
@@ -25,6 +25,7 @@ namespace Internal
 namespace SceneGraph
 {
 class SamplerDataProvider;
+class Shader;
 
 
 class MaterialDataProvider
@@ -40,6 +41,12 @@ public:
   }
 
   /**
+   * Returns the shader
+   * @return The shader
+   */
+  virtual Shader* GetShader() const = 0;
+
+  /**
    * Returns the list of samplers that this material provides
    * @return The list of samplers
    */
index b8dcd92..c06fe7c 100644 (file)
@@ -196,12 +196,12 @@ void RenderGeometry::Draw( Context* context, BufferIndex bufferIndex, const Geom
   {
     case Dali::Geometry::TRIANGLES:
     {
-      context->DrawElements(GL_TRIANGLES, numIndices/3, GL_UNSIGNED_SHORT, 0);
+      context->DrawElements(GL_TRIANGLES, numIndices, GL_UNSIGNED_SHORT, 0);
       break;
     }
     case Dali::Geometry::LINES:
     {
-      context->DrawElements(GL_LINES, numIndices/2, GL_UNSIGNED_SHORT, 0);
+      context->DrawElements(GL_LINES, numIndices, GL_UNSIGNED_SHORT, 0);
       break;
     }
     case Dali::Geometry::POINTS:
index 13a4513..20e6c84 100644 (file)
@@ -179,12 +179,15 @@ private:
                                            const SamplerDataProvider& sampler );
 
 
-private:
+public:
+  // @todo MESH_REWORK Make private - add getters
   //const NodeDataProvider&     mNodeDataProvider;
   //const ShaderDataProvider&   mShaderDataProvider;
   const MaterialDataProvider* mMaterialDataProvider;
   const GeometryDataProvider* mGeometryDataProvider;
 
+private:
+
   RenderGeometry mRenderGeometry;
 
   struct TextureUnitUniformIndex
index f411d62..5ef9b9d 100644 (file)
@@ -27,6 +27,7 @@
 #include <dali/internal/render/data-providers/node-data-provider.h>
 #include <dali/public-api/actors/blending.h>
 #include <dali/internal/common/image-sampler.h>
+#include <dali/internal/render/renderers/render-renderer.h>
 
 namespace Dali
 {
@@ -158,7 +159,13 @@ void Renderer::Render( BufferIndex bufferIndex,
 {
   DALI_ASSERT_DEBUG( mContext && "Renderer::Render. Renderer not initialised!! (mContext == NULL)." );
 
-  // @todo
+  // @todo MESH_REWORK Fix when merging! :D
+  NewRenderer* renderer = dynamic_cast<NewRenderer*>(this);
+  if( renderer )
+  {
+    // Get the shader from the material:
+    mShader = renderer->mMaterialDataProvider->GetShader();
+  }
 
   // if mShader is NULL it means we're set to default
   if( !mShader )
index ab81fbe..699ad6b 100644 (file)
@@ -37,12 +37,12 @@ PropertyBuffer* PropertyBuffer::NewQuadVertices()
   PropertyBuffer* propertyBuffer = new PropertyBuffer();
   propertyBuffer->mElementSize = sizeof(Vector4);
   propertyBuffer->mData.Resize( propertyBuffer->mElementSize * 4 );
-  Vector4* vertices = reinterpret_cast<Vector4*>(propertyBuffer->mData[0]);
+  Vector4* vertices = reinterpret_cast<Vector4*>(&propertyBuffer->mData[0]);
 
-  vertices[ 0 ] = Vector4( -0.5f, -0.5f, 1.0f, 0.0f );
-  vertices[ 1 ] = Vector4(  0.5f, -0.5f, 1.0f, 1.0f );
-  vertices[ 2 ] = Vector4( -0.5f,  0.5f, 0.0f, 0.0f );
-  vertices[ 3 ] = Vector4(  0.5f,  0.5f, 0.0f, 1.0f );
+  vertices[ 0 ] = Vector4( -0.5f, -0.5f, 0.0f, 0.0f );
+  vertices[ 1 ] = Vector4(  0.5f, -0.5f, 1.0f, 0.0f );
+  vertices[ 2 ] = Vector4( -0.5f,  0.5f, 0.0f, 1.0f );
+  vertices[ 3 ] = Vector4(  0.5f,  0.5f, 1.0f, 1.0f );
 
   return propertyBuffer;
 }
@@ -54,7 +54,7 @@ PropertyBuffer* PropertyBuffer::NewQuadIndices()
 
   propertyBuffer->mElementSize = sizeof( unsigned short );
   propertyBuffer->mData.Resize( propertyBuffer->mElementSize * 6 );
-  unsigned short* indices = reinterpret_cast<unsigned short*>(propertyBuffer->mData[0]);
+  unsigned short* indices = reinterpret_cast<unsigned short*>(&propertyBuffer->mData[0]);
 
   indices[0] = 0;  indices[1] = 3;  indices[2] = 1;
   indices[3] = 0;  indices[4] = 2;  indices[5] = 3;
@@ -77,7 +77,7 @@ std::size_t PropertyBuffer::GetElementSize( BufferIndex bufferIndex ) const
 const void* PropertyBuffer::GetData( BufferIndex bufferIndex ) const
 {
   // @todo MESH_REWORK mData should be double buffered
-  return reinterpret_cast< const void* >(mData[0]);
+  return reinterpret_cast< const void* >(&mData[0]);
 }
 
 
index b854083..b05382f 100644 (file)
@@ -44,9 +44,10 @@ void Material::SetShader( const Shader* shader )
   // Need to inform renderer in render thread about this shader
 }
 
-const Shader* Material::GetShader() const
+Shader* Material::GetShader() const
 {
-  return mShader;
+  // @todo - Fix this - move shader setup to the Renderer connect to stage... or summit
+  return const_cast<Shader*>(mShader);
 }
 
 void Material::AddSampler( const Sampler* sampler )
index fab6529..d1fcd27 100644 (file)
@@ -59,7 +59,7 @@ public:
    * Get the shader effect of this material
    * @return the shader effect;
    */
-  const Shader* GetShader() const;
+  virtual Shader* GetShader() const;
 
   /**
    * Add a sampler (image + sampler modes) to the material
index d0a30f8..3a52c84 100644 (file)
@@ -23,6 +23,7 @@
 // INTERNAL INCLUDES
 #include <dali/internal/common/owner-container.h>
 #include <dali/internal/update/common/discard-queue.h>
+#include <dali/internal/update/controllers/scene-controller.h>
 
 namespace Dali
 {
@@ -53,12 +54,23 @@ public:
    * @param[in] discardQueue Queue to discard objects that might still be in use in the render thread.
    **/
   ObjectOwnerContainer( SceneGraphBuffers& sceneGraphBuffers, DiscardQueue& discardQueue )
-  : mSceneGraphBuffers( sceneGraphBuffers ),
+  : mSceneController( NULL ),
+    mSceneGraphBuffers( sceneGraphBuffers ),
     mDiscardQueue( discardQueue )
   {
   }
 
   /**
+   * @brief Set the SceneController on this owner
+   *
+   * @param[in] sceneController The SceneController
+   **/
+  void SetSceneController( SceneController& sceneController )
+  {
+    mSceneController = &sceneController;
+  }
+
+  /**
    * @brief Add an object to the owner
    *
    * @param[in] object Pointer to the object that will be owned
@@ -68,6 +80,9 @@ public:
     DALI_ASSERT_DEBUG( pointer && "Pointer should not be null" );
 
     mObjectContainer.PushBack( pointer );
+
+    // @todo MESH_REWORK FIX ME NOW!
+    //pointer->ConnectToSceneGraph(*mSceneController, mSceneGraphBuffers.GetUpdateBufferIndex() );
   }
 
   /**
@@ -86,6 +101,7 @@ public:
     DALI_ASSERT_DEBUG( match != mObjectContainer.End() && "Should always find a match" );
 
     mDiscardQueue.Add( mSceneGraphBuffers.GetUpdateBufferIndex(), mObjectContainer.Release( match ) );
+    pointer->DisconnectFromSceneGraph(*mSceneController, mSceneGraphBuffers.GetUpdateBufferIndex() );
   }
 
   /**
@@ -120,6 +136,7 @@ public:
   }
 
 private:
+  SceneController* mSceneController;      ///< SceneControler used to send messages
   ObjectContainer mObjectContainer;       ///< Container for the objects owned
   SceneGraphBuffers& mSceneGraphBuffers;  ///< Reference to a SceneGraphBuffers to get the indexBuffer
   DiscardQueue& mDiscardQueue;            ///< Discard queue used for removed objects
index 0c8b376..b62a925 100644 (file)
@@ -53,6 +53,7 @@
 #include <dali/internal/update/manager/update-algorithms.h>
 #include <dali/internal/update/manager/update-manager-debug.h>
 #include <dali/internal/update/node-attachments/scene-graph-camera-attachment.h>
+#include <dali/internal/update/node-attachments/scene-graph-renderer-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>
@@ -174,7 +175,7 @@ struct UpdateManager::Impl
     systemLevelTaskList ( completeStatusManager ),
     root( NULL ),
     systemLevelRoot( NULL ),
-    geometries( sceneGraphBuffers, discardQueue ),
+    geometries(  sceneGraphBuffers, discardQueue ),
     materials( sceneGraphBuffers, discardQueue ),
     samplers( sceneGraphBuffers, discardQueue ),
     propertyBuffers( sceneGraphBuffers, discardQueue ),
@@ -190,6 +191,11 @@ struct UpdateManager::Impl
     renderTaskWaiting( false )
   {
     sceneController = new SceneControllerImpl( renderMessageDispatcher, renderQueue, discardQueue, textureCache, completeStatusManager );
+
+    geometries.SetSceneController( *sceneController );
+    materials.SetSceneController( *sceneController );
+    propertyBuffers.SetSceneController( *sceneController );
+    samplers.SetSceneController( *sceneController );
   }
 
   ~Impl()
@@ -423,6 +429,7 @@ void UpdateManager::DestroyNode( Node* node )
   node->OnDestroy();
 }
 
+//@todo MESH_REWORK Extend to allow arbitrary scene objects to connect to each other
 void UpdateManager::AttachToNode( Node* node, NodeAttachment* attachment )
 {
   DALI_ASSERT_DEBUG( node != NULL );
@@ -433,6 +440,11 @@ void UpdateManager::AttachToNode( Node* node, NodeAttachment* attachment )
   attachment->ConnectToSceneGraph( *mImpl->sceneController, mSceneGraphBuffers.GetUpdateBufferIndex() );
 }
 
+void UpdateManager::AttachToSceneGraph( RendererAttachment* renderer )
+{
+  renderer->AttachToSceneGraph( *(mImpl->sceneController), mSceneGraphBuffers.GetUpdateBufferIndex() );
+}
+
 void UpdateManager::AddObject( PropertyOwner* object )
 {
   DALI_ASSERT_DEBUG( NULL != object );
index 27383a2..364390e 100644 (file)
@@ -38,7 +38,6 @@
 
 #include <dali/internal/render/shaders/scene-graph-shader.h>
 
-
 namespace Dali
 {
 
@@ -80,6 +79,7 @@ class Geometry;
 class PropertyBuffer;
 class Material;
 class Sampler;
+class RendererAttachment;
 
 /**
  * UpdateManager holds a scene graph i.e. a tree of nodes.
@@ -206,6 +206,12 @@ public:
   void AttachToNode( Node* node, NodeAttachment* attachment );
 
   /**
+   * Attach a renderer to the scene graph
+   */
+  void AttachToSceneGraph( RendererAttachment* renderer );
+
+
+  /**
    * Add a newly created object.
    * @param[in] object The object to add.
    * @post The object is owned by UpdateManager.
@@ -557,6 +563,17 @@ inline void AttachToNodeMessage( UpdateManager& manager, const Node& constParent
   new (slot) LocalType( &manager, &UpdateManager::AttachToNode, &parent, attachment );
 }
 
+inline void AttachToSceneGraphMessage( UpdateManager& manager, RendererAttachment* renderer )
+{
+  typedef MessageValue1< UpdateManager, RendererAttachment* > 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::AttachToSceneGraph, renderer );
+}
+
 inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object )
 {
   typedef MessageValue1< UpdateManager, OwnerPointer<PropertyOwner> > LocalType;
index 1ba9c7a..a60c39e 100644 (file)
@@ -243,7 +243,7 @@ void RenderableAttachment::PrepareRender( BufferIndex updateBufferIndex )
 }
 
 RenderableAttachment::RenderableAttachment( bool usesGeometryScaling )
-: mSceneController(NULL),
+: mSceneController(NULL), //@todo MESH_REWORK Pass in where required rather than store
   mShader( NULL ),
   mTrackedResources(),
   mSortModifier( 0.0f ),
index 1240841..95c6f4d 100644 (file)
 #include <dali/internal/render/queue/render-queue.h>
 #include <dali/internal/render/renderers/render-renderer.h>
 
+#if defined(DEBUG_ENABLED)
+Debug::Filter* gImageAttachmentLogFilter = Debug::Filter::New(Debug::NoLogging, false, "LOG_SCENE_GRAPH_IMAGE_ATTACHMENT");
+
+#define ATTACHMENT_LOG(level)                                                 \
+  DALI_LOG_INFO(gImageAttachmentLogFilter, level, "SceneGraph::ImageAttachment::%s: this:%p\n", __FUNCTION__, this)
+#define ATTACHMENT_LOG_FMT(level, format, args...) \
+  DALI_LOG_INFO(gImageAttachmentLogFilter, level, "SceneGraph::ImageAttachment::%s: this:%p " format, __FUNCTION__, this, ## args)
+
+#else
+
+#define ATTACHMENT_LOG(level)
+#define ATTACHMENT_LOG_FMT(level, format, args...)
+
+#endif
+
+
 namespace Dali
 {
 namespace Internal
@@ -56,6 +72,7 @@ void RendererAttachment::SetMaterial( BufferIndex updateBufferIndex, const Mater
   mMaterial = material;
 
   // Tell renderer about a new provider
+  if( mRenderer )
   {
     typedef MessageValue1< NewRenderer, const MaterialDataProvider*> DerivedType;
     unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
@@ -73,6 +90,7 @@ void RendererAttachment::SetGeometry( BufferIndex updateBufferIndex, const Geome
   mGeometry = geometry;
 
   // Tell renderer about a new provider
+  if( mRenderer )
   {
     typedef MessageValue1< NewRenderer, const GeometryDataProvider*> DerivedType;
     unsigned int* slot = mSceneController->GetRenderQueue().ReserveMessageSlot( updateBufferIndex, sizeof( DerivedType ) );
@@ -121,24 +139,31 @@ bool RendererAttachment::IsFullyOpaque( BufferIndex updateBufferIndex )
     opaque = mParent->GetWorldColor( updateBufferIndex ).a >= FULLY_OPAQUE;
   }
 
-  // Require that all affecting samplers are opaque
-  unsigned int opaqueCount=0;
-  unsigned int affectingCount=0;
-  const Material::Samplers& samplers = mMaterial->GetSamplers();
-  for( Material::Samplers::ConstIterator iter = samplers.Begin();
-       iter != samplers.End(); ++iter )
+  if( mMaterial != NULL )
   {
-    const Sampler* sampler = static_cast<const Sampler*>(*iter);
-    if( sampler->AffectsTransparency( updateBufferIndex ) )
+    // Require that all affecting samplers are opaque
+    unsigned int opaqueCount=0;
+    unsigned int affectingCount=0;
+
+    const Material::Samplers& samplers = mMaterial->GetSamplers();
+    for( Material::Samplers::ConstIterator iter = samplers.Begin();
+         iter != samplers.End(); ++iter )
     {
-      affectingCount++;
-      if( sampler->IsFullyOpaque( updateBufferIndex ) )
+      const Sampler* sampler = static_cast<const Sampler*>(*iter);
+      if( sampler != NULL )
       {
-        opaqueCount++;
+        if( sampler->AffectsTransparency( updateBufferIndex ) )
+        {
+          affectingCount++;
+          if( sampler->IsFullyOpaque( updateBufferIndex ) )
+          {
+            opaqueCount++;
+          }
+        }
       }
     }
+    opaque = (opaqueCount == affectingCount);
   }
-  opaque = (opaqueCount == affectingCount);
 
   return opaque;
 }
@@ -148,6 +173,11 @@ void RendererAttachment::SizeChanged( BufferIndex updateBufferIndex )
   // Do nothing.
 }
 
+void RendererAttachment::AttachToSceneGraph( SceneController& sceneController, BufferIndex updateBufferIndex )
+{
+  mSceneController = &sceneController;
+}
+
 void RendererAttachment::ConnectToSceneGraph2( BufferIndex updateBufferIndex )
 {
   DALI_ASSERT_DEBUG( mSceneController );
index 43ec50e..38a8fe3 100644 (file)
@@ -92,6 +92,11 @@ public:
    */
   int GetDepthIndex() const ;
 
+  /**
+   * Initial setup on attaching to the scene graph
+   */
+  void AttachToSceneGraph( SceneController& sceneController, BufferIndex updateBufferIndex );
+
 protected: // From RenderableAttachment
   /**
    * @copydoc RenderableAttachment::GetRenderer().
@@ -118,7 +123,7 @@ protected: // From RenderableAttachment
    */
   virtual void SizeChanged( BufferIndex updateBufferIndex );
 
-  /**
+/**
    * @copydoc RenderableAttachment::ConnectToSceneGraph2().
    */
   virtual void ConnectToSceneGraph2( BufferIndex updateBufferIndex );