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 void RenderableActor::SetSortModifier(float modifier)
56 GetImplementation(*this).SetSortModifier(modifier);
59 float RenderableActor::GetSortModifier() const
61 return GetImplementation(*this).GetSortModifier();
64 void RenderableActor::SetCullFace(const CullFaceMode mode)
66 GetImplementation(*this).SetCullFace(mode);
69 CullFaceMode RenderableActor::GetCullFace() const
71 return GetImplementation(*this).GetCullFace();
74 void RenderableActor::SetBlendMode( BlendingMode::Type mode )
76 GetImplementation(*this).SetBlendMode( mode );
79 BlendingMode::Type RenderableActor::GetBlendMode() const
81 return GetImplementation(*this).GetBlendMode();
84 void RenderableActor::SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba )
86 GetImplementation(*this).SetBlendFunc( srcFactorRgba, destFactorRgba );
89 void RenderableActor::SetBlendFunc( BlendingFactor::Type srcFactorRgb, BlendingFactor::Type destFactorRgb,
90 BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha )
92 GetImplementation(*this).SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
95 void RenderableActor::GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
96 BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const
98 GetImplementation(*this).GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
101 void RenderableActor::SetBlendEquation( BlendingEquation::Type equationRgba )
103 GetImplementation(*this).SetBlendEquation( equationRgba );
106 void RenderableActor::SetBlendEquation( BlendingEquation::Type equationRgb, BlendingEquation::Type equationAlpha )
108 GetImplementation(*this).SetBlendEquation( equationRgb, equationAlpha );
111 void RenderableActor::GetBlendEquation( BlendingEquation::Type& equationRgb, BlendingEquation::Type& equationAlpha ) const
113 GetImplementation(*this).GetBlendEquation( equationRgb, equationAlpha );
116 void RenderableActor::SetBlendColor( const Vector4& color )
118 GetImplementation(*this).SetBlendColor( color );
121 const Vector4& RenderableActor::GetBlendColor() const
123 return GetImplementation(*this).GetBlendColor();
126 void RenderableActor::SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter )
128 GetImplementation(*this).SetFilterMode( minFilter, magFilter );
131 void RenderableActor::GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const
133 GetImplementation(*this).GetFilterMode( minFilter, magFilter );
136 void RenderableActor::SetShaderEffect(ShaderEffect effect)
138 GetImplementation(*this).SetShaderEffect(GetImplementation(effect));
141 ShaderEffect RenderableActor::GetShaderEffect() const
143 Internal::ShaderEffectPtr internal = GetImplementation(*this).GetShaderEffect();
145 return ShaderEffect(internal.Get());
148 void RenderableActor::RemoveShaderEffect()
150 GetImplementation(*this).RemoveShaderEffect();
153 RenderableActor::RenderableActor(Internal::RenderableActor* internal)
158 void SetShaderEffectRecursively( Actor actor, ShaderEffect effect )
160 // only do something if the actor and effect are valid
161 if( actor && effect )
163 // first remove from this actor
164 RenderableActor renderable = RenderableActor::DownCast( actor );
167 renderable.SetShaderEffect( effect );
169 // then all children recursively
170 const unsigned int count = actor.GetChildCount();
171 for( unsigned int index = 0; index < count; ++index )
173 Actor child( actor.GetChildAt( index ) );
174 SetShaderEffectRecursively( child, effect );
179 void RemoveShaderEffectRecursively( Actor actor )
181 // only do something if the actor is valid
184 // first remove from this actor
185 RenderableActor renderable = RenderableActor::DownCast( actor );
188 renderable.RemoveShaderEffect();
190 // then all children recursively
191 const unsigned int count = actor.GetChildCount();
192 for( unsigned int index = 0; index < count; ++index )
194 Actor child( actor.GetChildAt( index ) );
195 RemoveShaderEffectRecursively( child );