Reduce ImageActor & RenderableActor APIs
[platform/core/uifw/dali-core.git] / dali / public-api / actors / renderable-actor.cpp
index 11ad014..5dec5b4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 
 // INTERNAL INCLUDES
 #include <dali/internal/event/actors/renderable-actor-impl.h>
+#include <dali/internal/event/effects/shader-effect-impl.h>
 
 namespace Dali
 {
@@ -39,6 +40,17 @@ RenderableActor::~RenderableActor()
 {
 }
 
+RenderableActor::RenderableActor(const RenderableActor& copy)
+: Actor(copy)
+{
+}
+
+RenderableActor& RenderableActor::operator=(const RenderableActor& rhs)
+{
+  BaseHandle::operator=(rhs);
+  return *this;
+}
+
 void RenderableActor::SetSortModifier(float modifier)
 {
   GetImplementation(*this).SetSortModifier(modifier);
@@ -69,11 +81,6 @@ BlendingMode::Type RenderableActor::GetBlendMode() const
   return GetImplementation(*this).GetBlendMode();
 }
 
-void RenderableActor::SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba )
-{
-  GetImplementation(*this).SetBlendFunc( srcFactorRgba, destFactorRgba );
-}
-
 void RenderableActor::SetBlendFunc( BlendingFactor::Type srcFactorRgb,   BlendingFactor::Type destFactorRgb,
                                     BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha )
 {
@@ -86,29 +93,31 @@ void RenderableActor::GetBlendFunc( BlendingFactor::Type& srcFactorRgb,   Blendi
   GetImplementation(*this).GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
 }
 
-void RenderableActor::SetBlendEquation( BlendingEquation::Type equationRgba )
+void RenderableActor::SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter )
 {
-  GetImplementation(*this).SetBlendEquation( equationRgba );
+  GetImplementation(*this).SetFilterMode( minFilter, magFilter );
 }
 
-void RenderableActor::SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha )
+void RenderableActor::GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const
 {
-  GetImplementation(*this).SetBlendEquation( equationRgb, equationAlpha );
+  GetImplementation(*this).GetFilterMode( minFilter, magFilter );
 }
 
-void RenderableActor::GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const
+void RenderableActor::SetShaderEffect(ShaderEffect effect)
 {
-  GetImplementation(*this).GetBlendEquation( equationRgb, equationAlpha );
+  GetImplementation(*this).SetShaderEffect(GetImplementation(effect));
 }
 
-void RenderableActor::SetBlendColor( const Vector4& color )
+ShaderEffect RenderableActor::GetShaderEffect() const
 {
-  GetImplementation(*this).SetBlendColor( color );
+  Internal::ShaderEffectPtr internal = GetImplementation(*this).GetShaderEffect();
+
+  return ShaderEffect(internal.Get());
 }
 
-const Vector4& RenderableActor::GetBlendColor() const
+void RenderableActor::RemoveShaderEffect()
 {
-  return GetImplementation(*this).GetBlendColor();
+  GetImplementation(*this).RemoveShaderEffect();
 }
 
 RenderableActor::RenderableActor(Internal::RenderableActor* internal)
@@ -116,4 +125,46 @@ RenderableActor::RenderableActor(Internal::RenderableActor* internal)
 {
 }
 
+void SetShaderEffectRecursively( Actor actor, ShaderEffect effect )
+{
+  // only do something if the actor and effect are valid
+  if( actor && effect )
+  {
+    // first remove from this actor
+    RenderableActor renderable = RenderableActor::DownCast( actor );
+    if( renderable )
+    {
+      renderable.SetShaderEffect( effect );
+    }
+    // then all children recursively
+    const unsigned int count = actor.GetChildCount();
+    for( unsigned int index = 0; index < count; ++index )
+    {
+      Actor child( actor.GetChildAt( index ) );
+      SetShaderEffectRecursively( child, effect );
+    }
+  }
+}
+
+void RemoveShaderEffectRecursively( Actor actor )
+{
+  // only do something if the actor is valid
+  if( actor )
+  {
+    // first remove from this actor
+    RenderableActor renderable = RenderableActor::DownCast( actor );
+    if( renderable )
+    {
+      renderable.RemoveShaderEffect();
+    }
+    // then all children recursively
+    const unsigned int count = actor.GetChildCount();
+    for( unsigned int index = 0; index < count; ++index )
+    {
+      Actor child( actor.GetChildAt( index ) );
+      RemoveShaderEffectRecursively( child );
+    }
+  }
+}
+
 } // namespace Dali