1 #ifndef __DALI_TOOLKIT_INTERNAL_SHADOW_VIEW_H__
2 #define __DALI_TOOLKIT_INTERNAL_SHADOW_VIEW_H__
5 * Copyright (c) 2016 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/object/property-map.h>
30 #include <dali-toolkit/devel-api/controls/shadow-view/shadow-view.h>
31 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
32 #include <dali-toolkit/public-api/controls/control-impl.h>
33 #include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
47 * ShadowView implementation class
49 class ShadowView : public Control
54 * @copydoc Dali::Toolkit::ShadowView::ShadowView
59 * @copydoc Dali::Toolkit::ShadowView::ShadowView
61 ShadowView(float downsampleWidthScale, float downsampleHeightScale);
64 * @copydoc Dali::Toolkit::ShadowView::~ShadowView
66 virtual ~ShadowView();
69 * @copydoc Dali::Toolkit::ShadowView::New(float downsampleWidthScale, float downsampleHeightScale)
71 static Dali::Toolkit::ShadowView New(float downsampleWidthScale, float downsampleHeightScale);
74 * @copydoc Dali::Toolkit::ShadowView::SetShadowPlaneBackground(Actor shadowPlaneBackground)
76 void SetShadowPlaneBackground(Actor shadowPlaneBackground);
79 * @copydoc Dali::Toolkit::ShadowView::SetPointLight(Actor pointLight)
81 void SetPointLight(Actor pointLight);
84 * @copydoc Dali::Toolkit::ShadowView::SetPointLightFieldOfView(float fieldOfView)
86 void SetPointLightFieldOfView(float fieldOfView);
89 * @copydoc Dali::Toolkit::ShadowView::SetShadowColor(Vector4 color)
91 void SetShadowColor(Vector4 color);
94 * @copydoc Dali::Toolkit::ShadowView::Activate()
99 * @copydoc Dali::Toolkit::ShadowView::Deactivate()
104 * @copydoc Dali::Toolkit::ShadowView::GetBlurStrengthPropertyIndex()
106 Property::Index GetBlurStrengthPropertyIndex() const {return mBlurStrengthPropertyIndex;}
109 * @copydoc Dali::Toolkit::ShadowView::GetShadowColorPropertyIndex()
111 Property::Index GetShadowColorPropertyIndex() const {return mShadowColorPropertyIndex;}
113 void SetShaderConstants();
117 virtual void OnInitialize();
120 * @copydoc Control::OnChildAdd()
122 virtual void OnChildAdd( Actor& child );
125 * @copydoc Control::OnChildRemove()
127 virtual void OnChildRemove( Actor& child );
130 * Constrain the camera actor to the position of the point light, pointing
131 * at the center of the shadow plane.
133 void ConstrainCamera();
135 void CreateRenderTasks();
136 void RemoveRenderTasks();
137 void CreateBlurFilter();
140 Toolkit::ImageView mShadowPlane; // Shadow renders into this actor
141 Actor mShadowPlaneBg; // mShadowPlane renders directly in front of this actor
142 Actor mPointLight; // Shadow is cast from this point light
144 /////////////////////////////////////////////////////////////
145 FrameBufferImage mSceneFromLightRenderTarget; // for rendering normal scene seen from light to texture instead of the screen
147 FrameBufferImage mOutputImage;
149 Actor mChildrenRoot; // Subtree for all user added child actors that should be rendered normally
150 Actor mBlurRootActor; // Root actor for blur filter processing
151 RenderTask mRenderSceneTask;
153 CameraActor mCameraActor; // Constrained to same position as mPointLight and pointing at mShadowPlane
155 Property::Map mShadowVisualMap;
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__