Implemented the Handle assignment operators properly
[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 RenderTask& RenderTask::operator=(BaseHandle::NullType* rhs)
78 {
79   DALI_ASSERT_ALWAYS( (rhs == NULL) && "Can only assign NULL pointer to handle");
80   Reset();
81   return *this;
82 }
83
84 void RenderTask::SetSourceActor( Actor actor )
85 {
86   // NULL handle is allowed
87   Internal::Actor* actorImpl( NULL );
88   if ( actor )
89   {
90     actorImpl = &GetImplementation( actor );
91   }
92
93   GetImplementation(*this).SetSourceActor( actorImpl );
94 }
95
96 Actor RenderTask::GetSourceActor() const
97 {
98   return Dali::Actor(GetImplementation(*this).GetSourceActor());
99 }
100
101 void RenderTask::SetExclusive( bool exclusive )
102 {
103   GetImplementation(*this).SetExclusive( exclusive );
104 }
105
106 bool RenderTask::IsExclusive() const
107 {
108   return GetImplementation(*this).IsExclusive();
109 }
110
111 void RenderTask::SetCameraActor( CameraActor cameraActor )
112 {
113   // NULL handle is allowed
114   Internal::CameraActor* actorImpl( NULL );
115   if ( cameraActor )
116   {
117     actorImpl = &GetImplementation( cameraActor );
118   }
119
120   GetImplementation(*this).SetCameraActor( actorImpl );
121 }
122
123 CameraActor RenderTask::GetCameraActor() const
124 {
125   return Dali::CameraActor(GetImplementation(*this).GetCameraActor());
126 }
127
128 void RenderTask::SetTargetFrameBuffer( FrameBufferImage frameBuffer )
129 {
130   GetImplementation(*this).SetTargetFrameBuffer( frameBuffer );
131 }
132
133 FrameBufferImage RenderTask::GetTargetFrameBuffer() const
134 {
135   return GetImplementation(*this).GetTargetFrameBuffer();
136 }
137
138 void RenderTask::SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction )
139 {
140   GetImplementation(*this).SetScreenToFrameBufferFunction( conversionFunction );
141 }
142
143 RenderTask::ScreenToFrameBufferFunction RenderTask::GetScreenToFrameBufferFunction() const
144 {
145   return GetImplementation(*this).GetScreenToFrameBufferFunction();
146 }
147
148 void RenderTask::SetScreenToFrameBufferMappingActor( Dali::Actor mappingActor )
149 {
150   // NULL handle is allowed
151   Internal::Actor* actorImpl( NULL );
152   if ( mappingActor )
153   {
154     actorImpl = &GetImplementation( mappingActor );
155   }
156
157   GetImplementation(*this).SetScreenToFrameBufferMappingActor( actorImpl );
158 }
159
160 Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const
161 {
162   return Dali::Actor(GetImplementation(*this).GetScreenToFrameBufferMappingActor());
163 }
164
165 void RenderTask::SetViewportPosition( Vector2 position )
166 {
167   GetImplementation(*this).SetViewportPosition( position );
168 }
169
170 Vector2 RenderTask::GetCurrentViewportPosition() const
171 {
172   return GetImplementation(*this).GetCurrentViewportPosition();
173 }
174
175 void RenderTask::SetViewportSize( Vector2 size )
176 {
177   GetImplementation(*this).SetViewportSize( size );
178 }
179
180 Vector2 RenderTask::GetCurrentViewportSize() const
181 {
182   return GetImplementation(*this).GetCurrentViewportSize();
183 }
184
185 void RenderTask::SetViewport( Viewport viewport )
186 {
187   GetImplementation(*this).SetViewport( viewport );
188 }
189
190 Viewport RenderTask::GetViewport() const
191 {
192   Viewport result;
193   GetImplementation(*this).GetViewport( result );
194   return result;
195 }
196
197 void RenderTask::SetClearColor( const Vector4& color )
198 {
199   GetImplementation(*this).SetClearColor( color );
200 }
201
202 Vector4 RenderTask::GetClearColor() const
203 {
204   return GetImplementation(*this).GetClearColor();
205 }
206
207 void RenderTask::SetClearEnabled( bool enabled )
208 {
209   GetImplementation(*this).SetClearEnabled( enabled );
210 }
211
212 bool RenderTask::GetClearEnabled() const
213 {
214   return GetImplementation(*this).GetClearEnabled();
215 }
216
217 void RenderTask::SetCullMode( bool mode )
218 {
219   GetImplementation(*this).SetCullMode( mode );
220 }
221
222 bool RenderTask::GetCullMode() const
223 {
224   return GetImplementation(*this).GetCullMode();
225 }
226
227 void RenderTask::SetRefreshRate( unsigned int refreshRate )
228 {
229   GetImplementation(*this).SetRefreshRate( refreshRate );
230 }
231
232 unsigned int RenderTask::GetRefreshRate() const
233 {
234   return GetImplementation(*this).GetRefreshRate();
235 }
236
237 RenderTask::RenderTaskSignalV2& RenderTask::FinishedSignal()
238 {
239   return GetImplementation(*this).FinishedSignal();
240 }
241
242 void RenderTask::SetInputEnabled( bool enabled )
243 {
244   GetImplementation(*this).SetInputEnabled( enabled );
245 }
246
247 bool RenderTask::GetInputEnabled() const
248 {
249   return GetImplementation(*this).GetInputEnabled();
250 }
251
252 RenderTask::RenderTask( Internal::RenderTask* internal )
253 : Constrainable(internal)
254 {
255 }
256
257 } // namespace Dali