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>
28 #include <dali/public-api/object/property-map.h>
31 #include <dali-toolkit/devel-api/controls/shadow-view/shadow-view.h>
32 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
33 #include <dali-toolkit/public-api/controls/control-impl.h>
34 #include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
48 * ShadowView implementation class
50 class ShadowView : public Control
55 * @copydoc Dali::Toolkit::ShadowView::ShadowView
60 * @copydoc Dali::Toolkit::ShadowView::ShadowView
62 ShadowView(float downsampleWidthScale, float downsampleHeightScale);
65 * @copydoc Dali::Toolkit::ShadowView::~ShadowView
67 virtual ~ShadowView();
70 * @copydoc Dali::Toolkit::ShadowView::New(float downsampleWidthScale, float downsampleHeightScale)
72 static Dali::Toolkit::ShadowView New(float downsampleWidthScale, float downsampleHeightScale);
75 * @copydoc Dali::Toolkit::ShadowView::SetShadowPlaneBackground(Actor shadowPlaneBackground)
77 void SetShadowPlaneBackground(Actor shadowPlaneBackground);
80 * @copydoc Dali::Toolkit::ShadowView::SetPointLight(Actor pointLight)
82 void SetPointLight(Actor pointLight);
85 * @copydoc Dali::Toolkit::ShadowView::SetPointLightFieldOfView(float fieldOfView)
87 void SetPointLightFieldOfView(float fieldOfView);
90 * @copydoc Dali::Toolkit::ShadowView::SetShadowColor(Vector4 color)
92 void SetShadowColor(Vector4 color);
95 * @copydoc Dali::Toolkit::ShadowView::Activate()
100 * @copydoc Dali::Toolkit::ShadowView::Deactivate()
105 * @copydoc Dali::Toolkit::ShadowView::GetBlurStrengthPropertyIndex()
107 Property::Index GetBlurStrengthPropertyIndex() const {return mBlurStrengthPropertyIndex;}
110 * @copydoc Dali::Toolkit::ShadowView::GetShadowColorPropertyIndex()
112 Property::Index GetShadowColorPropertyIndex() const {return mShadowColorPropertyIndex;}
114 void SetShaderConstants();
118 virtual void OnInitialize();
121 * @copydoc Control::OnChildAdd()
123 virtual void OnChildAdd( Actor& child );
126 * @copydoc Control::OnChildRemove()
128 virtual void OnChildRemove( Actor& child );
131 * Constrain the camera actor to the position of the point light, pointing
132 * at the center of the shadow plane.
134 void ConstrainCamera();
136 void CreateRenderTasks();
137 void RemoveRenderTasks();
138 void CreateBlurFilter();
141 Toolkit::ImageView mShadowPlane; // Shadow renders into this actor
142 Actor mShadowPlaneBg; // mShadowPlane renders directly in front of this actor
143 Actor mPointLight; // Shadow is cast from this point light
145 /////////////////////////////////////////////////////////////
146 FrameBufferImage mSceneFromLightRenderTarget; // for rendering normal scene seen from light to texture instead of the screen
148 FrameBufferImage mOutputImage;
150 Actor mChildrenRoot; // Subtree for all user added child actors that should be rendered normally
151 Actor mBlurRootActor; // Root actor for blur filter processing
152 RenderTask mRenderSceneTask;
154 CameraActor mCameraActor; // Constrained to same position as mPointLight and pointing at mShadowPlane
156 Property::Map mShadowRenderShader;
157 BlurTwoPassFilter mBlurFilter;
159 Vector4 mCachedShadowColor; ///< Cached Shadow color.
160 Vector4 mCachedBackgroundColor; ///< Cached Shadow background color (same as shadow color but with alpha at 0.0)
162 /////////////////////////////////////////////////////////////
163 // Properties that can be animated
164 Property::Index mBlurStrengthPropertyIndex;
165 Property::Index mShadowColorPropertyIndex;
166 float mDownsampleWidthScale;
167 float mDownsampleHeightScale;
171 // Undefined copy constructor.
172 ShadowView( const ShadowView& );
174 // Undefined assignment operator.
175 ShadowView& operator=( const ShadowView& );
178 } // namespace Internal
181 // Helpers for public-api forwarding methods
182 inline Toolkit::Internal::ShadowView& GetImpl( Toolkit::ShadowView& obj )
184 DALI_ASSERT_ALWAYS(obj);
185 Dali::RefObject& handle = obj.GetImplementation();
186 return static_cast<Toolkit::Internal::ShadowView&>(handle);
189 inline const Toolkit::Internal::ShadowView& GetImpl( const Toolkit::ShadowView& obj )
191 DALI_ASSERT_ALWAYS(obj);
192 const Dali::RefObject& handle = obj.GetImplementation();
193 return static_cast<const Toolkit::Internal::ShadowView&>(handle);
197 } // namespace Toolkit
201 #endif // __DALI_TOOLKIT_INTERNAL_SHADOW_VIEW_H__