remove dead code from shadow view (OnStageConnection & OnStageDisconnection)
[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) 2014 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/shader-effects/shader-effect.h>
28
29 // INTERNAL INCLUDES
30 #include <dali-toolkit/devel-api/controls/shadow-view/shadow-view.h>
31 #include <dali-toolkit/public-api/controls/control-impl.h>
32 #include <dali-toolkit/internal/filters/blur-two-pass-filter.h>
33
34 namespace Dali
35 {
36
37 namespace Toolkit
38 {
39
40 class ShadowView;
41
42 namespace Internal
43 {
44
45 /**
46  * ShadowView implementation class
47  */
48 class ShadowView : public Control
49 {
50 public:
51
52   /**
53    * @copydoc Dali::Toolkit::ShadowView::ShadowView
54    */
55   ShadowView();
56
57   /**
58    * @copydoc Dali::Toolkit::ShadowView::ShadowView
59    */
60   ShadowView(float downsampleWidthScale, float downsampleHeightScale);
61
62   /**
63    * @copydoc Dali::Toolkit::ShadowView::~ShadowView
64    */
65   virtual ~ShadowView();
66
67   /**
68    * @copydoc Dali::Toolkit::ShadowView::New(float downsampleWidthScale, float downsampleHeightScale)
69    */
70   static Dali::Toolkit::ShadowView New(float downsampleWidthScale, float downsampleHeightScale);
71
72   /**
73    * @copydoc Dali::Toolkit::ShadowView::Add(Actor child)
74    */
75   void Add(Actor child);
76
77   /**
78    * @copydoc Dali::Toolkit::ShadowView::Remove(Actor child)
79    */
80   void Remove(Actor child);
81
82   /**
83    * @copydoc Dali::Toolkit::ShadowView::SetShadowPlane(Actor shadowPlane)
84    */
85   void SetShadowPlane(Actor shadowPlane);
86
87   /**
88    * @copydoc Dali::Toolkit::ShadowView::SetPointLight(Actor pointLight)
89    */
90   void SetPointLight(Actor pointLight);
91
92   /**
93    * @copydoc Dali::Toolkit::ShadowView::SetPointLightFieldOfView(float fieldOfView)
94    */
95   void SetPointLightFieldOfView(float fieldOfView);
96
97   /**
98    * @copydoc Dali::Toolkit::ShadowView::SetShadowColor(Vector4 color)
99    */
100   void SetShadowColor(Vector4 color);
101
102   /**
103    * @copydoc Dali::Toolkit::ShadowView::Activate()
104    */
105   void Activate();
106
107   /**
108    * @copydoc Dali::Toolkit::ShadowView::Deactivate()
109    */
110   void Deactivate();
111
112   /**
113    * @copydoc Dali::Toolkit::ShadowView::GetBlurStrengthPropertyIndex()
114    */
115   Property::Index GetBlurStrengthPropertyIndex() const {return mBlurStrengthPropertyIndex;}
116
117   /**
118    * @copydoc Dali::Toolkit::ShadowView::GetShadowColorPropertyIndex()
119    */
120   Property::Index GetShadowColorPropertyIndex() const {return mShadowColorPropertyIndex;}
121
122   void SetShaderConstants();
123
124 private:
125
126   virtual void OnInitialize();
127   virtual void OnSizeSet(const Vector3& targetSize);
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   ImageActor 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   FrameBufferImage mSceneFromLightRenderTarget;  // for rendering normal scene seen from light to texture instead of the screen
146
147   FrameBufferImage mOutputImage;
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   ImageActor mShadowPlaneDrawable; // Positioned on top of mShadowPlane for drawing shadow image
152   RenderTask mRenderSceneTask;
153
154   CameraActor mCameraActor; // Constrained to same position as mPointLight and pointing at mShadowPlane
155
156   ShaderEffect mShadowRenderShader;
157   BlurTwoPassFilter mBlurFilter;
158
159   Vector4 mCachedShadowColor;                               ///< Cached Shadow color.
160   Vector4 mCachedBackgroundColor;                           ///< Cached Shadow background color (same as shadow color but with alpha at 0.0)
161
162   /////////////////////////////////////////////////////////////
163   // Properties that can be animated
164   Property::Index mBlurStrengthPropertyIndex;
165   Property::Index mShadowColorPropertyIndex;
166   float mDownsampleWidthScale;
167   float mDownsampleHeightScale;
168
169 private:
170
171   // Undefined copy constructor.
172   ShadowView( const ShadowView& );
173
174   // Undefined assignment operator.
175   ShadowView& operator=( const ShadowView& );
176 };
177
178 } // namespace Internal
179
180
181 // Helpers for public-api forwarding methods
182 inline Toolkit::Internal::ShadowView& GetImpl( Toolkit::ShadowView& obj )
183 {
184   DALI_ASSERT_ALWAYS(obj);
185   Dali::RefObject& handle = obj.GetImplementation();
186   return static_cast<Toolkit::Internal::ShadowView&>(handle);
187 }
188
189 inline const Toolkit::Internal::ShadowView& GetImpl( const Toolkit::ShadowView& obj )
190 {
191   DALI_ASSERT_ALWAYS(obj);
192   const Dali::RefObject& handle = obj.GetImplementation();
193   return static_cast<const Toolkit::Internal::ShadowView&>(handle);
194 }
195
196
197 } // namespace Toolkit
198
199 } // namespace Dali
200
201 #endif // __DALI_TOOLKIT_INTERNAL_SHADOW_VIEW_H__