2 * Copyright (c) 2016 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/public-api/rendering/frame-buffer.h>
24 #include <dali/internal/event/actors/actor-impl.h>
25 #include <dali/internal/event/actors/camera-actor-impl.h>
26 #include <dali/internal/event/render-tasks/render-task-impl.h>
31 static bool DefaultScreenToFrameBufferFunction( Vector2& coordinates )
36 static bool FullScreenFrameBufferFunction( Vector2& coordinates )
38 // Don't need to modify frameBufferCoords
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 bool RenderTask::DEFAULT_CULL_MODE = true;
50 const unsigned int RenderTask::DEFAULT_REFRESH_RATE = REFRESH_ALWAYS;
52 RenderTask::RenderTask()
56 RenderTask RenderTask::DownCast( BaseHandle handle )
58 return RenderTask( dynamic_cast<Dali::Internal::RenderTask*>( handle.GetObjectPtr() ) );
61 RenderTask::~RenderTask()
65 RenderTask::RenderTask(const RenderTask& handle)
70 RenderTask& RenderTask::operator=(const RenderTask& rhs)
72 BaseHandle::operator=(rhs);
76 void RenderTask::SetSourceActor( Actor actor )
78 // NULL handle is allowed
79 Internal::Actor* actorImpl( NULL );
82 actorImpl = &GetImplementation( actor );
85 GetImplementation(*this).SetSourceActor( actorImpl );
88 Actor RenderTask::GetSourceActor() const
90 return Dali::Actor(GetImplementation(*this).GetSourceActor());
93 void RenderTask::SetExclusive( bool exclusive )
95 GetImplementation(*this).SetExclusive( exclusive );
98 bool RenderTask::IsExclusive() const
100 return GetImplementation(*this).IsExclusive();
103 void RenderTask::SetCameraActor( CameraActor cameraActor )
105 // NULL handle is allowed
106 Internal::CameraActor* actorImpl( NULL );
109 actorImpl = &GetImplementation( cameraActor );
112 GetImplementation(*this).SetCameraActor( actorImpl );
115 CameraActor RenderTask::GetCameraActor() const
117 return Dali::CameraActor(GetImplementation(*this).GetCameraActor());
120 void RenderTask::SetTargetFrameBuffer( FrameBufferImage frameBuffer )
122 GetImplementation(*this).SetTargetFrameBuffer( frameBuffer );
125 FrameBufferImage RenderTask::GetTargetFrameBuffer() const
127 return GetImplementation(*this).GetTargetFrameBuffer();
130 void RenderTask::SetFrameBuffer( FrameBuffer frameBuffer )
132 GetImplementation(*this).SetFrameBuffer( frameBuffer );
135 FrameBuffer RenderTask::GetFrameBuffer() const
137 Internal::FrameBuffer* frameBufferPtr( GetImplementation(*this).GetFrameBuffer() );
138 return FrameBuffer( frameBufferPtr );
141 void RenderTask::SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction )
143 GetImplementation(*this).SetScreenToFrameBufferFunction( conversionFunction );
146 RenderTask::ScreenToFrameBufferFunction RenderTask::GetScreenToFrameBufferFunction() const
148 return GetImplementation(*this).GetScreenToFrameBufferFunction();
151 void RenderTask::SetScreenToFrameBufferMappingActor( Dali::Actor mappingActor )
153 // NULL handle is allowed
154 Internal::Actor* actorImpl( NULL );
157 actorImpl = &GetImplementation( mappingActor );
160 GetImplementation(*this).SetScreenToFrameBufferMappingActor( actorImpl );
163 Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const
165 return Dali::Actor(GetImplementation(*this).GetScreenToFrameBufferMappingActor());
168 void RenderTask::SetViewportPosition( Vector2 position )
170 GetImplementation(*this).SetViewportPosition( position );
173 Vector2 RenderTask::GetCurrentViewportPosition() const
175 return GetImplementation(*this).GetCurrentViewportPosition();
178 void RenderTask::SetViewportSize( Vector2 size )
180 GetImplementation(*this).SetViewportSize( size );
183 Vector2 RenderTask::GetCurrentViewportSize() const
185 return GetImplementation(*this).GetCurrentViewportSize();
188 void RenderTask::SetViewport( Viewport viewport )
190 GetImplementation(*this).SetViewport( viewport );
193 Viewport RenderTask::GetViewport() const
196 GetImplementation(*this).GetViewport( result );
200 void RenderTask::SetClearColor( const Vector4& color )
202 GetImplementation(*this).SetClearColor( color );
205 Vector4 RenderTask::GetClearColor() const
207 return GetImplementation(*this).GetClearColor();
210 void RenderTask::SetClearEnabled( bool enabled )
212 GetImplementation(*this).SetClearEnabled( enabled );
215 bool RenderTask::GetClearEnabled() const
217 return GetImplementation(*this).GetClearEnabled();
220 void RenderTask::SetCullMode( bool mode )
222 GetImplementation(*this).SetCullMode( mode );
225 bool RenderTask::GetCullMode() const
227 return GetImplementation(*this).GetCullMode();
230 void RenderTask::SetRefreshRate( unsigned int refreshRate )
232 GetImplementation(*this).SetRefreshRate( refreshRate );
235 unsigned int RenderTask::GetRefreshRate() const
237 return GetImplementation(*this).GetRefreshRate();
240 RenderTask::RenderTaskSignalType& RenderTask::FinishedSignal()
242 return GetImplementation(*this).FinishedSignal();
245 void RenderTask::SetInputEnabled( bool enabled )
247 GetImplementation(*this).SetInputEnabled( enabled );
250 bool RenderTask::GetInputEnabled() const
252 return GetImplementation(*this).GetInputEnabled();
255 bool RenderTask::WorldToViewport(const Vector3 &position, float& viewportX, float& viewportY) const
257 return GetImplementation(*this).WorldToViewport(position, viewportX, viewportY);
260 bool RenderTask::ViewportToLocal(Actor actor, float viewportX, float viewportY, float &localX, float &localY) const
264 Internal::Actor* actorImpl( &GetImplementation( actor ) );
265 return GetImplementation(*this).ViewportToLocal( actorImpl, viewportX, viewportY, localX, localY );
274 RenderTask::RenderTask( Internal::RenderTask* internal )