Merge branch 'new_text' into tizen
[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 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 // INTERNAL INCLUDES
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 Control
41 {
42
43 public:
44
45   /**
46    * @copydoc Dali::Toolkit::SuperBlurView::New
47    */
48   static Toolkit::SuperBlurView New( unsigned int blurLevels );
49
50   /**
51    * @copydoc Dali::Toolkit::SuperBlurView::SetImage
52    */
53   void SetImage(Image inputImage);
54
55   /**
56    * @copydoc Dali::Toolkit::SuperBlurView::GetBlurStrengthPropertyIndex
57    */
58   Property::Index GetBlurStrengthPropertyIndex() const;
59
60   /**
61    * @copydoc Dali::Toolkit::SuperBlurView::SetBlurStrength
62    */
63   void SetBlurStrength( float blurStrength );
64
65   /**
66    * @copydoc Dali::Toolkit::SuperBlurView::GetCurrentBlurStrength
67    */
68   float GetCurrentBlurStrength() const;
69
70   /**
71    * @copydoc Dali::Toolkit::SuperBlurView::BlurFinishedSignal
72    */
73   Dali::Toolkit::SuperBlurView::SuperBlurViewSignal& BlurFinishedSignal();
74
75   /**
76    * @copydoc Dali::Toolkit::SuperBlurView::GetBlurredImage
77    */
78   Image GetBlurredImage( unsigned int level );
79
80   // Properties
81
82   /**
83    * Called when a property of an object of this type is set.
84    * @param[in] object The object whose property is set.
85    * @param[in] index The property index.
86    * @param[in] value The new property value.
87    */
88   static void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value );
89
90   /**
91    * Called to retrieve a property of an object of this type.
92    * @param[in] object The object whose property is to be retrieved.
93    * @param[in] index The property index.
94    * @return The current value of the property.
95    */
96   static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
97
98 protected:
99
100   /**
101    * Constructor. It initializes the SuperBlurView members
102    */
103   SuperBlurView( unsigned int blurLevels );
104
105   /**
106    * A reference counted object may only be deleted by calling Unreference()
107    */
108   virtual ~SuperBlurView();
109
110 private: // from Control
111
112   /**
113    * @copydoc Toolkit::Control::OnInitialize
114    */
115   virtual void OnInitialize();
116
117   /**
118    * @copydoc Toolkit::Control::OnControlSizeSet
119    */
120   virtual void OnControlSizeSet(const Vector3& targetSize);
121
122 private:
123
124   /**
125    * Carry out the idx-th pass of blurring
126    * @param[in] idx The blur pass index
127    * @param[in] image The input image for the current blurring, it is either the original image or the blurred image from the previous pass
128    */
129   void BlurImage( unsigned int idx, Image image );
130
131   /**
132    * Signal handler to tell when the last blur view completes
133    * @param[in] blurView The blur view that just completed
134    */
135   void OnBlurViewFinished( Toolkit::GaussianBlurView blurView );
136
137   /**
138    * Clear the resources used to create the blurred image
139    */
140   void ClearBlurResource();
141
142 private:
143
144   unsigned int                           mBlurLevels;
145
146   Property::Index                        mBlurStrengthPropertyIndex;
147
148   std::vector<Toolkit::GaussianBlurView> mGaussianBlurView;
149   std::vector<FrameBufferImage>          mBlurredImage;
150   std::vector<ImageActor>                mImageActors;
151   bool                                   mResourcesCleared;
152
153   Vector2                                mTargetSize;
154   Toolkit::SuperBlurView::SuperBlurViewSignal mBlurFinishedSignal; ///< Signal emitted when blur has completed.
155 };
156
157 }
158
159 // Helpers for public-api forwarding methods
160 inline Toolkit::Internal::SuperBlurView& GetImpl( Toolkit::SuperBlurView& obj )
161 {
162   DALI_ASSERT_ALWAYS(obj);
163   Dali::RefObject& handle = obj.GetImplementation();
164   return static_cast<Toolkit::Internal::SuperBlurView&>(handle);
165 }
166
167 inline const Toolkit::Internal::SuperBlurView& GetImpl( const Toolkit::SuperBlurView& obj )
168 {
169   DALI_ASSERT_ALWAYS(obj);
170   const Dali::RefObject& handle = obj.GetImplementation();
171   return static_cast<const Toolkit::Internal::SuperBlurView&>(handle);
172 }
173
174 }
175
176 }
177
178 #endif /* __DALI_TOOLKIT_INTERNALSUPER_BLUR_VIEW_H__ */