3e73a27ce86acd95f8a5e5ebcc18c25339c43b5d
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / filters / blur-two-pass-filter.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_BLUR_TWO_PASS_FILTER_H__
2 #define __DALI_TOOLKIT_INTERNAL_BLUR_TWO_PASS_FILTER_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 // EXTERNAL INCLUDES
22 #include <dali/public-api/render-tasks/render-task.h>
23 #include <dali-toolkit/public-api/controls/image-view/image-view.h>
24
25 // INTERNAL INCLUDES
26 #include "image-filter.h"
27
28 namespace Dali
29 {
30
31 namespace Toolkit
32 {
33
34 namespace Internal
35 {
36
37 /**
38  * A two pass blur filter, pass one performs a horizontal blur and pass two performs a
39  * vertical blur on the result of pass one.
40  */
41 class BlurTwoPassFilter : public ImageFilter
42 {
43 public:
44   /**
45    * Default constructor
46    */
47   BlurTwoPassFilter();
48
49   /**
50    * Destructor
51    */
52   virtual ~BlurTwoPassFilter();
53
54 public: // From ImageFilter
55   /// @copydoc Dali::Toolkit::Internal::ImageFilter::Enable
56   virtual void Enable();
57
58   /// @copydoc Dali::Toolkit::Internal::ImageFilter::Disable
59   virtual void Disable();
60
61   /// @copydoc Dali::Toolkit::Internal::ImageFilter::Refresh
62   virtual void Refresh();
63
64   /// @copydoc Dali::Toolkit::Internal::ImageFilter::SetSize
65   virtual void SetSize( const Vector2& size );
66
67   /**
68    * Get the property index that controls the strength of the blur applied to the image. Useful for animating this property.
69    * This property represents a value in the range [0.0 - 1.0] where 0.0 is no blur and 1.0 is full blur.
70    */
71   Property::Index GetBlurStrengthPropertyIndex() const {return mBlurStrengthPropertyIndex;}
72
73   /**
74    * Retrieve the handle to the object in order to animate or constrain the blur strength property
75    * @return The hadnle to the object which blends the output image according to the blur strength
76    */
77   Handle GetHandleForAnimateBlurStrength();
78
79 private:
80
81   /**
82    * Setup render tasks for blur
83    */
84   void CreateRenderTasks();
85
86 private:
87   BlurTwoPassFilter( const BlurTwoPassFilter& );
88   BlurTwoPassFilter& operator=( const BlurTwoPassFilter& );
89
90 private: // Attributes
91
92   // To perform horizontal blur from mInputImage to mImageForHorz
93   RenderTask         mRenderTaskForHorz;
94   Toolkit::ImageView mActorForInput;
95   FrameBufferImage   mImageForHorz;
96
97   // To perform vertical blur from mImageForHorz to mOutputImage
98   RenderTask         mRenderTaskForVert;
99   Toolkit::ImageView mActorForHorz;
100   FrameBufferImage   mBlurredImage;
101
102   // To blend the blurred image and input image according to the blur strength
103   RenderTask         mRenderTaskForBlending;
104   Toolkit::ImageView mActorForBlending;
105   Actor              mRootActorForBlending;
106   Property::Index    mBlurStrengthPropertyIndex;
107
108 }; // class BlurTwoPassFilter
109
110 } // namespace Internal
111
112 } // namespace Toolkit
113
114 } // namespace Dali
115
116 #endif // __DALI_TOOLKIT_INTERNAL_BLUR_TWO_PASS_FILTER_H__
117