1 #ifndef __DALI_TOOLKIT_INTERNAL_SHADOW_VIEW_H__
2 #define __DALI_TOOLKIT_INTERNAL_SHADOW_VIEW_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
24 #include <dali/public-api/actors/camera-actor.h>
25 #include <dali/public-api/animation/constraints.h>
26 #include <dali/public-api/render-tasks/render-task.h>
27 #include <dali/public-api/shader-effects/shader-effect.h>
30 #include <dali-toolkit/public-api/controls/shadow-view/shadow-view.h>
31 #include <dali-toolkit/public-api/controls/control-impl.h>
32 #include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
46 * ShadowView implementation class
48 class ShadowView : public Control
53 * @copydoc Dali::Toolkit::ShadowView::ShadowView
58 * @copydoc Dali::Toolkit::ShadowView::ShadowView
60 ShadowView(float downsampleWidthScale, float downsampleHeightScale);
63 * @copydoc Dali::Toolkit::ShadowView::~ShadowView
65 virtual ~ShadowView();
68 * @copydoc Dali::Toolkit::ShadowView::New(float downsampleWidthScale, float downsampleHeightScale)
70 static Dali::Toolkit::ShadowView New(float downsampleWidthScale, float downsampleHeightScale);
73 * @copydoc Dali::Toolkit::ShadowView::Add(Actor child)
75 void Add(Actor child);
78 * @copydoc Dali::Toolkit::ShadowView::Remove(Actor child)
80 void Remove(Actor child);
83 * @copydoc Dali::Toolkit::ShadowView::SetShadowPlane(Actor shadowPlane)
85 void SetShadowPlane(Actor shadowPlane);
88 * @copydoc Dali::Toolkit::ShadowView::SetPointLight(Actor pointLight)
90 void SetPointLight(Actor pointLight);
93 * @copydoc Dali::Toolkit::ShadowView::SetPointLightFieldOfView(float fieldOfView)
95 void SetPointLightFieldOfView(float fieldOfView);
98 * @copydoc Dali::Toolkit::ShadowView::SetShadowColor(Vector4 color)
100 void SetShadowColor(Vector4 color);
103 * @copydoc Dali::Toolkit::ShadowView::Activate()
108 * @copydoc Dali::Toolkit::ShadowView::Deactivate()
113 * @copydoc Dali::Toolkit::ShadowView::GetBlurStrengthPropertyIndex()
115 Property::Index GetBlurStrengthPropertyIndex() const {return mBlurStrengthPropertyIndex;}
118 * @copydoc Dali::Toolkit::ShadowView::GetShadowColorPropertyIndex()
120 Property::Index GetShadowColorPropertyIndex() const {return mShadowColorPropertyIndex;}
122 void SetShaderConstants();
126 virtual void OnInitialize();
127 virtual void OnSizeSet(const Vector3& targetSize);
128 virtual void OnStageConnection();
129 virtual void OnStageDisconnection();
132 * Constrain the camera actor to the position of the point light, pointing
133 * at the center of the shadow plane.
135 void ConstrainCamera();
137 void CreateRenderTasks();
138 void RemoveRenderTasks();
139 void CreateBlurFilter();
142 ImageActor mShadowPlane; // Shadow renders into this actor
143 Actor mShadowPlaneBg; // mShadowPlane renders directly in front of this actor
144 Actor mPointLight; // Shadow is cast from this point light
146 /////////////////////////////////////////////////////////////
147 FrameBufferImage mSceneFromLightRenderTarget; // for rendering normal scene seen from light to texture instead of the screen
149 FrameBufferImage mOutputImage;
151 Actor mChildrenRoot; // Subtree for all user added child actors that should be rendered normally
152 Actor mBlurRootActor; // Root actor for blur filter processing
153 ImageActor mShadowPlaneDrawable; // Positioned on top of mShadowPlane for drawing shadow image
154 RenderTask mRenderSceneTask;
156 CameraActor mCameraActor; // Constrained to same position as mPointLight and pointing at mShadowPlane
158 ShaderEffect mShadowRenderShader;
159 BlurTwoPassFilter mBlurFilter;
161 Vector4 mCachedShadowColor; ///< Cached Shadow color.
162 Vector4 mCachedBackgroundColor; ///< Cached Shadow background color (same as shadow color but with alpha at 0.0)
164 /////////////////////////////////////////////////////////////
165 // Properties that can be animated
166 Property::Index mBlurStrengthPropertyIndex;
167 Property::Index mShadowColorPropertyIndex;
168 float mDownsampleWidthScale;
169 float mDownsampleHeightScale;
173 // Undefined copy constructor.
174 ShadowView( const ShadowView& );
176 // Undefined assignment operator.
177 ShadowView& operator=( const ShadowView& );
180 } // namespace Internal
183 // Helpers for public-api forwarding methods
184 inline Toolkit::Internal::ShadowView& GetImpl( Toolkit::ShadowView& obj )
186 DALI_ASSERT_ALWAYS(obj);
187 Dali::RefObject& handle = obj.GetImplementation();
188 return static_cast<Toolkit::Internal::ShadowView&>(handle);
191 inline const Toolkit::Internal::ShadowView& GetImpl( const Toolkit::ShadowView& obj )
193 DALI_ASSERT_ALWAYS(obj);
194 const Dali::RefObject& handle = obj.GetImplementation();
195 return static_cast<const Toolkit::Internal::ShadowView&>(handle);
199 } // namespace Toolkit
203 #endif // __DALI_TOOLKIT_INTERNAL_SHADOW_VIEW_H__