Fix compile error. Non initialized variable.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / shadow-view / shadow-view-impl.h
1 #ifndef DALI_TOOLKIT_INTERNAL_SHADOW_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_SHADOW_VIEW_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <sstream>
23 #include <cmath>
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>
28
29 // INTERNAL INCLUDES
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>
34
35 namespace Dali
36 {
37
38 namespace Toolkit
39 {
40
41 class ShadowView;
42
43 namespace Internal
44 {
45
46 /**
47  * ShadowView implementation class
48  */
49 class ShadowView : public Control
50 {
51 public:
52
53   /**
54    * @copydoc Dali::Toolkit::ShadowView::ShadowView
55    */
56   ShadowView();
57
58   /**
59    * @copydoc Dali::Toolkit::ShadowView::ShadowView
60    */
61   ShadowView(float downsampleWidthScale, float downsampleHeightScale);
62
63   /**
64    * @copydoc Dali::Toolkit::ShadowView::~ShadowView
65    */
66   virtual ~ShadowView();
67
68   /**
69    * @copydoc Dali::Toolkit::ShadowView::New(float downsampleWidthScale, float downsampleHeightScale)
70    */
71   static Dali::Toolkit::ShadowView New(float downsampleWidthScale, float downsampleHeightScale);
72
73   /**
74    * @copydoc Dali::Toolkit::ShadowView::SetShadowPlaneBackground(Actor shadowPlaneBackground)
75    */
76   void SetShadowPlaneBackground(Actor shadowPlaneBackground);
77
78   /**
79    * @copydoc Dali::Toolkit::ShadowView::SetPointLight(Actor pointLight)
80    */
81   void SetPointLight(Actor pointLight);
82
83   /**
84    * @copydoc Dali::Toolkit::ShadowView::SetPointLightFieldOfView(float fieldOfView)
85    */
86   void SetPointLightFieldOfView(float fieldOfView);
87
88   /**
89    * @copydoc Dali::Toolkit::ShadowView::SetShadowColor(Vector4 color)
90    */
91   void SetShadowColor(Vector4 color);
92
93   /**
94    * @copydoc Dali::Toolkit::ShadowView::Activate()
95    */
96   void Activate();
97
98   /**
99    * @copydoc Dali::Toolkit::ShadowView::Deactivate()
100    */
101   void Deactivate();
102
103   /**
104    * @copydoc Dali::Toolkit::ShadowView::GetBlurStrengthPropertyIndex()
105    */
106   Property::Index GetBlurStrengthPropertyIndex() const {return mBlurStrengthPropertyIndex;}
107
108   /**
109    * @copydoc Dali::Toolkit::ShadowView::GetShadowColorPropertyIndex()
110    */
111   Property::Index GetShadowColorPropertyIndex() const {return mShadowColorPropertyIndex;}
112
113   void SetShaderConstants();
114
115 private:
116
117   virtual void OnInitialize();
118
119   /**
120    * @copydoc Control::OnChildAdd()
121    */
122   virtual void OnChildAdd( Actor& child );
123
124   /**
125    * @copydoc Control::OnChildRemove()
126    */
127   virtual void OnChildRemove( Actor& child );
128
129   /**
130    * Constrain the camera actor to the position of the point light, pointing
131    * at the center of the shadow plane.
132    */
133   void ConstrainCamera();
134
135   void CreateRenderTasks();
136   void RemoveRenderTasks();
137   void CreateBlurFilter();
138
139 private:
140   Actor 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
143
144   /////////////////////////////////////////////////////////////
145   FrameBuffer mSceneFromLightRenderTarget;  // for rendering normal scene seen from light to texture instead of the screen
146
147   FrameBuffer mOutputFrameBuffer;
148
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;
152
153   CameraActor mCameraActor; // Constrained to same position as mPointLight and pointing at mShadowPlane
154
155   Property::Map mShadowVisualMap;
156   BlurTwoPassFilter mBlurFilter;
157
158   Vector4 mCachedShadowColor;                               ///< Cached Shadow color.
159   Vector4 mCachedBackgroundColor;                           ///< Cached Shadow background color (same as shadow color but with alpha at 0.0)
160
161   /////////////////////////////////////////////////////////////
162   // Properties that can be animated
163   Property::Index mBlurStrengthPropertyIndex;
164   Property::Index mShadowColorPropertyIndex;
165   float mDownsampleWidthScale;
166   float mDownsampleHeightScale;
167
168 private:
169
170   // Undefined copy constructor.
171   ShadowView( const ShadowView& );
172
173   // Undefined assignment operator.
174   ShadowView& operator=( const ShadowView& );
175 };
176
177 } // namespace Internal
178
179
180 // Helpers for public-api forwarding methods
181 inline Toolkit::Internal::ShadowView& GetImpl( Toolkit::ShadowView& obj )
182 {
183   DALI_ASSERT_ALWAYS(obj);
184   Dali::RefObject& handle = obj.GetImplementation();
185   return static_cast<Toolkit::Internal::ShadowView&>(handle);
186 }
187
188 inline const Toolkit::Internal::ShadowView& GetImpl( const Toolkit::ShadowView& obj )
189 {
190   DALI_ASSERT_ALWAYS(obj);
191   const Dali::RefObject& handle = obj.GetImplementation();
192   return static_cast<const Toolkit::Internal::ShadowView&>(handle);
193 }
194
195
196 } // namespace Toolkit
197
198 } // namespace Dali
199
200 #endif // DALI_TOOLKIT_INTERNAL_SHADOW_VIEW_H