Conversion to Apache 2.0 license
[platform/core/uifw/dali-toolkit.git] / optional / 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
23 // INTERNAL INCLUDES
24 #include <dali/dali.h>
25 #include "image-filter.h"
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Internal
34 {
35
36 /**
37  * A two pass blur filter, pass one performs a horizontal blur and pass two performs a
38  * vertical blur on the result of pass one.
39  */
40 class BlurTwoPassFilter : public ImageFilter
41 {
42 public:
43   /**
44    * Default constructor
45    */
46   BlurTwoPassFilter();
47
48   /**
49    * Destructor
50    */
51   virtual ~BlurTwoPassFilter();
52
53 public: // From ImageFilter
54   /// @copydoc Dali::Toolkit::Internal::ImageFilter::Enable
55   virtual void Enable();
56
57   /// @copydoc Dali::Toolkit::Internal::ImageFilter::Disable
58   virtual void Disable();
59
60   /// @copydoc Dali::Toolkit::Internal::ImageFilter::Refresh
61   virtual void Refresh();
62
63   /**
64    * Get the property index that controls the strength of the blur applied to the image. Useful for animating this property.
65    * This property represents a value in the range [0.0 - 1.0] where 0.0 is no blur and 1.0 is full blur.
66    */
67   Property::Index GetBlurStrengthPropertyIndex() const {return mBlurStrengthPropertyIndex;}
68
69   /**
70    * Retrieve the constrainable object to animate or constrain the blur strength property
71    * @return the constrainable object which blend the output image according to the blur strength
72    */
73   Constrainable GetHandleForAnimateBlurStrength();
74
75 private:
76   /**
77    * Setup position and parameters for camera
78    */
79   void SetupCamera();
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   CameraActor      mCameraForBlur;
93
94   // To perform horizontal blur from mInputImage to mImageForHorz
95   RenderTask       mRenderTaskForHorz;
96   ImageActor       mActorForInput;
97   FrameBufferImage mImageForHorz;
98   ShaderEffect     mShaderForHorz;
99
100   // To perform vertical blur from mImageForHorz to mOutputImage
101   RenderTask       mRenderTaskForVert;
102   ImageActor       mActorForHorz;
103   ShaderEffect     mShaderForVert;
104   FrameBufferImage mBlurredImage;
105
106   // To blend the blurred image and input image according to the blur strength
107   RenderTask       mRenderTaskForBlending;
108   ImageActor       mActorForBlending;
109   Actor            mRootActorForBlending;
110   ShaderEffect     mShaderForBlending;
111   Property::Index  mBlurStrengthPropertyIndex;
112
113 }; // class BlurTwoPassFilter
114
115 } // namespace Internal
116
117 } // namespace Toolkit
118
119 } // namespace Dali
120
121 #endif // __DALI_TOOLKIT_INTERNAL_BLUR_TWO_PASS_FILTER_H__
122