Merge "TextSelectionPopup to show Paste in data in Clipboard" into devel/master
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / filters / image-filter.h
1 #ifndef __DALI_TOOLKIT_INTERNAL_IMAGE_FILTER_H__
2 #define __DALI_TOOLKIT_INTERNAL_IMAGE_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-toolkit/public-api/controls/control-impl.h>
25 #include <dali-toolkit/devel-api/controls/effects-view/effects-view.h>
26
27 namespace Dali
28 {
29
30 namespace Toolkit
31 {
32
33 namespace Internal
34 {
35
36 /**
37  * An interface class that provides a interface for image filters that perform
38  * a simple shader effect on an input image, rendering the output to a FrameBufferImage.
39  */
40 class ImageFilter
41 {
42 public:
43   typedef std::vector< Vector3 > FilterKernel;
44
45 public:
46
47   /**
48    * Default constructor
49    */
50   ImageFilter();
51
52   /**
53    * Destructor
54    */
55   virtual ~ImageFilter();
56
57   /**
58    * Enable effect, allocates any necessary resources
59    */
60   virtual void Enable() = 0;
61
62   /**
63    * Disable effect, releases any allocated resources
64    */
65   virtual void Disable() = 0;
66
67   /**
68    * Refresh the filter output
69    */
70   virtual void Refresh() = 0;
71
72   /**
73    * @copydoc Dali::Toolkit::EffectsView::SetRefreshOnDemand
74    */
75   void SetRefreshOnDemand( bool onDemand );
76
77   /**
78    * Set the input image
79    * @param[in] The input/original image.
80    */
81   void SetInputImage( Image image );
82
83   /**
84    * Set the output image
85    * @return The output image.
86    */
87   void SetOutputImage( FrameBufferImage image );
88
89   /**
90    * Set size of ImageFilter. Used to create internal offscreen buffers
91    * @param[in] size  THe size.
92    */
93   virtual void SetSize( const Vector2& size );
94
95   /**
96    * Set the pixel format for internal offscreen buffers
97    * @param[in] pixelFormat The pixel format.
98    */
99   void SetPixelFormat( Pixel::Format pixelFormat );
100
101   /**
102    * Set the filter kernel
103    * @param[in] The filter kernel
104    */
105   void SetKernel( const FilterKernel& kernel );
106
107   /**
108    * Get a const reference to the internal filter kernel
109    * @Return A a const reference to the internal filter kernel
110    */
111   const FilterKernel& GetKernel() const;
112
113   /**
114    * Get the number of steps/elements in the kernel
115    * @return The number of steps/elements in the kernel
116    */
117   size_t GetKernelSize() const;
118
119   /**
120    * Create a kernel from an array of weights
121    * @param[in] weights
122    * @param[in] count
123    */
124   void CreateKernel( const float* weights, size_t count);
125
126   /**
127    * Set the actor which acts as the root actor for all internal actors for connection to stage
128    * @param[in] rootActor   An actor which acts as the root actor for any internal actors that need
129    *                        to be created
130    */
131   void SetRootActor( Actor rootActor );
132
133   /**
134    * Set the background / clear color
135    * @param[in] color The background / clear color
136    */
137   void SetBackgroundColor( const Vector4& color );
138
139   /**
140    * Enable optional debug output in the shader
141    * @param[in] flag Set true to enable, dalse to disable.
142    */
143   void RenderDebug( bool flag );
144
145 protected:
146   Image            mInputImage;
147   FrameBufferImage mOutputImage;
148   FilterKernel     mKernel;
149   Actor            mRootActor;
150   Vector4          mBackgroundColor;
151   Vector2          mTargetSize;
152   Pixel::Format    mPixelFormat;
153   bool             mRefreshOnDemand;
154   bool             mDebugRender;
155 }; // class Imagefilter
156
157 } // namespace Internal
158
159 } // namespace Toolkit
160
161 } // namespace Dali
162
163 #endif // __DALI_TOOLKIT_INTERNAL_IMAGE_FILTER_H__
164