Revert "Move new mesh API to devel-api"
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / renderer-impl.cpp
index 42a935e..f11870d 100644 (file)
@@ -20,6 +20,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/public-api/actors/renderer.h> // Dali::Renderer
+#include <dali/public-api/object/type-registry.h>
 #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/property-input-impl.h>
@@ -38,11 +39,18 @@ namespace
  *            |name          |type     |writable|animatable|constraint-input|enum for index-checking|
  */
 DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "depth-index", INTEGER,  true, true, true, Dali::Renderer::Property::DEPTH_INDEX )
+DALI_PROPERTY( "depth-index", INTEGER, true, false, false, Dali::Renderer::Property::DEPTH_INDEX )
 DALI_PROPERTY_TABLE_END( DEFAULT_OBJECT_PROPERTY_START_INDEX )
 
 const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> RENDERER_IMPL = { DEFAULT_PROPERTY_DETAILS };
 
+BaseHandle Create()
+{
+  return Dali::BaseHandle();
+}
+
+TypeRegistration mType( typeid( Dali::Renderer ), typeid( Dali::Handle ), Create );
+
 } // unnamed namespace
 
 RendererPtr Renderer::New()
@@ -60,6 +68,11 @@ void Renderer::SetGeometry( Geometry& geometry )
   SetGeometryMessage( GetEventThreadServices(), *mSceneObject, *geometrySceneObject );
 }
 
+Geometry* Renderer::GetGeometry() const
+{
+  return mGeometryConnector.Get().Get();
+}
+
 void Renderer::SetMaterial( Material& material )
 {
   mMaterialConnector.Set( material, OnStage() );
@@ -67,20 +80,23 @@ void Renderer::SetMaterial( Material& material )
   SetMaterialMessage( GetEventThreadServices(), *mSceneObject, *materialSceneObject );
 }
 
-void Renderer::SetDepthIndex( int depthIndex )
+Material* Renderer::GetMaterial() const
 {
-  SceneGraph::AnimatablePropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mDepthIndex, &SceneGraph::AnimatableProperty<int>::Bake, depthIndex );
+  return mMaterialConnector.Get().Get();
 }
 
-int Renderer::GetCurrentDepthIndex() const
+void Renderer::SetDepthIndex( int depthIndex )
 {
-  int depthIndex = 0;
-  if( mSceneObject )
+  if ( mDepthIndex != depthIndex )
   {
-    BufferIndex bufferIndex = GetEventThreadServices().GetEventBufferIndex();
-    depthIndex = mSceneObject->mDepthIndex[bufferIndex];
+    mDepthIndex = depthIndex;
+    SetDepthIndexMessage( GetEventThreadServices(), *mSceneObject, depthIndex );
   }
-  return depthIndex;
+}
+
+int Renderer::GetDepthIndex() const
+{
+  return mDepthIndex;
 }
 
 SceneGraph::RendererAttachment* Renderer::GetRendererSceneObject()
@@ -156,7 +172,7 @@ Property::Value Renderer::GetDefaultProperty( Property::Index index ) const
   {
     case Dali::Renderer::Property::DEPTH_INDEX:
     {
-      value = GetCurrentDepthIndex();
+      value = GetDepthIndex();
     }
     break;
   }
@@ -185,18 +201,6 @@ const SceneGraph::PropertyBase* Renderer::GetSceneObjectAnimatableProperty( Prop
       &Renderer::FindAnimatableProperty,
       &Renderer::FindCustomProperty,
       index );
-
-    if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
-    {
-      switch(index)
-      {
-        case Dali::Renderer::Property::DEPTH_INDEX:
-        {
-          property = &mSceneObject->mDepthIndex;
-        }
-        break;
-      }
-    }
   }
 
   return property;
@@ -214,18 +218,6 @@ const PropertyInputImpl* Renderer::GetSceneObjectInputProperty( Property::Index
                                                      &Renderer::FindCustomProperty,
                                                      index );
     property = static_cast<const PropertyInputImpl*>( baseProperty );
-
-    if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
-    {
-      switch(index)
-      {
-        case Dali::Renderer::Property::DEPTH_INDEX:
-        {
-          property = &mSceneObject->mDepthIndex;
-        }
-        break;
-      }
-    }
   }
 
   return property;
@@ -259,13 +251,13 @@ void Renderer::Disconnect()
 
 Renderer::Renderer()
 : mSceneObject(NULL),
+  mDepthIndex(0),
   mOnStage(false)
 {
 }
 
 void Renderer::Initialize()
 {
-  DALI_ASSERT_ALWAYS( EventThreadServices::IsCoreRunning() && "Core is not running" );
   EventThreadServices& eventThreadServices = GetEventThreadServices();
   SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
 
@@ -274,10 +266,20 @@ void Renderer::Initialize()
 
   // Send message to update to connect to scene graph:
   AttachToSceneGraphMessage( updateManager, mSceneObject );
+
+  eventThreadServices.RegisterObject( this );
 }
 
 Renderer::~Renderer()
 {
+  if( EventThreadServices::IsCoreRunning() )
+  {
+    EventThreadServices& eventThreadServices = GetEventThreadServices();
+    SceneGraph::UpdateManager& updateManager = eventThreadServices.GetUpdateManager();
+    RemoveObjectMessage( updateManager, mSceneObject );
+
+    eventThreadServices.UnregisterObject( this );
+  }
 }
 
 } // namespace Internal