1 #ifndef DALI_TOOLKIT_INTERNAL_EFFECTS_VIEW_H
2 #define DALI_TOOLKIT_INTERNAL_EFFECTS_VIEW_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/common/dali-vector.h>
24 #include <dali/public-api/render-tasks/render-task.h>
25 #include <dali/public-api/rendering/frame-buffer.h>
26 #include <dali/public-api/rendering/renderer.h>
29 #include <dali-toolkit/devel-api/controls/effects-view/effects-view.h>
30 #include <dali-toolkit/public-api/controls/control-impl.h>
41 class GaussianBlurView;
45 * EffectsView implementation class
46 * @copydoc Dali::Toolkit::EffectsView
48 class EffectsView : public Control
51 /// @copydoc Dali::Toolkit::EffectsView New()
52 static Toolkit::EffectsView New();
55 * Construct a new EffectsView.
56 * @copydoc Toolkit::EffectsView New()
61 * A reference counted object may only be deleted by calling Unreference()
63 virtual ~EffectsView();
67 /// @copydoc Dali::Toolkit::EffectsView::SetType
68 void SetType( Toolkit::EffectsView::EffectType type );
70 /// @copydoc Dali::Toolkit::EffectsView::GetType
71 Toolkit::EffectsView::EffectType GetType() const;
73 /// @copydoc Dali::Toolkit::EffectsView::Refresh
76 /// @copydoc Dali::Toolkit::EffectsView::SetRefreshOnDemand
77 void SetRefreshOnDemand( bool onDemand );
79 /// @copydoc Dali::Toolkit::EffectsView::SetPixelFormat
80 void SetPixelFormat( Pixel::Format pixelFormat );
82 /// @copydoc Dali::Toolkit::EffectsView::SetBackgroundColor(const Vector4&)
83 void SetBackgroundColor( const Vector4& color );
85 /// @copydoc Dali::Toolkit::GaussianBlurView::GetBackgroundColor
86 Vector4 GetBackgroundColor() const;
89 * Set the effect size which decides the size of filter kernel.
90 * @param[in] effectSize The effect size.
92 void SetEffectSize( int effectSize );
95 * Get the effect size.
96 * @return The effect size.
102 * Called when a property of an object of this type is set.
103 * @param[in] object The object whose property is set.
104 * @param[in] index The property index.
105 * @param[in] value The new property value.
107 static void SetProperty( BaseObject* object, Property::Index index, const Property::Value& value );
111 * Called to retrieve a property of an object of this type.
112 * @param[in] object The object whose property is to be retrieved.
113 * @param[in] index The property index.
114 * @return The current value of the property.
116 static Property::Value GetProperty( BaseObject* object, Property::Index propertyIndex );
118 private: // From Control
121 * @copydoc Toolkit::Internal::Control::OnInitialize()
123 virtual void OnInitialize();
126 * @copydoc CustomActorImpl::OnSizeSet( const Vector3& targetSize )
128 virtual void OnSizeSet( const Vector3& targetSize );
131 * @copydoc Toolkit::Internal::Control::OnStageConnection
133 virtual void OnStageConnection( int depth );
136 * @copydoc Toolkit::Internal::Control::OnStageDisconnection
138 virtual void OnStageDisconnection();
141 * @copydoc Toolkit::Internal::Control::OnChildAdd
143 virtual void OnChildAdd( Actor& child );
146 * @copydoc Toolkit::Internal::Control::OnChildRemove
148 virtual void OnChildRemove( Actor& child );
153 * Enable the effect when the control is set on stage
158 * Disable the effect when the control is set off stage
163 * Setup image filters
170 void AllocateResources();
178 * Create render tasks for internal jobs
180 void CreateRenderTasks();
183 * Remove render tasks
185 void RemoveRenderTasks();
188 * Refresh render tasks
190 void RefreshRenderTasks();
193 * Remove ImageFilters
195 void RemoveFilters();
200 EffectsView( const EffectsView& );
203 EffectsView& operator = ( const EffectsView& );
205 private: // attributes/properties
207 /////////////////////////////////////////////////////////////
208 // for rendering all user added children to offscreen target
209 FrameBuffer mFrameBufferForChildren;
210 Renderer mRendererForChildren;
211 RenderTask mRenderTaskForChildren;
212 CameraActor mCameraForChildren;
213 Actor mChildrenRoot; // for creating a subtree for all user added child actors
215 /////////////////////////////////////////////////////////////
216 // background fill color
217 Vector4 mBackgroundColor;
219 /////////////////////////////////////////////////////////////
220 // for checking if we need to reallocate render targets
223 /////////////////////////////////////////////////////////////
225 FrameBuffer mFrameBufferPostFilter;
226 Renderer mRendererPostFilter;
228 Vector<ImageFilter*> mFilters;
230 /////////////////////////////////////////////////////////////
231 // downsampling is used for the separated blur passes to get increased blur with the same number of samples and also to make rendering quicker
234 /////////////////////////////////////////////////////////////
235 Toolkit::EffectsView::EffectType mEffectType;
236 Pixel::Format mPixelFormat; ///< pixel format used by render targets
239 bool mRefreshOnDemand:1;
240 }; // class EffectsView
242 } // namespace Internal
245 // Helpers for public-api forwarding methods
247 inline Toolkit::Internal::EffectsView& GetImpl( Toolkit::EffectsView& effectsView )
249 DALI_ASSERT_ALWAYS( effectsView );
251 Dali::RefObject& handle = effectsView.GetImplementation();
253 return static_cast<Toolkit::Internal::EffectsView&>( handle );
256 inline const Toolkit::Internal::EffectsView& GetImpl( const Toolkit::EffectsView& effectsView )
258 DALI_ASSERT_ALWAYS( effectsView );
260 const Dali::RefObject& handle = effectsView.GetImplementation();
262 return static_cast<const Toolkit::Internal::EffectsView&>( handle );
265 } // namespace Toolkit
269 #endif // DALI_TOOLKIT_INTERNAL_EFFECTS_VIEW_H