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