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