Purge underscored header file barriers
[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) 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 // INTERNAL INCLUDES
22 #include <dali-toolkit/public-api/controls/control-impl.h>
23 #include <dali-toolkit/devel-api/controls/super-blur-view/super-blur-view.h>
24 #include <dali-toolkit/devel-api/controls/gaussian-blur-view/gaussian-blur-view.h>
25 #include <dali-toolkit/devel-api/visual-factory/visual-factory.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 class SuperBlurView;
34
35 namespace Internal
36 {
37
38 /**
39  * SuperBlurView implementation class
40  */
41 class SuperBlurView : public Control
42 {
43
44 public:
45
46   /**
47    * @copydoc Dali::Toolkit::SuperBlurView::New
48    */
49   static Toolkit::SuperBlurView New( unsigned int blurLevels );
50
51   /**
52    * @copydoc Dali::Toolkit::SuperBlurView::SetImage
53    */
54   void SetImage(Image inputImage);
55
56   /**
57    * Get the image for blurring.
58    * @return The image for blurring.
59    */
60   Image GetImage();
61
62   /**
63    * @copydoc Dali::Toolkit::SuperBlurView::GetBlurStrengthPropertyIndex
64    */
65   Property::Index GetBlurStrengthPropertyIndex() const;
66
67   /**
68    * @copydoc Dali::Toolkit::SuperBlurView::SetBlurStrength
69    */
70   void SetBlurStrength( float blurStrength );
71
72   /**
73    * @copydoc Dali::Toolkit::SuperBlurView::GetCurrentBlurStrength
74    */
75   float GetCurrentBlurStrength() const;
76
77   /**
78    * @copydoc Dali::Toolkit::SuperBlurView::BlurFinishedSignal
79    */
80   Dali::Toolkit::SuperBlurView::SuperBlurViewSignal& BlurFinishedSignal();
81
82   /**
83    * @copydoc Dali::Toolkit::SuperBlurView::GetBlurredImage
84    */
85   Image GetBlurredImage( unsigned int level );
86
87   // Properties
88
89   /**
90    * Called when a property of an object of this type is set.
91    * @param[in] object The object whose property is set.
92    * @param[in] index The property index.
93    * @param[in] value The new property value.
94    */
95   static void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value );
96
97   /**
98    * Called to retrieve a property of an object of this type.
99    * @param[in] object The object whose property is to be retrieved.
100    * @param[in] index The property index.
101    * @return The current value of the property.
102    */
103   static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
104
105 protected:
106
107   /**
108    * Constructor. It initializes the SuperBlurView members
109    */
110   SuperBlurView( unsigned int blurLevels );
111
112   /**
113    * A reference counted object may only be deleted by calling Unreference()
114    */
115   virtual ~SuperBlurView();
116
117 private: // from Control
118
119   /**
120    * @copydoc Toolkit::Control::OnInitialize
121    */
122   virtual void OnInitialize();
123
124   /**
125    * @copydoc CustomActorImpl::OnSizeSet()
126    */
127   virtual void OnSizeSet(const Vector3& targetSize);
128
129   /**
130    * @copydoc CustomActorImpl::OnStageConnection()
131    */
132   virtual void OnStageConnection( int depth );
133
134   /**
135    * @copydoc CustomActorImpl::GetNaturalSize()
136    */
137   virtual Vector3 GetNaturalSize();
138
139 private:
140
141   /**
142    * Carry out the idx-th pass of blurring
143    * @param[in] idx The blur pass index
144    * @param[in] image The input image for the current blurring, it is either the original image or the blurred image from the previous pass
145    */
146   void BlurImage( unsigned int idx, Image image );
147
148   /**
149    * Signal handler to tell when the last blur view completes
150    * @param[in] blurView The blur view that just completed
151    */
152   void OnBlurViewFinished( Toolkit::GaussianBlurView blurView );
153
154   /**
155    * Clear the resources used to create the blurred image
156    */
157   void ClearBlurResource();
158
159   /**
160    * Sets shader effect on the control renderer
161    * @param[in,out] Sets custom shader effect on the given visual
162    */
163   void SetShaderEffect( Toolkit::Visual::Base& visual );
164
165 private:
166   std::vector<Toolkit::GaussianBlurView> mGaussianBlurView;
167   std::vector<FrameBufferImage>          mBlurredImage;
168   std::vector<Toolkit::Visual::Base>     mVisuals;
169   Image                                  mInputImage;
170   Vector2                                mTargetSize;
171
172   Toolkit::SuperBlurView::SuperBlurViewSignal mBlurFinishedSignal; ///< Signal emitted when blur has completed.
173
174   Property::Index                        mBlurStrengthPropertyIndex;
175   unsigned int                           mBlurLevels;
176   bool                                   mResourcesCleared;
177 };
178
179 }  // namespace Internal
180
181 // Helpers for public-api forwarding methods
182 inline Toolkit::Internal::SuperBlurView& GetImpl( Toolkit::SuperBlurView& obj )
183 {
184   DALI_ASSERT_ALWAYS(obj);
185   Dali::RefObject& handle = obj.GetImplementation();
186   return static_cast<Toolkit::Internal::SuperBlurView&>(handle);
187 }
188
189 inline const Toolkit::Internal::SuperBlurView& GetImpl( const Toolkit::SuperBlurView& obj )
190 {
191   DALI_ASSERT_ALWAYS(obj);
192   const Dali::RefObject& handle = obj.GetImplementation();
193   return static_cast<const Toolkit::Internal::SuperBlurView&>(handle);
194 }
195
196 } // namespace Toolkit
197
198 } // namespace Dali
199
200 #endif // DALI_TOOLKIT_INTERNAL_SUPER_BLUR_VIEW_H