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