[dali_1.0.39] Merge branch 'tizen'
[platform/core/uifw/dali-core.git] / dali / public-api / render-tasks / render-task.cpp
1 /*
2  * Copyright (c) 2015 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 RenderTask::ConstScreenToFrameBufferFunction RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION = DefaultScreenToFrameBufferFunction;
42 RenderTask::ConstScreenToFrameBufferFunction RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION        = FullScreenFrameBufferFunction;
43
44 const bool         RenderTask::DEFAULT_EXCLUSIVE     = false;
45 const bool         RenderTask::DEFAULT_INPUT_ENABLED = true;
46 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
47 const bool         RenderTask::DEFAULT_CLEAR_ENABLED = false;
48 const bool         RenderTask::DEFAULT_CULL_MODE     = true;
49 const unsigned int RenderTask::DEFAULT_REFRESH_RATE  = REFRESH_ALWAYS;
50
51 RenderTask::RenderTask()
52 {
53 }
54
55 RenderTask RenderTask::DownCast( BaseHandle handle )
56 {
57   return RenderTask( dynamic_cast<Dali::Internal::RenderTask*>( handle.GetObjectPtr() ) );
58 }
59
60 RenderTask::~RenderTask()
61 {
62 }
63
64 RenderTask::RenderTask(const RenderTask& handle)
65 : Handle(handle)
66 {
67 }
68
69 RenderTask& RenderTask::operator=(const RenderTask& rhs)
70 {
71   BaseHandle::operator=(rhs);
72   return *this;
73 }
74
75 void RenderTask::SetSourceActor( Actor actor )
76 {
77   // NULL handle is allowed
78   Internal::Actor* actorImpl( NULL );
79   if ( actor )
80   {
81     actorImpl = &GetImplementation( actor );
82   }
83
84   GetImplementation(*this).SetSourceActor( actorImpl );
85 }
86
87 Actor RenderTask::GetSourceActor() const
88 {
89   return Dali::Actor(GetImplementation(*this).GetSourceActor());
90 }
91
92 void RenderTask::SetExclusive( bool exclusive )
93 {
94   GetImplementation(*this).SetExclusive( exclusive );
95 }
96
97 bool RenderTask::IsExclusive() const
98 {
99   return GetImplementation(*this).IsExclusive();
100 }
101
102 void RenderTask::SetCameraActor( CameraActor cameraActor )
103 {
104   // NULL handle is allowed
105   Internal::CameraActor* actorImpl( NULL );
106   if ( cameraActor )
107   {
108     actorImpl = &GetImplementation( cameraActor );
109   }
110
111   GetImplementation(*this).SetCameraActor( actorImpl );
112 }
113
114 CameraActor RenderTask::GetCameraActor() const
115 {
116   return Dali::CameraActor(GetImplementation(*this).GetCameraActor());
117 }
118
119 void RenderTask::SetTargetFrameBuffer( FrameBufferImage frameBuffer )
120 {
121   GetImplementation(*this).SetTargetFrameBuffer( frameBuffer );
122 }
123
124 FrameBufferImage RenderTask::GetTargetFrameBuffer() const
125 {
126   return GetImplementation(*this).GetTargetFrameBuffer();
127 }
128
129 void RenderTask::SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction )
130 {
131   GetImplementation(*this).SetScreenToFrameBufferFunction( conversionFunction );
132 }
133
134 RenderTask::ScreenToFrameBufferFunction RenderTask::GetScreenToFrameBufferFunction() const
135 {
136   return GetImplementation(*this).GetScreenToFrameBufferFunction();
137 }
138
139 void RenderTask::SetScreenToFrameBufferMappingActor( Dali::Actor mappingActor )
140 {
141   // NULL handle is allowed
142   Internal::Actor* actorImpl( NULL );
143   if ( mappingActor )
144   {
145     actorImpl = &GetImplementation( mappingActor );
146   }
147
148   GetImplementation(*this).SetScreenToFrameBufferMappingActor( actorImpl );
149 }
150
151 Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const
152 {
153   return Dali::Actor(GetImplementation(*this).GetScreenToFrameBufferMappingActor());
154 }
155
156 void RenderTask::SetViewportPosition( Vector2 position )
157 {
158   GetImplementation(*this).SetViewportPosition( position );
159 }
160
161 Vector2 RenderTask::GetCurrentViewportPosition() const
162 {
163   return GetImplementation(*this).GetCurrentViewportPosition();
164 }
165
166 void RenderTask::SetViewportSize( Vector2 size )
167 {
168   GetImplementation(*this).SetViewportSize( size );
169 }
170
171 Vector2 RenderTask::GetCurrentViewportSize() const
172 {
173   return GetImplementation(*this).GetCurrentViewportSize();
174 }
175
176 void RenderTask::SetViewport( Viewport viewport )
177 {
178   GetImplementation(*this).SetViewport( viewport );
179 }
180
181 Viewport RenderTask::GetViewport() const
182 {
183   Viewport result;
184   GetImplementation(*this).GetViewport( result );
185   return result;
186 }
187
188 void RenderTask::SetClearColor( const Vector4& color )
189 {
190   GetImplementation(*this).SetClearColor( color );
191 }
192
193 Vector4 RenderTask::GetClearColor() const
194 {
195   return GetImplementation(*this).GetClearColor();
196 }
197
198 void RenderTask::SetClearEnabled( bool enabled )
199 {
200   GetImplementation(*this).SetClearEnabled( enabled );
201 }
202
203 bool RenderTask::GetClearEnabled() const
204 {
205   return GetImplementation(*this).GetClearEnabled();
206 }
207
208 void RenderTask::SetCullMode( bool mode )
209 {
210   GetImplementation(*this).SetCullMode( mode );
211 }
212
213 bool RenderTask::GetCullMode() const
214 {
215   return GetImplementation(*this).GetCullMode();
216 }
217
218 void RenderTask::SetRefreshRate( unsigned int refreshRate )
219 {
220   GetImplementation(*this).SetRefreshRate( refreshRate );
221 }
222
223 unsigned int RenderTask::GetRefreshRate() const
224 {
225   return GetImplementation(*this).GetRefreshRate();
226 }
227
228 RenderTask::RenderTaskSignalType& RenderTask::FinishedSignal()
229 {
230   return GetImplementation(*this).FinishedSignal();
231 }
232
233 void RenderTask::SetInputEnabled( bool enabled )
234 {
235   GetImplementation(*this).SetInputEnabled( enabled );
236 }
237
238 bool RenderTask::GetInputEnabled() const
239 {
240   return GetImplementation(*this).GetInputEnabled();
241 }
242
243 RenderTask::RenderTask( Internal::RenderTask* internal )
244 : Handle(internal)
245 {
246 }
247
248 } // namespace Dali