2 * Copyright (c) 2020 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 uint32_t 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::SetFrameBuffer( FrameBuffer frameBuffer )
122 Internal::FrameBuffer* frameBufferPtr( NULL );
125 frameBufferPtr = &GetImplementation( frameBuffer );
128 GetImplementation(*this).SetFrameBuffer( frameBufferPtr );
131 FrameBuffer RenderTask::GetFrameBuffer() const
133 Internal::FrameBuffer* frameBufferPtr( GetImplementation(*this).GetFrameBuffer() );
134 return FrameBuffer( frameBufferPtr );
137 void RenderTask::SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction )
139 GetImplementation(*this).SetScreenToFrameBufferFunction( conversionFunction );
142 RenderTask::ScreenToFrameBufferFunction RenderTask::GetScreenToFrameBufferFunction() const
144 return GetImplementation(*this).GetScreenToFrameBufferFunction();
147 void RenderTask::SetScreenToFrameBufferMappingActor( Dali::Actor mappingActor )
149 GetImplementation(*this).SetScreenToFrameBufferMappingActor( mappingActor );
152 Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const
154 return GetImplementation(*this).GetScreenToFrameBufferMappingActor();
157 void RenderTask::SetViewportPosition( Vector2 position )
159 GetImplementation(*this).SetViewportPosition( position );
162 Vector2 RenderTask::GetCurrentViewportPosition() const
164 return GetImplementation(*this).GetCurrentViewportPosition();
167 void RenderTask::SetViewportSize( Vector2 size )
169 GetImplementation(*this).SetViewportSize( size );
172 Vector2 RenderTask::GetCurrentViewportSize() const
174 return GetImplementation(*this).GetCurrentViewportSize();
177 void RenderTask::SetViewport( Viewport viewport )
179 GetImplementation(*this).SetViewport( viewport );
182 Viewport RenderTask::GetViewport() const
185 GetImplementation(*this).GetViewport( result );
189 void RenderTask::SetClearColor( const Vector4& color )
191 GetImplementation(*this).SetClearColor( color );
194 Vector4 RenderTask::GetClearColor() const
196 return GetImplementation(*this).GetClearColor();
199 void RenderTask::SetClearEnabled( bool enabled )
201 GetImplementation(*this).SetClearEnabled( enabled );
204 bool RenderTask::GetClearEnabled() const
206 return GetImplementation(*this).GetClearEnabled();
209 void RenderTask::SetCullMode( bool mode )
211 GetImplementation(*this).SetCullMode( mode );
214 bool RenderTask::GetCullMode() const
216 return GetImplementation(*this).GetCullMode();
219 void RenderTask::SetRefreshRate( uint32_t refreshRate )
221 GetImplementation(*this).SetRefreshRate( refreshRate );
224 uint32_t RenderTask::GetRefreshRate() const
226 return GetImplementation(*this).GetRefreshRate();
229 RenderTask::RenderTaskSignalType& RenderTask::FinishedSignal()
231 return GetImplementation(*this).FinishedSignal();
234 void RenderTask::SetInputEnabled( bool enabled )
236 GetImplementation(*this).SetInputEnabled( enabled );
239 bool RenderTask::GetInputEnabled() const
241 return GetImplementation(*this).GetInputEnabled();
244 bool RenderTask::WorldToViewport(const Vector3 &position, float& viewportX, float& viewportY) const
246 return GetImplementation(*this).WorldToViewport(position, viewportX, viewportY);
249 bool RenderTask::ViewportToLocal(Actor actor, float viewportX, float viewportY, float &localX, float &localY) const
253 Internal::Actor* actorImpl( &GetImplementation( actor ) );
254 return GetImplementation(*this).ViewportToLocal( actorImpl, viewportX, viewportY, localX, localY );
263 RenderTask::RenderTask( Internal::RenderTask* internal )