Revert "License conversion from Flora to Apache 2.0"
[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 Flora License, Version 1.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://floralicense.org/license/
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 // CLASS HEADER
18 #include <dali/public-api/render-tasks/render-task.h>
19
20 // INTERNAL INCLUDES
21 #include <dali/public-api/common/constants.h>
22 #include <dali/internal/event/actors/actor-impl.h>
23 #include <dali/internal/event/actors/camera-actor-impl.h>
24 #include <dali/internal/event/render-tasks/render-task-impl.h>
25
26 namespace Dali
27 {
28
29 static bool DefaultScreenToFrameBufferFunction( Vector2& coordinates )
30 {
31   return false;
32 }
33
34 static bool FullScreenFrameBufferFunction( Vector2& coordinates )
35 {
36   // Don't need to modify frameBufferCoords
37   return true;
38 }
39
40 const char* const RenderTask::SIGNAL_FINISHED = "finished";
41
42 RenderTask::ConstScreenToFrameBufferFunction RenderTask::DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION = DefaultScreenToFrameBufferFunction;
43 RenderTask::ConstScreenToFrameBufferFunction RenderTask::FULLSCREEN_FRAMEBUFFER_FUNCTION        = FullScreenFrameBufferFunction;
44
45 const bool         RenderTask::DEFAULT_EXCLUSIVE     = false;
46 const bool         RenderTask::DEFAULT_INPUT_ENABLED = true;
47 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
48 const bool         RenderTask::DEFAULT_CLEAR_ENABLED = false;
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 void RenderTask::SetSourceActor( Actor actor )
65 {
66   // NULL handle is allowed
67   Internal::Actor* actorImpl( NULL );
68   if ( actor )
69   {
70     actorImpl = &GetImplementation( actor );
71   }
72
73   GetImplementation(*this).SetSourceActor( actorImpl );
74 }
75
76 Actor RenderTask::GetSourceActor() const
77 {
78   return Dali::Actor(GetImplementation(*this).GetSourceActor());
79 }
80
81 void RenderTask::SetExclusive( bool exclusive )
82 {
83   GetImplementation(*this).SetExclusive( exclusive );
84 }
85
86 bool RenderTask::IsExclusive() const
87 {
88   return GetImplementation(*this).IsExclusive();
89 }
90
91 void RenderTask::SetCameraActor( CameraActor cameraActor )
92 {
93   // NULL handle is allowed
94   Internal::CameraActor* actorImpl( NULL );
95   if ( cameraActor )
96   {
97     actorImpl = &GetImplementation( cameraActor );
98   }
99
100   GetImplementation(*this).SetCameraActor( actorImpl );
101 }
102
103 CameraActor RenderTask::GetCameraActor() const
104 {
105   return Dali::CameraActor(GetImplementation(*this).GetCameraActor());
106 }
107
108 void RenderTask::SetTargetFrameBuffer( FrameBufferImage frameBuffer )
109 {
110   GetImplementation(*this).SetTargetFrameBuffer( frameBuffer );
111 }
112
113 FrameBufferImage RenderTask::GetTargetFrameBuffer() const
114 {
115   return GetImplementation(*this).GetTargetFrameBuffer();
116 }
117
118 void RenderTask::SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction )
119 {
120   GetImplementation(*this).SetScreenToFrameBufferFunction( conversionFunction );
121 }
122
123 RenderTask::ScreenToFrameBufferFunction RenderTask::GetScreenToFrameBufferFunction() const
124 {
125   return GetImplementation(*this).GetScreenToFrameBufferFunction();
126 }
127
128 void RenderTask::SetScreenToFrameBufferMappingActor( Dali::Actor mappingActor )
129 {
130   // NULL handle is allowed
131   Internal::Actor* actorImpl( NULL );
132   if ( mappingActor )
133   {
134     actorImpl = &GetImplementation( mappingActor );
135   }
136
137   GetImplementation(*this).SetScreenToFrameBufferMappingActor( actorImpl );
138 }
139
140 Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const
141 {
142   return Dali::Actor(GetImplementation(*this).GetScreenToFrameBufferMappingActor());
143 }
144
145 void RenderTask::SetViewportPosition( Vector2 position )
146 {
147   GetImplementation(*this).SetViewportPosition( position );
148 }
149
150 Vector2 RenderTask::GetCurrentViewportPosition() const
151 {
152   return GetImplementation(*this).GetCurrentViewportPosition();
153 }
154
155 void RenderTask::SetViewportSize( Vector2 size )
156 {
157   GetImplementation(*this).SetViewportSize( size );
158 }
159
160 Vector2 RenderTask::GetCurrentViewportSize() const
161 {
162   return GetImplementation(*this).GetCurrentViewportSize();
163 }
164
165 void RenderTask::SetViewport( Viewport viewport )
166 {
167   GetImplementation(*this).SetViewport( viewport );
168 }
169
170 Viewport RenderTask::GetViewport() const
171 {
172   Viewport result;
173   GetImplementation(*this).GetViewport( result );
174   return result;
175 }
176
177 void RenderTask::SetClearColor( const Vector4& color )
178 {
179   GetImplementation(*this).SetClearColor( color );
180 }
181
182 Vector4 RenderTask::GetClearColor() const
183 {
184   return GetImplementation(*this).GetClearColor();
185 }
186
187 void RenderTask::SetClearEnabled( bool enabled )
188 {
189   GetImplementation(*this).SetClearEnabled( enabled );
190 }
191
192 bool RenderTask::GetClearEnabled() const
193 {
194   return GetImplementation(*this).GetClearEnabled();
195 }
196
197 void RenderTask::SetRefreshRate( unsigned int refreshRate )
198 {
199   GetImplementation(*this).SetRefreshRate( refreshRate );
200 }
201
202 unsigned int RenderTask::GetRefreshRate() const
203 {
204   return GetImplementation(*this).GetRefreshRate();
205 }
206
207 RenderTask::RenderTaskSignalV2& RenderTask::FinishedSignal()
208 {
209   return GetImplementation(*this).FinishedSignal();
210 }
211
212 void RenderTask::SetInputEnabled( bool enabled )
213 {
214   GetImplementation(*this).SetInputEnabled( enabled );
215 }
216
217 bool RenderTask::GetInputEnabled() const
218 {
219   return GetImplementation(*this).GetInputEnabled();
220 }
221
222 RenderTask::RenderTask( Internal::RenderTask* internal )
223 : Constrainable(internal)
224 {
225 }
226
227 } // namespace Dali
228