1 #ifndef DALI_TOOLKIT_INTERNAL_IMAGE_FILTER_H
2 #define DALI_TOOLKIT_INTERNAL_IMAGE_FILTER_H
5 * Copyright (c) 2019 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/public-api/actors/camera-actor.h>
23 #include <dali/public-api/rendering/frame-buffer.h>
24 #include <dali/public-api/rendering/texture.h>
27 #include <dali-toolkit/public-api/controls/control-impl.h>
28 #include <dali-toolkit/devel-api/controls/effects-view/effects-view.h>
40 * An interface class that provides a interface for image filters that perform
41 * a simple shader effect on an input texture, rendering the output to a FrameBuffer.
46 typedef std::vector< Vector3 > FilterKernel;
58 virtual ~ImageFilter();
61 * Enable effect, allocates any necessary resources
63 virtual void Enable() = 0;
66 * Disable effect, releases any allocated resources
68 virtual void Disable() = 0;
71 * Refresh the filter output
73 virtual void Refresh() = 0;
76 * @copydoc Dali::Toolkit::EffectsView::SetRefreshOnDemand
78 void SetRefreshOnDemand( bool onDemand );
81 * Set the input texture
82 * @param[in] The input/original texture.
84 void SetInputTexture( Texture texture );
87 * Set the output frame buffer
88 * @return The output frame buffer.
90 void SetOutputFrameBuffer( FrameBuffer frameBuffer );
93 * Set size of ImageFilter. Used to create internal offscreen buffers
94 * @param[in] size THe size.
96 virtual void SetSize( const Vector2& size );
99 * Set the pixel format for internal offscreen buffers
100 * @param[in] pixelFormat The pixel format.
102 void SetPixelFormat( Pixel::Format pixelFormat );
105 * Set the filter kernel
106 * @param[in] The filter kernel
108 void SetKernel( const FilterKernel& kernel );
111 * Get a const reference to the internal filter kernel
112 * @Return A a const reference to the internal filter kernel
114 const FilterKernel& GetKernel() const;
117 * Get the number of steps/elements in the kernel
118 * @return The number of steps/elements in the kernel
120 size_t GetKernelSize() const;
123 * Create a kernel from an array of weights
127 void CreateKernel( const float* weights, size_t count);
130 * Set the actor which acts as the root actor for all internal actors for connection to stage
131 * @param[in] rootActor An actor which acts as the root actor for any internal actors that need
134 void SetRootActor( Actor rootActor );
137 * Set the background / clear color
138 * @param[in] color The background / clear color
140 void SetBackgroundColor( const Vector4& color );
145 * Setup position and parameters for camera
150 Texture mInputTexture;
151 FrameBuffer mOutputFrameBuffer;
152 FilterKernel mKernel;
154 CameraActor mCameraActor;
155 Vector4 mBackgroundColor;
157 Pixel::Format mPixelFormat;
158 bool mRefreshOnDemand;
160 }; // class Imagefilter
162 } // namespace Internal
164 } // namespace Toolkit
168 #endif // DALI_TOOLKIT_INTERNAL_IMAGE_FILTER_H