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.
26 #include <dali/dali.h>
27 #include <dali-toolkit/public-api/controls/shadow-view/shadow-view.h>
28 #include <dali-toolkit/public-api/controls/control-impl.h>
29 #include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
43 * ShadowView implementation class
45 class ShadowView : public Control
50 * @copydoc Dali::Toolkit::ShadowView::ShadowView
55 * @copydoc Dali::Toolkit::ShadowView::ShadowView
57 ShadowView(float downsampleWidthScale, float downsampleHeightScale);
60 * @copydoc Dali::Toolkit::ShadowView::~ShadowView
62 virtual ~ShadowView();
65 * @copydoc Dali::Toolkit::ShadowView::New(float downsampleWidthScale, float downsampleHeightScale)
67 static Dali::Toolkit::ShadowView New(float downsampleWidthScale, float downsampleHeightScale);
70 * @copydoc Dali::Toolkit::ShadowView::Add(Actor child)
72 void Add(Actor child);
75 * @copydoc Dali::Toolkit::ShadowView::Remove(Actor child)
77 void Remove(Actor child);
80 * @copydoc Dali::Toolkit::ShadowView::SetShadowPlane(Actor shadowPlane)
82 void SetShadowPlane(Actor shadowPlane);
85 * @copydoc Dali::Toolkit::ShadowView::SetPointLight(Actor pointLight)
87 void SetPointLight(Actor pointLight);
90 * @copydoc Dali::Toolkit::ShadowView::SetPointLightFieldOfView(float fieldOfView)
92 void SetPointLightFieldOfView(float fieldOfView);
95 * @copydoc Dali::Toolkit::ShadowView::SetShadowColor(Vector4 color)
97 void SetShadowColor(Vector4 color);
100 * @copydoc Dali::Toolkit::ShadowView::Activate()
105 * @copydoc Dali::Toolkit::ShadowView::Deactivate()
110 * @copydoc Dali::Toolkit::ShadowView::GetBlurStrengthPropertyIndex()
112 Property::Index GetBlurStrengthPropertyIndex() const {return mBlurStrengthPropertyIndex;}
115 * @copydoc Dali::Toolkit::ShadowView::GetShadowColorPropertyIndex()
117 Property::Index GetShadowColorPropertyIndex() const {return mShadowColorPropertyIndex;}
119 void SetShaderConstants();
123 virtual void OnInitialize();
124 virtual void OnSizeSet(const Vector3& targetSize);
125 virtual void OnStageConnection();
126 virtual void OnStageDisconnection();
129 * Constrain the camera actor to the position of the point light, pointing
130 * at the center of the shadow plane.
132 void ConstrainCamera();
134 void CreateRenderTasks();
135 void RemoveRenderTasks();
136 void CreateBlurFilter();
139 ImageActor mShadowPlane; // Shadow renders into this actor
140 Actor mShadowPlaneBg; // mShadowPlane renders directly in front of this actor
141 Actor mPointLight; // Shadow is cast from this point light
143 /////////////////////////////////////////////////////////////
144 FrameBufferImage mSceneFromLightRenderTarget; // for rendering normal scene seen from light to texture instead of the screen
146 FrameBufferImage mOutputImage;
148 Actor mChildrenRoot; // Subtree for all user added child actors that should be rendered normally
149 Actor mBlurRootActor; // Root actor for blur filter processing
150 ImageActor mShadowPlaneDrawable; // Positioned on top of mShadowPlane for drawing shadow image
151 RenderTask mRenderSceneTask;
153 CameraActor mCameraActor; // Constrained to same position as mPointLight and pointing at mShadowPlane
155 ShaderEffect mShadowRenderShader;
156 BlurTwoPassFilter mBlurFilter;
158 Vector4 mCachedShadowColor; ///< Cached Shadow color.
159 Vector4 mCachedBackgroundColor; ///< Cached Shadow background color (same as shadow color but with alpha at 0.0)
161 /////////////////////////////////////////////////////////////
162 // Properties that can be animated
163 Property::Index mBlurStrengthPropertyIndex;
164 Property::Index mShadowColorPropertyIndex;
165 float mDownsampleWidthScale;
166 float mDownsampleHeightScale;
170 // Undefined copy constructor.
171 ShadowView( const ShadowView& );
173 // Undefined assignment operator.
174 ShadowView& operator=( const ShadowView& );
177 } // namespace Internal
180 // Helpers for public-api forwarding methods
181 inline Toolkit::Internal::ShadowView& GetImpl( Toolkit::ShadowView& obj )
183 DALI_ASSERT_ALWAYS(obj);
184 Dali::RefObject& handle = obj.GetImplementation();
185 return static_cast<Toolkit::Internal::ShadowView&>(handle);
188 inline const Toolkit::Internal::ShadowView& GetImpl( const Toolkit::ShadowView& obj )
190 DALI_ASSERT_ALWAYS(obj);
191 const Dali::RefObject& handle = obj.GetImplementation();
192 return static_cast<const Toolkit::Internal::ShadowView&>(handle);
196 } // namespace Toolkit
200 #endif // __DALI_TOOLKIT_INTERNAL_SHADOW_VIEW_H__