2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/public-api/render-tasks/render-task.h>
22 #include <dali/public-api/common/constants.h>
23 #include <dali/internal/event/actors/actor-impl.h>
24 #include <dali/internal/event/actors/camera-actor-impl.h>
25 #include <dali/internal/event/render-tasks/render-task-impl.h>
30 static bool DefaultScreenToFrameBufferFunction( Vector2& coordinates )
35 static bool FullScreenFrameBufferFunction( Vector2& coordinates )
37 // Don't need to modify frameBufferCoords
41 const char* const RenderTask::SIGNAL_FINISHED = "finished";
43 RenderTask::ConstScreenToFrameBufferFunction RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION = DefaultScreenToFrameBufferFunction;
44 RenderTask::ConstScreenToFrameBufferFunction RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION = FullScreenFrameBufferFunction;
46 const bool RenderTask::DEFAULT_EXCLUSIVE = false;
47 const bool RenderTask::DEFAULT_INPUT_ENABLED = true;
48 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
49 const bool RenderTask::DEFAULT_CLEAR_ENABLED = false;
50 const bool RenderTask::DEFAULT_CULL_MODE = true;
51 const unsigned int RenderTask::DEFAULT_REFRESH_RATE = REFRESH_ALWAYS;
53 RenderTask::RenderTask()
57 RenderTask RenderTask::DownCast( BaseHandle handle )
59 return RenderTask( dynamic_cast<Dali::Internal::RenderTask*>( handle.GetObjectPtr() ) );
62 RenderTask::~RenderTask()
66 RenderTask::RenderTask(const RenderTask& handle)
67 : Constrainable(handle)
71 RenderTask& RenderTask::operator=(const RenderTask& rhs)
73 BaseHandle::operator=(rhs);
77 RenderTask& RenderTask::operator=(BaseHandle::NullType* rhs)
79 DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
84 void RenderTask::SetSourceActor( Actor actor )
86 // NULL handle is allowed
87 Internal::Actor* actorImpl( NULL );
90 actorImpl = &GetImplementation( actor );
93 GetImplementation(*this).SetSourceActor( actorImpl );
96 Actor RenderTask::GetSourceActor() const
98 return Dali::Actor(GetImplementation(*this).GetSourceActor());
101 void RenderTask::SetExclusive( bool exclusive )
103 GetImplementation(*this).SetExclusive( exclusive );
106 bool RenderTask::IsExclusive() const
108 return GetImplementation(*this).IsExclusive();
111 void RenderTask::SetCameraActor( CameraActor cameraActor )
113 // NULL handle is allowed
114 Internal::CameraActor* actorImpl( NULL );
117 actorImpl = &GetImplementation( cameraActor );
120 GetImplementation(*this).SetCameraActor( actorImpl );
123 CameraActor RenderTask::GetCameraActor() const
125 return Dali::CameraActor(GetImplementation(*this).GetCameraActor());
128 void RenderTask::SetTargetFrameBuffer( FrameBufferImage frameBuffer )
130 GetImplementation(*this).SetTargetFrameBuffer( frameBuffer );
133 FrameBufferImage RenderTask::GetTargetFrameBuffer() const
135 return GetImplementation(*this).GetTargetFrameBuffer();
138 void RenderTask::SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction )
140 GetImplementation(*this).SetScreenToFrameBufferFunction( conversionFunction );
143 RenderTask::ScreenToFrameBufferFunction RenderTask::GetScreenToFrameBufferFunction() const
145 return GetImplementation(*this).GetScreenToFrameBufferFunction();
148 void RenderTask::SetScreenToFrameBufferMappingActor( Dali::Actor mappingActor )
150 // NULL handle is allowed
151 Internal::Actor* actorImpl( NULL );
154 actorImpl = &GetImplementation( mappingActor );
157 GetImplementation(*this).SetScreenToFrameBufferMappingActor( actorImpl );
160 Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const
162 return Dali::Actor(GetImplementation(*this).GetScreenToFrameBufferMappingActor());
165 void RenderTask::SetViewportPosition( Vector2 position )
167 GetImplementation(*this).SetViewportPosition( position );
170 Vector2 RenderTask::GetCurrentViewportPosition() const
172 return GetImplementation(*this).GetCurrentViewportPosition();
175 void RenderTask::SetViewportSize( Vector2 size )
177 GetImplementation(*this).SetViewportSize( size );
180 Vector2 RenderTask::GetCurrentViewportSize() const
182 return GetImplementation(*this).GetCurrentViewportSize();
185 void RenderTask::SetViewport( Viewport viewport )
187 GetImplementation(*this).SetViewport( viewport );
190 Viewport RenderTask::GetViewport() const
193 GetImplementation(*this).GetViewport( result );
197 void RenderTask::SetClearColor( const Vector4& color )
199 GetImplementation(*this).SetClearColor( color );
202 Vector4 RenderTask::GetClearColor() const
204 return GetImplementation(*this).GetClearColor();
207 void RenderTask::SetClearEnabled( bool enabled )
209 GetImplementation(*this).SetClearEnabled( enabled );
212 bool RenderTask::GetClearEnabled() const
214 return GetImplementation(*this).GetClearEnabled();
217 void RenderTask::SetCullMode( bool mode )
219 GetImplementation(*this).SetCullMode( mode );
222 bool RenderTask::GetCullMode() const
224 return GetImplementation(*this).GetCullMode();
227 void RenderTask::SetRefreshRate( unsigned int refreshRate )
229 GetImplementation(*this).SetRefreshRate( refreshRate );
232 unsigned int RenderTask::GetRefreshRate() const
234 return GetImplementation(*this).GetRefreshRate();
237 RenderTask::RenderTaskSignalV2& RenderTask::FinishedSignal()
239 return GetImplementation(*this).FinishedSignal();
242 void RenderTask::SetInputEnabled( bool enabled )
244 GetImplementation(*this).SetInputEnabled( enabled );
247 bool RenderTask::GetInputEnabled() const
249 return GetImplementation(*this).GetInputEnabled();
252 RenderTask::RenderTask( Internal::RenderTask* internal )
253 : Constrainable(internal)