2 * Copyright (c) 2015 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 srcFactorRgb, BlendingFactor::Type destFactorRgb,
85 BlendingFactor::Type srcFactorAlpha, BlendingFactor::Type destFactorAlpha )
87 GetImplementation(*this).SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
90 void RenderableActor::GetBlendFunc( BlendingFactor::Type& srcFactorRgb, BlendingFactor::Type& destFactorRgb,
91 BlendingFactor::Type& srcFactorAlpha, BlendingFactor::Type& destFactorAlpha ) const
93 GetImplementation(*this).GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
96 void RenderableActor::SetFilterMode( FilterMode::Type minFilter, FilterMode::Type magFilter )
98 GetImplementation(*this).SetFilterMode( minFilter, magFilter );
101 void RenderableActor::GetFilterMode( FilterMode::Type& minFilter, FilterMode::Type& magFilter ) const
103 GetImplementation(*this).GetFilterMode( minFilter, magFilter );
106 void RenderableActor::SetShaderEffect(ShaderEffect effect)
108 GetImplementation(*this).SetShaderEffect(GetImplementation(effect));
111 ShaderEffect RenderableActor::GetShaderEffect() const
113 Internal::ShaderEffectPtr internal = GetImplementation(*this).GetShaderEffect();
115 return ShaderEffect(internal.Get());
118 void RenderableActor::RemoveShaderEffect()
120 GetImplementation(*this).RemoveShaderEffect();
123 RenderableActor::RenderableActor(Internal::RenderableActor* internal)
128 void SetShaderEffectRecursively( Actor actor, ShaderEffect effect )
130 // only do something if the actor and effect are valid
131 if( actor && effect )
133 // first remove from this actor
134 RenderableActor renderable = RenderableActor::DownCast( actor );
137 renderable.SetShaderEffect( effect );
139 // then all children recursively
140 const unsigned int count = actor.GetChildCount();
141 for( unsigned int index = 0; index < count; ++index )
143 Actor child( actor.GetChildAt( index ) );
144 SetShaderEffectRecursively( child, effect );
149 void RemoveShaderEffectRecursively( Actor actor )
151 // only do something if the actor is valid
154 // first remove from this actor
155 RenderableActor renderable = RenderableActor::DownCast( actor );
158 renderable.RemoveShaderEffect();
160 // then all children recursively
161 const unsigned int count = actor.GetChildCount();
162 for( unsigned int index = 0; index < count; ++index )
164 Actor child( actor.GetChildAt( index ) );
165 RemoveShaderEffectRecursively( child );