Upload package dali-toolkit_0.9.13.
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / controls / super-blur-view / super-blur-view-impl.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_SUPER_BLUR_VIEW_H__
2 #define __DALI_TOOLKIT_INTERNAL_SUPER_BLUR_VIEW_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali/dali.h>
22 #include <dali-toolkit/public-api/controls/control-impl.h>
23 #include <dali-toolkit/public-api/controls/super-blur-view/super-blur-view.h>
24 #include <dali-toolkit/public-api/controls/gaussian-blur-view/gaussian-blur-view.h>
25
26 namespace Dali
27 {
28
29 namespace Toolkit
30 {
31
32 class SuperBlurView;
33
34 namespace Internal
35 {
36
37 /**
38  * SuperBlurView implementation class
39  */
40 class SuperBlurView : public ControlImpl
41 {
42 public:
43
44   /**
45    * @copydoc Dali::Toolkit::SuperBlurView::New
46    */
47   static Toolkit::SuperBlurView New( unsigned int blurLevels );
48
49   /**
50    * @copydoc Dali::Toolkit::SuperBlurView::SetImage
51    */
52   void SetImage(Image inputImage);
53
54   /**
55    * @copydoc Dali::Toolkit::SuperBlurView::GetBlurStrengthPropertyIndex
56    */
57   Property::Index GetBlurStrengthPropertyIndex() const;
58
59   /**
60    * @copydoc Dali::Toolkit::SuperBlurView::SetBlurStrength
61    */
62   void SetBlurStrength( float blurStrength );
63
64   /**
65    * @copydoc Dali::Toolkit::SuperBlurView::GetCurrentBlurStrength
66    */
67   float GetCurrentBlurStrength() const;
68
69   /**
70    * @copydoc Dali::Toolkit::SuperBlurView::BlurFinishedSignal
71    */
72   Dali::Toolkit::SuperBlurView::SuperBlurViewSignal& BlurFinishedSignal();
73
74   /**
75    * @copydoc Dali::Toolkit::SuperBlurView::GetBlurredImage
76    */
77   Image GetBlurredImage( unsigned int level );
78
79 protected:
80
81   /**
82    * Constructor. It initializes the SuperBlurView members
83    */
84   SuperBlurView( unsigned int blurLevels );
85
86   /**
87    * A reference counted object may only be deleted by calling Unreference()
88    */
89   virtual ~SuperBlurView();
90
91 private: // from ControlImpl
92
93   /**
94    * @copydoc Toolkit::Control::OnInitialize
95    */
96   virtual void OnInitialize();
97
98   /**
99    * @copydoc Toolkit::Control::OnControlSizeSet
100    */
101   virtual void OnControlSizeSet(const Vector3& targetSize);
102
103   /**
104    * @copydoc Toolkit::ControlImpl::OnRelaidOut()
105    */
106   virtual void OnRelaidOut( Vector2 size, ActorSizeContainer& container );
107
108 private:
109
110   /**
111    * Carry out the idx-th pass of blurring
112    * @param[in] idx The blur pass index
113    * @param[in] image The input image for the current blurring, it is either the original image or the blurred image from the previous pass
114    */
115   void BlurImage( unsigned int idx, Image image );
116
117   /**
118    * Signal handler to tell when the last blur view completes
119    * @param[in] blurView The blur view that just completed
120    */
121   void OnBlurViewFinished( Toolkit::GaussianBlurView blurView );
122
123   /**
124    * Clear the resources used to create the blurred image
125    */
126   void ClearBlurResource();
127
128 private:
129
130   unsigned int                           mBlurLevels;
131
132   Property::Index                        mBlurStrengthPropertyIndex;
133
134   std::vector<Toolkit::GaussianBlurView> mGaussianBlurView;
135   std::vector<FrameBufferImage>          mBlurredImage;
136   std::vector<ImageActor>                mImageActors;
137   bool                                   mResourcesCleared;
138
139   Vector2                                mTargetSize;
140   Toolkit::SuperBlurView::SuperBlurViewSignal mBlurFinishedSignal; ///< Signal emitted when blur has completed.
141 };
142
143 }
144
145 // Helpers for public-api forwarding methods
146 inline Toolkit::Internal::SuperBlurView& GetImpl( Toolkit::SuperBlurView& obj )
147 {
148   DALI_ASSERT_ALWAYS(obj);
149   Dali::RefObject& handle = obj.GetImplementation();
150   return static_cast<Toolkit::Internal::SuperBlurView&>(handle);
151 }
152
153 inline const Toolkit::Internal::SuperBlurView& GetImpl( const Toolkit::SuperBlurView& obj )
154 {
155   DALI_ASSERT_ALWAYS(obj);
156   const Dali::RefObject& handle = obj.GetImplementation();
157   return static_cast<const Toolkit::Internal::SuperBlurView&>(handle);
158 }
159
160 }
161
162 }
163
164 #endif /* __DALI_TOOLKIT_INTERNALSUPER_BLUR_VIEW_H__ */