Reduce ImageActor & RenderableActor APIs
[platform/core/uifw/dali-core.git] / dali / public-api / actors / renderable-actor.cpp
index 96bdc9e..5dec5b4 100644 (file)
@@ -1,24 +1,26 @@
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 // CLASS HEADER
 #include <dali/public-api/actors/renderable-actor.h>
 
 // INTERNAL INCLUDES
 #include <dali/internal/event/actors/renderable-actor-impl.h>
+#include <dali/internal/event/effects/shader-effect-impl.h>
 
 namespace Dali
 {
@@ -38,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);
@@ -68,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 )
 {
@@ -85,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)
@@ -115,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