1 #ifndef __DALI_TOOLKIT_INTERNAL_EFFECTS_VIEW_H__
2 #define __DALI_TOOLKIT_INTERNAL_EFFECTS_VIEW_H__
5 * Copyright (c) 2014 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.
24 #include <dali/dali.h>
25 #include <dali/public-api/common/dali-vector.h>
26 #include <dali-toolkit/public-api/controls/control-impl.h>
27 #include <dali-toolkit/public-api/controls/effects-view/effects-view.h>
28 #include <dali-toolkit/public-api/controls/gaussian-blur-view/gaussian-blur-view.h>
39 class GaussianBlurView;
43 * EffectsView implementation class
44 * @copydoc Dali::Toolkit::EffectsView
46 class EffectsView : public ControlImpl
49 /// @copydoc Dali::Toolkit::EffectsView New()
50 static Toolkit::EffectsView New();
53 * Construct a new EffectsView.
54 * @copydoc Toolkit::EffectsView New()
60 * @copydoc Toolkit::EffectsView New(const unsigned int,const float,const Pixel::Format,const float,const float)
62 EffectsView(const unsigned int numSamples, const float blurBellCurveWidth, const int spread,
63 const Pixel::Format pixelFormat,
64 const float downsampleWidthScale, const float downsampleHeightScale,
65 FrameBufferImage image);
68 * A reference counted object may only be deleted by calling Unreference()
70 virtual ~EffectsView();
74 /// @copydoc Dali::Toolkit::EffectsView::SetType
75 void SetType( Toolkit::EffectsView::EffectType type );
77 /// @copydoc Dali::Toolkit::EffectsView::GetType
78 Toolkit::EffectsView::EffectType GetType() const;
80 /// @copydoc Dali::Toolkit::EffectsView::Enable
83 /// @copydoc Dali::Toolkit::EffectsView::Disable
86 /// @copydoc Dali::Toolkit::EffectsView::Refresh
89 /// @copydoc Dali::Toolkit::EffectsView::SetRefreshOnDemand
90 void SetRefreshOnDemand( bool onDemand );
92 /// @copydoc Dali::Toolkit::EffectsView::SetPixelFormat
93 void SetPixelFormat( Pixel::Format pixelFormat );
95 /// @copydoc Dali::Toolkit::EffectsView::SetOutputImage
96 void SetOutputImage( FrameBufferImage image );
98 /// @copydoc Dali::Toolkit::EffectsView::GetOutputImage
99 FrameBufferImage GetOutputImage();
101 /// @copydoc Dali::Toolkit::EffectsView::GetEffectSizePropertyIndex
102 Property::Index GetEffectSizePropertyIndex() const;
104 /// @copydoc Dali::Toolkit::EffectsView::GetEffectStrengthPropertyIndex
105 Property::Index GetEffectStrengthPropertyIndex() const;
107 /// @copydoc Dali::Toolkit::EffectsView::GetEffectOffsetPropertyIndex
108 Property::Index GetEffectOffsetPropertyIndex() const;
110 /// @copydoc Dali::Toolkit::EffectsView::GetEffectColorPropertyIndex
111 Property::Index GetEffectColorPropertyIndex() const;
113 /// @copydoc Dali::Toolkit::EffectsView::SetBackgroundColor(const Vector4&)
114 void SetBackgroundColor( const Vector4& color );
116 /// @copydoc Dali::Toolkit::GaussianBlurView::GetBackgroundColor
117 Vector4 GetBackgroundColor() const;
121 * Register and setup indices for EffectsView properties
123 void SetupProperties();
125 private: // From ControlImpl
128 * @copydoc Toolkit::Control::OnInitialize()
130 virtual void OnInitialize();
133 * @copydoc Toolkit::Control::OnControlSizeSet( const Vector3& targetSize )
135 virtual void OnControlSizeSet( const Vector3& targetSize );
140 * Callback received when the control is disconnected from the stage.
142 void OnStageDisconnection();
145 * Setup image filters
152 void AllocateResources();
160 * Create render tasks for internal jobs
162 void CreateRenderTasks();
165 * Remove render tasks
167 void RemoveRenderTasks();
170 * Refresh render tasks
172 void RefreshRenderTasks();
175 * Remove ImageFilters
177 void RemoveFilters();
182 EffectsView( const EffectsView& );
185 EffectsView& operator = ( const EffectsView& );
187 private: // attributes/properties
188 Toolkit::EffectsView::EffectType mEffectType;
190 /////////////////////////////////////////////////////////////
191 // for rendering all user added children to offscreen target
192 FrameBufferImage mImageForChildren;
193 ImageActor mActorForChildren;
194 RenderTask mRenderTaskForChildren;
195 CameraActor mCameraForChildren;
197 /////////////////////////////////////////////////////////////
198 Pixel::Format mPixelFormat; ///< pixel format used by render targets
200 /////////////////////////////////////////////////////////////
201 // downsampling is used for the separated blur passes to get increased blur with the same number of samples and also to make rendering quicker
204 /////////////////////////////////////////////////////////////
205 // background fill color
206 Vector4 mBackgroundColor;
208 /////////////////////////////////////////////////////////////
209 // for checking if we need to reallocate render targets
213 bool mRefreshOnDemand;
215 /////////////////////////////////////////////////////////////
216 // horizontal spread objects
217 FrameBufferImage mImageForHorzSpread;
218 ImageActor mActorForHorzSpread;
219 RenderTask mRenderTaskForHorzSpread;
221 /////////////////////////////////////////////////////////////
222 // vertical spread objects
223 FrameBufferImage mImageForVertSpread;
224 ImageActor mActorForVertSpread;
225 RenderTask mRenderTaskForVertSpread;
227 CameraActor mCameraForSpread;
229 /////////////////////////////////////////////////////////////
231 FrameBufferImage mImagePostFilter;
232 ImageActor mActorPostFilter;
234 /////////////////////////////////////////////////////////////
236 FrameBufferImage mImageForResult;
237 Actor mActorForResult;
238 RenderTask mRenderTaskForResult;
240 Property::Index mEffectSizePropertyIndex;
241 Property::Index mEffectStrengthPropertyIndex;
242 Property::Index mEffectOffsetPropertyIndex;
243 Property::Index mEffectColorPropertyIndex;
245 std::vector<ImageFilter*> mFilters;
246 }; // class EffectsView
248 } // namespace Internal
251 // Helpers for public-api forwarding methods
253 inline Toolkit::Internal::EffectsView& GetImpl( Toolkit::EffectsView& effectsView )
255 DALI_ASSERT_ALWAYS( effectsView );
257 Dali::RefObject& handle = effectsView.GetImplementation();
259 return static_cast<Toolkit::Internal::EffectsView&>( handle );
262 inline const Toolkit::Internal::EffectsView& GetImpl( const Toolkit::EffectsView& effectsView )
264 DALI_ASSERT_ALWAYS( effectsView );
266 const Dali::RefObject& handle = effectsView.GetImplementation();
268 return static_cast<const Toolkit::Internal::EffectsView&>( handle );
271 } // namespace Toolkit
275 #endif // __DALI_TOOLKIT_INTERNAL_EFFECTS_VIEW_H__