1 #ifndef DALI_TOOLKIT_INTERNAL_IMAGE_FILTER_H
2 #define DALI_TOOLKIT_INTERNAL_IMAGE_FILTER_H
5 * Copyright (c) 2021 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/devel-api/controls/effects-view/effects-view.h>
28 #include <dali-toolkit/public-api/controls/control-impl.h>
37 * An interface class that provides a interface for image filters that perform
38 * a simple shader effect on an input texture, rendering the output to a FrameBuffer.
43 typedef std::vector<Vector3> FilterKernel;
54 virtual ~ImageFilter();
57 * Enable effect, allocates any necessary resources
59 virtual void Enable() = 0;
62 * Disable effect, releases any allocated resources
64 virtual void Disable() = 0;
67 * Refresh the filter output
69 virtual void Refresh() = 0;
72 * @copydoc Dali::Toolkit::EffectsView::SetRefreshOnDemand
74 void SetRefreshOnDemand(bool onDemand);
77 * Set the input texture
78 * @param[in] The input/original texture.
80 void SetInputTexture(Texture texture);
83 * Set the output frame buffer
84 * @return The output frame buffer.
86 void SetOutputFrameBuffer(FrameBuffer frameBuffer);
89 * Set size of ImageFilter. Used to create internal offscreen buffers
90 * @param[in] size THe size.
92 virtual void SetSize(const Vector2& size);
95 * Set the pixel format for internal offscreen buffers
96 * @param[in] pixelFormat The pixel format.
98 void SetPixelFormat(Pixel::Format pixelFormat);
101 * Set the filter kernel
102 * @param[in] The filter kernel
104 void SetKernel(const FilterKernel& kernel);
107 * Get a const reference to the internal filter kernel
108 * @Return A a const reference to the internal filter kernel
110 const FilterKernel& GetKernel() const;
113 * Get the number of steps/elements in the kernel
114 * @return The number of steps/elements in the kernel
116 size_t GetKernelSize() const;
119 * Create a kernel from an array of weights
123 void CreateKernel(const float* weights, size_t count);
126 * Set the actor which acts as the root actor for all internal actors for connection to stage
127 * @param[in] rootActor An actor which acts as the root actor for any internal actors that need
130 void SetRootActor(Actor rootActor);
133 * Set the background / clear color
134 * @param[in] color The background / clear color
136 void SetBackgroundColor(const Vector4& color);
140 * Setup position and parameters for camera
145 Texture mInputTexture;
146 FrameBuffer mOutputFrameBuffer;
147 FilterKernel mKernel;
149 CameraActor mCameraActor;
150 Vector4 mBackgroundColor;
152 Pixel::Format mPixelFormat;
153 bool mRefreshOnDemand;
155 }; // class Imagefilter
157 } // namespace Internal
159 } // namespace Toolkit
163 #endif // DALI_TOOLKIT_INTERNAL_IMAGE_FILTER_H