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 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 void RenderTask::SetSourceActor( Actor actor )
67 // NULL handle is allowed
68 Internal::Actor* actorImpl( NULL );
71 actorImpl = &GetImplementation( actor );
74 GetImplementation(*this).SetSourceActor( actorImpl );
77 Actor RenderTask::GetSourceActor() const
79 return Dali::Actor(GetImplementation(*this).GetSourceActor());
82 void RenderTask::SetExclusive( bool exclusive )
84 GetImplementation(*this).SetExclusive( exclusive );
87 bool RenderTask::IsExclusive() const
89 return GetImplementation(*this).IsExclusive();
92 void RenderTask::SetCameraActor( CameraActor cameraActor )
94 // NULL handle is allowed
95 Internal::CameraActor* actorImpl( NULL );
98 actorImpl = &GetImplementation( cameraActor );
101 GetImplementation(*this).SetCameraActor( actorImpl );
104 CameraActor RenderTask::GetCameraActor() const
106 return Dali::CameraActor(GetImplementation(*this).GetCameraActor());
109 void RenderTask::SetTargetFrameBuffer( FrameBufferImage frameBuffer )
111 GetImplementation(*this).SetTargetFrameBuffer( frameBuffer );
114 FrameBufferImage RenderTask::GetTargetFrameBuffer() const
116 return GetImplementation(*this).GetTargetFrameBuffer();
119 void RenderTask::SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction )
121 GetImplementation(*this).SetScreenToFrameBufferFunction( conversionFunction );
124 RenderTask::ScreenToFrameBufferFunction RenderTask::GetScreenToFrameBufferFunction() const
126 return GetImplementation(*this).GetScreenToFrameBufferFunction();
129 void RenderTask::SetScreenToFrameBufferMappingActor( Dali::Actor mappingActor )
131 // NULL handle is allowed
132 Internal::Actor* actorImpl( NULL );
135 actorImpl = &GetImplementation( mappingActor );
138 GetImplementation(*this).SetScreenToFrameBufferMappingActor( actorImpl );
141 Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const
143 return Dali::Actor(GetImplementation(*this).GetScreenToFrameBufferMappingActor());
146 void RenderTask::SetViewportPosition( Vector2 position )
148 GetImplementation(*this).SetViewportPosition( position );
151 Vector2 RenderTask::GetCurrentViewportPosition() const
153 return GetImplementation(*this).GetCurrentViewportPosition();
156 void RenderTask::SetViewportSize( Vector2 size )
158 GetImplementation(*this).SetViewportSize( size );
161 Vector2 RenderTask::GetCurrentViewportSize() const
163 return GetImplementation(*this).GetCurrentViewportSize();
166 void RenderTask::SetViewport( Viewport viewport )
168 GetImplementation(*this).SetViewport( viewport );
171 Viewport RenderTask::GetViewport() const
174 GetImplementation(*this).GetViewport( result );
178 void RenderTask::SetClearColor( const Vector4& color )
180 GetImplementation(*this).SetClearColor( color );
183 Vector4 RenderTask::GetClearColor() const
185 return GetImplementation(*this).GetClearColor();
188 void RenderTask::SetClearEnabled( bool enabled )
190 GetImplementation(*this).SetClearEnabled( enabled );
193 bool RenderTask::GetClearEnabled() const
195 return GetImplementation(*this).GetClearEnabled();
198 void RenderTask::SetRefreshRate( unsigned int refreshRate )
200 GetImplementation(*this).SetRefreshRate( refreshRate );
203 unsigned int RenderTask::GetRefreshRate() const
205 return GetImplementation(*this).GetRefreshRate();
208 RenderTask::RenderTaskSignalV2& RenderTask::FinishedSignal()
210 return GetImplementation(*this).FinishedSignal();
213 void RenderTask::SetInputEnabled( bool enabled )
215 GetImplementation(*this).SetInputEnabled( enabled );
218 bool RenderTask::GetInputEnabled() const
220 return GetImplementation(*this).GetInputEnabled();
223 RenderTask::RenderTask( Internal::RenderTask* internal )
224 : Constrainable(internal)