1 #ifndef __DALI_TOOLKIT_INTERNAL_SUPER_BLUR_VIEW_H__
2 #define __DALI_TOOLKIT_INTERNAL_SUPER_BLUR_VIEW_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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/public-api/controls/gaussian-blur-view/gaussian-blur-view.h>
25 #include <dali-toolkit/devel-api/controls/renderer-factory/renderer-factory.h>
39 * SuperBlurView implementation class
41 class SuperBlurView : public Control
47 * @copydoc Dali::Toolkit::SuperBlurView::New
49 static Toolkit::SuperBlurView New( unsigned int blurLevels );
52 * @copydoc Dali::Toolkit::SuperBlurView::SetImage
54 void SetImage(Image inputImage);
57 * Get the image for blurring.
58 * @return The image for blurring.
63 * @copydoc Dali::Toolkit::SuperBlurView::GetBlurStrengthPropertyIndex
65 Property::Index GetBlurStrengthPropertyIndex() const;
68 * @copydoc Dali::Toolkit::SuperBlurView::SetBlurStrength
70 void SetBlurStrength( float blurStrength );
73 * @copydoc Dali::Toolkit::SuperBlurView::GetCurrentBlurStrength
75 float GetCurrentBlurStrength() const;
78 * @copydoc Dali::Toolkit::SuperBlurView::BlurFinishedSignal
80 Dali::Toolkit::SuperBlurView::SuperBlurViewSignal& BlurFinishedSignal();
83 * @copydoc Dali::Toolkit::SuperBlurView::GetBlurredImage
85 Image GetBlurredImage( unsigned int level );
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.
95 static void SetProperty( BaseObject* object, Property::Index propertyIndex, const Property::Value& value );
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.
103 static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
108 * Constructor. It initializes the SuperBlurView members
110 SuperBlurView( unsigned int blurLevels );
113 * A reference counted object may only be deleted by calling Unreference()
115 virtual ~SuperBlurView();
117 private: // from Control
120 * @copydoc Toolkit::Control::OnInitialize
122 virtual void OnInitialize();
125 * @copydoc CustomActorImpl::OnSizeSet()
127 virtual void OnSizeSet(const Vector3& targetSize);
130 * @copydoc CustomActorImpl::OnStageConnection()
132 virtual void OnStageConnection( int depth );
135 * @copydoc CustomActorImpl::OnStageDisconnection()
137 virtual void OnStageDisconnection();
140 * @copydoc CustomActorImpl::GetNaturalSize()
142 virtual Vector3 GetNaturalSize();
147 * Carry out the idx-th pass of blurring
148 * @param[in] idx The blur pass index
149 * @param[in] image The input image for the current blurring, it is either the original image or the blurred image from the previous pass
151 void BlurImage( unsigned int idx, Image image );
154 * Signal handler to tell when the last blur view completes
155 * @param[in] blurView The blur view that just completed
157 void OnBlurViewFinished( Toolkit::GaussianBlurView blurView );
160 * Clear the resources used to create the blurred image
162 void ClearBlurResource();
165 * Sets shader effect on the control renderer
166 * @param[in,out] Sets custom shader effect on the given renderer
168 void SetShaderEffect( Toolkit::ControlRenderer& renderer );
171 std::vector<Toolkit::GaussianBlurView> mGaussianBlurView;
172 std::vector<FrameBufferImage> mBlurredImage;
173 std::vector<Toolkit::ControlRenderer> mRenderers;
177 Toolkit::SuperBlurView::SuperBlurViewSignal mBlurFinishedSignal; ///< Signal emitted when blur has completed.
179 Property::Index mBlurStrengthPropertyIndex;
180 unsigned int mBlurLevels;
181 bool mResourcesCleared;
186 // Helpers for public-api forwarding methods
187 inline Toolkit::Internal::SuperBlurView& GetImpl( Toolkit::SuperBlurView& obj )
189 DALI_ASSERT_ALWAYS(obj);
190 Dali::RefObject& handle = obj.GetImplementation();
191 return static_cast<Toolkit::Internal::SuperBlurView&>(handle);
194 inline const Toolkit::Internal::SuperBlurView& GetImpl( const Toolkit::SuperBlurView& obj )
196 DALI_ASSERT_ALWAYS(obj);
197 const Dali::RefObject& handle = obj.GetImplementation();
198 return static_cast<const Toolkit::Internal::SuperBlurView&>(handle);
205 #endif /* __DALI_TOOLKIT_INTERNALSUPER_BLUR_VIEW_H__ */