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 Flora License, Version 1.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://floralicense.org/license/
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.
25 #include <dali/dali.h>
26 #include <dali-toolkit/public-api/controls/shadow-view/shadow-view.h>
27 #include <dali-toolkit/public-api/controls/control-impl.h>
28 #include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
42 * ShadowView implementation class
44 class ShadowView : public Control
49 * @copydoc Dali::Toolkit::ShadowView::ShadowView
54 * @copydoc Dali::Toolkit::ShadowView::ShadowView
56 ShadowView(float downsampleWidthScale, float downsampleHeightScale);
59 * @copydoc Dali::Toolkit::ShadowView::~ShadowView
61 virtual ~ShadowView();
64 * @copydoc Dali::Toolkit::ShadowView::New(float downsampleWidthScale, float downsampleHeightScale)
66 static Dali::Toolkit::ShadowView New(float downsampleWidthScale, float downsampleHeightScale);
69 * @copydoc Dali::Toolkit::ShadowView::Add(Actor child)
71 void Add(Actor child);
74 * @copydoc Dali::Toolkit::ShadowView::Remove(Actor child)
76 void Remove(Actor child);
79 * @copydoc Dali::Toolkit::ShadowView::SetShadowPlane(Actor shadowPlane)
81 void SetShadowPlane(Actor shadowPlane);
84 * @copydoc Dali::Toolkit::ShadowView::SetPointLight(Actor pointLight)
86 void SetPointLight(Actor pointLight);
89 * @copydoc Dali::Toolkit::ShadowView::SetPointLightFieldOfView(float fieldOfView)
91 void SetPointLightFieldOfView(float fieldOfView);
94 * @copydoc Dali::Toolkit::ShadowView::SetShadowColor(Vector4 color)
96 void SetShadowColor(Vector4 color);
99 * @copydoc Dali::Toolkit::ShadowView::Activate()
104 * @copydoc Dali::Toolkit::ShadowView::Deactivate()
109 * @copydoc Dali::Toolkit::ShadowView::GetBlurStrengthPropertyIndex()
111 Property::Index GetBlurStrengthPropertyIndex() const {return mBlurStrengthPropertyIndex;}
114 * @copydoc Dali::Toolkit::ShadowView::GetShadowColorPropertyIndex()
116 Property::Index GetShadowColorPropertyIndex() const {return mShadowColorPropertyIndex;}
118 void SetShaderConstants();
122 virtual void OnInitialize();
123 virtual void OnSizeSet(const Vector3& targetSize);
124 virtual void OnStageConnection();
125 virtual void OnStageDisconnection();
128 * Constrain the camera actor to the position of the point light, pointing
129 * at the center of the shadow plane.
131 void ConstrainCamera();
133 void CreateRenderTasks();
134 void RemoveRenderTasks();
135 void CreateBlurFilter();
138 ImageActor mShadowPlane; // Shadow renders into this actor
139 Actor mShadowPlaneBg; // mShadowPlane renders directly in front of this actor
140 Actor mPointLight; // Shadow is cast from this point light
142 /////////////////////////////////////////////////////////////
143 FrameBufferImage mSceneFromLightRenderTarget; // for rendering normal scene seen from light to texture instead of the screen
145 FrameBufferImage mOutputImage;
147 Actor mChildrenRoot; // Subtree for all user added child actors that should be rendered normally
148 Actor mBlurRootActor; // Root actor for blur filter processing
149 ImageActor mShadowPlaneDrawable; // Positioned on top of mShadowPlane for drawing shadow image
150 RenderTask mRenderSceneTask;
152 CameraActor mCameraActor; // Constrained to same position as mPointLight and pointing at mShadowPlane
154 ShaderEffect mShadowRenderShader;
155 BlurTwoPassFilter mBlurFilter;
157 Vector4 mCachedShadowColor; ///< Cached Shadow color.
158 Vector4 mCachedBackgroundColor; ///< Cached Shadow background color (same as shadow color but with alpha at 0.0)
160 /////////////////////////////////////////////////////////////
161 // Properties that can be animated
162 Property::Index mBlurStrengthPropertyIndex;
163 Property::Index mShadowColorPropertyIndex;
164 float mDownsampleWidthScale;
165 float mDownsampleHeightScale;
169 // Undefined copy constructor.
170 ShadowView( const ShadowView& );
172 // Undefined assignment operator.
173 ShadowView& operator=( const ShadowView& );
176 } // namespace Internal
179 // Helpers for public-api forwarding methods
180 inline Toolkit::Internal::ShadowView& GetImpl( Toolkit::ShadowView& obj )
182 DALI_ASSERT_ALWAYS(obj);
183 Dali::RefObject& handle = obj.GetImplementation();
184 return static_cast<Toolkit::Internal::ShadowView&>(handle);
187 inline const Toolkit::Internal::ShadowView& GetImpl( const Toolkit::ShadowView& obj )
189 DALI_ASSERT_ALWAYS(obj);
190 const Dali::RefObject& handle = obj.GetImplementation();
191 return static_cast<const Toolkit::Internal::ShadowView&>(handle);
195 } // namespace Toolkit
199 #endif // __DALI_TOOLKIT_INTERNAL_SHADOW_VIEW_H__