2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/public-api/actors/renderable-actor.h>
22 #include <dali/internal/event/actors/renderable-actor-impl.h>
23 #include <dali/internal/event/effects/shader-effect-impl.h>
28 const BlendingMode::Type RenderableActor::DEFAULT_BLENDING_MODE = BlendingMode::AUTO;
30 RenderableActor::RenderableActor()
34 RenderableActor RenderableActor::DownCast( BaseHandle handle )
36 return RenderableActor( dynamic_cast<Dali::Internal::RenderableActor*>(handle.GetObjectPtr()) );
39 RenderableActor::~RenderableActor()
43 RenderableActor::RenderableActor(const RenderableActor& copy)
48 RenderableActor& RenderableActor::operator=(const RenderableActor& rhs)
50 BaseHandle::operator=(rhs);
54 RenderableActor& RenderableActor::operator=(BaseHandle::NullType* rhs)
56 DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
61 void RenderableActor::SetSortModifier(float modifier)
63 GetImplementation(*this).SetSortModifier(modifier);
66 float RenderableActor::GetSortModifier() const
68 return GetImplementation(*this).GetSortModifier();
71 void RenderableActor::SetCullFace(const CullFaceMode mode)
73 GetImplementation(*this).SetCullFace(mode);
76 CullFaceMode RenderableActor::GetCullFace() const
78 return GetImplementation(*this).GetCullFace();
81 void RenderableActor::SetBlendMode( BlendingMode::Type mode )
83 GetImplementation(*this).SetBlendMode( mode );
86 BlendingMode::Type RenderableActor::GetBlendMode() const
88 return GetImplementation(*this).GetBlendMode();
91 void RenderableActor::SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba )
93 GetImplementation(*this).SetBlendFunc( srcFactorRgba, destFactorRgba );
96 void RenderableActor::SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb,
97 BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha )
99 GetImplementation(*this).SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
102 void RenderableActor::GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
103 BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const
105 GetImplementation(*this).GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
108 void RenderableActor::SetBlendEquation( BlendingEquation::Type equationRgba )
110 GetImplementation(*this).SetBlendEquation( equationRgba );
113 void RenderableActor::SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha )
115 GetImplementation(*this).SetBlendEquation( equationRgb, equationAlpha );
118 void RenderableActor::GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const
120 GetImplementation(*this).GetBlendEquation( equationRgb, equationAlpha );
123 void RenderableActor::SetBlendColor( const Vector4& color )
125 GetImplementation(*this).SetBlendColor( color );
128 const Vector4& RenderableActor::GetBlendColor() const
130 return GetImplementation(*this).GetBlendColor();
133 void RenderableActor::SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter )
135 GetImplementation(*this).SetFilterMode( minFilter, magFilter );
138 void RenderableActor::GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const
140 GetImplementation(*this).GetFilterMode( minFilter, magFilter );
143 void RenderableActor::SetShaderEffect(ShaderEffect effect)
145 GetImplementation(*this).SetShaderEffect(GetImplementation(effect));
148 ShaderEffect RenderableActor::GetShaderEffect() const
150 Internal::ShaderEffectPtr internal = GetImplementation(*this).GetShaderEffect();
152 return ShaderEffect(internal.Get());
155 void RenderableActor::RemoveShaderEffect()
157 GetImplementation(*this).RemoveShaderEffect();
160 RenderableActor::RenderableActor(Internal::RenderableActor* internal)
165 void SetShaderEffectRecursively( Actor actor, ShaderEffect effect )
167 // only do something if the actor and effect are valid
168 if( actor && effect )
170 // first remove from this actor
171 RenderableActor renderable = RenderableActor::DownCast( actor );
174 renderable.SetShaderEffect( effect );
176 // then all children recursively
177 const unsigned int count = actor.GetChildCount();
178 for( unsigned int index = 0; index < count; ++index )
180 Actor child( actor.GetChildAt( index ) );
181 SetShaderEffectRecursively( child, effect );
186 void RemoveShaderEffectRecursively( Actor actor )
188 // only do something if the actor is valid
191 // first remove from this actor
192 RenderableActor renderable = RenderableActor::DownCast( actor );
195 renderable.RemoveShaderEffect();
197 // then all children recursively
198 const unsigned int count = actor.GetChildCount();
199 for( unsigned int index = 0; index < count; ++index )
201 Actor child( actor.GetChildAt( index ) );
202 RemoveShaderEffectRecursively( child );