DALi signals refactor to remove V2 naming
[platform/core/uifw/dali-core.git] / dali / public-api / render-tasks / render-task.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/public-api/render-tasks/render-task.h>
20
21 // INTERNAL INCLUDES
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>
26
27 namespace Dali
28 {
29
30 static bool DefaultScreenToFrameBufferFunction( Vector2& coordinates )
31 {
32   return false;
33 }
34
35 static bool FullScreenFrameBufferFunction( Vector2& coordinates )
36 {
37   // Don't need to modify frameBufferCoords
38   return true;
39 }
40
41 const char* const RenderTask::SIGNAL_FINISHED = "finished";
42
43 RenderTask::ConstScreenToFrameBufferFunction RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION = DefaultScreenToFrameBufferFunction;
44 RenderTask::ConstScreenToFrameBufferFunction RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION        = FullScreenFrameBufferFunction;
45
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;
52
53 RenderTask::RenderTask()
54 {
55 }
56
57 RenderTask RenderTask::DownCast( BaseHandle handle )
58 {
59   return RenderTask( dynamic_cast<Dali::Internal::RenderTask*>( handle.GetObjectPtr() ) );
60 }
61
62 RenderTask::~RenderTask()
63 {
64 }
65
66 RenderTask::RenderTask(const RenderTask& handle)
67 : Constrainable(handle)
68 {
69 }
70
71 RenderTask& RenderTask::operator=(const RenderTask& rhs)
72 {
73   BaseHandle::operator=(rhs);
74   return *this;
75 }
76
77 void RenderTask::SetSourceActor( Actor actor )
78 {
79   // NULL handle is allowed
80   Internal::Actor* actorImpl( NULL );
81   if ( actor )
82   {
83     actorImpl = &GetImplementation( actor );
84   }
85
86   GetImplementation(*this).SetSourceActor( actorImpl );
87 }
88
89 Actor RenderTask::GetSourceActor() const
90 {
91   return Dali::Actor(GetImplementation(*this).GetSourceActor());
92 }
93
94 void RenderTask::SetExclusive( bool exclusive )
95 {
96   GetImplementation(*this).SetExclusive( exclusive );
97 }
98
99 bool RenderTask::IsExclusive() const
100 {
101   return GetImplementation(*this).IsExclusive();
102 }
103
104 void RenderTask::SetCameraActor( CameraActor cameraActor )
105 {
106   // NULL handle is allowed
107   Internal::CameraActor* actorImpl( NULL );
108   if ( cameraActor )
109   {
110     actorImpl = &GetImplementation( cameraActor );
111   }
112
113   GetImplementation(*this).SetCameraActor( actorImpl );
114 }
115
116 CameraActor RenderTask::GetCameraActor() const
117 {
118   return Dali::CameraActor(GetImplementation(*this).GetCameraActor());
119 }
120
121 void RenderTask::SetTargetFrameBuffer( FrameBufferImage frameBuffer )
122 {
123   GetImplementation(*this).SetTargetFrameBuffer( frameBuffer );
124 }
125
126 FrameBufferImage RenderTask::GetTargetFrameBuffer() const
127 {
128   return GetImplementation(*this).GetTargetFrameBuffer();
129 }
130
131 void RenderTask::SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction )
132 {
133   GetImplementation(*this).SetScreenToFrameBufferFunction( conversionFunction );
134 }
135
136 RenderTask::ScreenToFrameBufferFunction RenderTask::GetScreenToFrameBufferFunction() const
137 {
138   return GetImplementation(*this).GetScreenToFrameBufferFunction();
139 }
140
141 void RenderTask::SetScreenToFrameBufferMappingActor( Dali::Actor mappingActor )
142 {
143   // NULL handle is allowed
144   Internal::Actor* actorImpl( NULL );
145   if ( mappingActor )
146   {
147     actorImpl = &GetImplementation( mappingActor );
148   }
149
150   GetImplementation(*this).SetScreenToFrameBufferMappingActor( actorImpl );
151 }
152
153 Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const
154 {
155   return Dali::Actor(GetImplementation(*this).GetScreenToFrameBufferMappingActor());
156 }
157
158 void RenderTask::SetViewportPosition( Vector2 position )
159 {
160   GetImplementation(*this).SetViewportPosition( position );
161 }
162
163 Vector2 RenderTask::GetCurrentViewportPosition() const
164 {
165   return GetImplementation(*this).GetCurrentViewportPosition();
166 }
167
168 void RenderTask::SetViewportSize( Vector2 size )
169 {
170   GetImplementation(*this).SetViewportSize( size );
171 }
172
173 Vector2 RenderTask::GetCurrentViewportSize() const
174 {
175   return GetImplementation(*this).GetCurrentViewportSize();
176 }
177
178 void RenderTask::SetViewport( Viewport viewport )
179 {
180   GetImplementation(*this).SetViewport( viewport );
181 }
182
183 Viewport RenderTask::GetViewport() const
184 {
185   Viewport result;
186   GetImplementation(*this).GetViewport( result );
187   return result;
188 }
189
190 void RenderTask::SetClearColor( const Vector4& color )
191 {
192   GetImplementation(*this).SetClearColor( color );
193 }
194
195 Vector4 RenderTask::GetClearColor() const
196 {
197   return GetImplementation(*this).GetClearColor();
198 }
199
200 void RenderTask::SetClearEnabled( bool enabled )
201 {
202   GetImplementation(*this).SetClearEnabled( enabled );
203 }
204
205 bool RenderTask::GetClearEnabled() const
206 {
207   return GetImplementation(*this).GetClearEnabled();
208 }
209
210 void RenderTask::SetCullMode( bool mode )
211 {
212   GetImplementation(*this).SetCullMode( mode );
213 }
214
215 bool RenderTask::GetCullMode() const
216 {
217   return GetImplementation(*this).GetCullMode();
218 }
219
220 void RenderTask::SetRefreshRate( unsigned int refreshRate )
221 {
222   GetImplementation(*this).SetRefreshRate( refreshRate );
223 }
224
225 unsigned int RenderTask::GetRefreshRate() const
226 {
227   return GetImplementation(*this).GetRefreshRate();
228 }
229
230 RenderTask::RenderTaskSignalType& RenderTask::FinishedSignal()
231 {
232   return GetImplementation(*this).FinishedSignal();
233 }
234
235 void RenderTask::SetInputEnabled( bool enabled )
236 {
237   GetImplementation(*this).SetInputEnabled( enabled );
238 }
239
240 bool RenderTask::GetInputEnabled() const
241 {
242   return GetImplementation(*this).GetInputEnabled();
243 }
244
245 RenderTask::RenderTask( Internal::RenderTask* internal )
246 : Constrainable(internal)
247 {
248 }
249
250 } // namespace Dali