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