2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 #include <dali/public-api/render-tasks/render-task.h>
21 #include <dali/public-api/common/constants.h>
22 #include <dali/internal/event/actors/actor-impl.h>
23 #include <dali/internal/event/actors/camera-actor-impl.h>
24 #include <dali/internal/event/render-tasks/render-task-impl.h>
29 static bool DefaultScreenToFrameBufferFunction( Vector2& coordinates )
34 static bool FullScreenFrameBufferFunction( Vector2& coordinates )
36 // Don't need to modify frameBufferCoords
40 const char* const RenderTask::SIGNAL_FINISHED = "finished";
42 RenderTask::ConstScreenToFrameBufferFunction RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION = DefaultScreenToFrameBufferFunction;
43 RenderTask::ConstScreenToFrameBufferFunction RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION = FullScreenFrameBufferFunction;
45 const bool RenderTask::DEFAULT_EXCLUSIVE = false;
46 const bool RenderTask::DEFAULT_INPUT_ENABLED = true;
47 const Vector4 RenderTask::DEFAULT_CLEAR_COLOR = Vector4( 0.0f, 0.0f, 0.0f, 1.0f ); // cannot use Color::Black because it may or may not be initialized yet
48 const bool RenderTask::DEFAULT_CLEAR_ENABLED = false;
49 const unsigned int RenderTask::DEFAULT_REFRESH_RATE = REFRESH_ALWAYS;
51 RenderTask::RenderTask()
55 RenderTask RenderTask::DownCast( BaseHandle handle )
57 return RenderTask( dynamic_cast<Dali::Internal::RenderTask*>( handle.GetObjectPtr() ) );
60 RenderTask::~RenderTask()
64 void RenderTask::SetSourceActor( Actor actor )
66 // NULL handle is allowed
67 Internal::Actor* actorImpl( NULL );
70 actorImpl = &GetImplementation( actor );
73 GetImplementation(*this).SetSourceActor( actorImpl );
76 Actor RenderTask::GetSourceActor() const
78 return Dali::Actor(GetImplementation(*this).GetSourceActor());
81 void RenderTask::SetExclusive( bool exclusive )
83 GetImplementation(*this).SetExclusive( exclusive );
86 bool RenderTask::IsExclusive() const
88 return GetImplementation(*this).IsExclusive();
91 void RenderTask::SetCameraActor( CameraActor cameraActor )
93 // NULL handle is allowed
94 Internal::CameraActor* actorImpl( NULL );
97 actorImpl = &GetImplementation( cameraActor );
100 GetImplementation(*this).SetCameraActor( actorImpl );
103 CameraActor RenderTask::GetCameraActor() const
105 return Dali::CameraActor(GetImplementation(*this).GetCameraActor());
108 void RenderTask::SetTargetFrameBuffer( FrameBufferImage frameBuffer )
110 GetImplementation(*this).SetTargetFrameBuffer( frameBuffer );
113 FrameBufferImage RenderTask::GetTargetFrameBuffer() const
115 return GetImplementation(*this).GetTargetFrameBuffer();
118 void RenderTask::SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction )
120 GetImplementation(*this).SetScreenToFrameBufferFunction( conversionFunction );
123 RenderTask::ScreenToFrameBufferFunction RenderTask::GetScreenToFrameBufferFunction() const
125 return GetImplementation(*this).GetScreenToFrameBufferFunction();
128 void RenderTask::SetScreenToFrameBufferMappingActor( Dali::Actor mappingActor )
130 // NULL handle is allowed
131 Internal::Actor* actorImpl( NULL );
134 actorImpl = &GetImplementation( mappingActor );
137 GetImplementation(*this).SetScreenToFrameBufferMappingActor( actorImpl );
140 Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const
142 return Dali::Actor(GetImplementation(*this).GetScreenToFrameBufferMappingActor());
145 void RenderTask::SetViewportPosition( Vector2 position )
147 GetImplementation(*this).SetViewportPosition( position );
150 Vector2 RenderTask::GetCurrentViewportPosition() const
152 return GetImplementation(*this).GetCurrentViewportPosition();
155 void RenderTask::SetViewportSize( Vector2 size )
157 GetImplementation(*this).SetViewportSize( size );
160 Vector2 RenderTask::GetCurrentViewportSize() const
162 return GetImplementation(*this).GetCurrentViewportSize();
165 void RenderTask::SetViewport( Viewport viewport )
167 GetImplementation(*this).SetViewport( viewport );
170 Viewport RenderTask::GetViewport() const
173 GetImplementation(*this).GetViewport( result );
177 void RenderTask::SetClearColor( const Vector4& color )
179 GetImplementation(*this).SetClearColor( color );
182 Vector4 RenderTask::GetClearColor() const
184 return GetImplementation(*this).GetClearColor();
187 void RenderTask::SetClearEnabled( bool enabled )
189 GetImplementation(*this).SetClearEnabled( enabled );
192 bool RenderTask::GetClearEnabled() const
194 return GetImplementation(*this).GetClearEnabled();
197 void RenderTask::SetRefreshRate( unsigned int refreshRate )
199 GetImplementation(*this).SetRefreshRate( refreshRate );
202 unsigned int RenderTask::GetRefreshRate() const
204 return GetImplementation(*this).GetRefreshRate();
207 RenderTask::RenderTaskSignalV2& RenderTask::FinishedSignal()
209 return GetImplementation(*this).FinishedSignal();
212 void RenderTask::SetInputEnabled( bool enabled )
214 GetImplementation(*this).SetInputEnabled( enabled );
217 bool RenderTask::GetInputEnabled() const
219 return GetImplementation(*this).GetInputEnabled();
222 RenderTask::RenderTask( Internal::RenderTask* internal )
223 : Constrainable(internal)