Remove FrameBufferImage
[platform/core/uifw/dali-core.git] / dali / public-api / render-tasks / render-task.cpp
1 /*
2  * Copyright (c) 2020 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/public-api/rendering/frame-buffer.h>
24 #include <dali/internal/event/actors/actor-impl.h>
25 #include <dali/internal/event/actors/camera-actor-impl.h>
26 #include <dali/internal/event/render-tasks/render-task-impl.h>
27
28 namespace Dali
29 {
30
31 static bool DefaultScreenToFrameBufferFunction( Vector2& coordinates )
32 {
33   return false;
34 }
35
36 static bool FullScreenFrameBufferFunction( Vector2& coordinates )
37 {
38   // Don't need to modify frameBufferCoords
39   return true;
40 }
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 bool     RenderTask::DEFAULT_CULL_MODE     = true;
50 const uint32_t 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 RenderTask::RenderTask(const RenderTask& handle)
66 : Handle(handle)
67 {
68 }
69
70 RenderTask& RenderTask::operator=(const RenderTask& rhs)
71 {
72   BaseHandle::operator=(rhs);
73   return *this;
74 }
75
76 void RenderTask::SetSourceActor( Actor actor )
77 {
78   // NULL handle is allowed
79   Internal::Actor* actorImpl( NULL );
80   if ( actor )
81   {
82     actorImpl = &GetImplementation( actor );
83   }
84
85   GetImplementation(*this).SetSourceActor( actorImpl );
86 }
87
88 Actor RenderTask::GetSourceActor() const
89 {
90   return Dali::Actor(GetImplementation(*this).GetSourceActor());
91 }
92
93 void RenderTask::SetExclusive( bool exclusive )
94 {
95   GetImplementation(*this).SetExclusive( exclusive );
96 }
97
98 bool RenderTask::IsExclusive() const
99 {
100   return GetImplementation(*this).IsExclusive();
101 }
102
103 void RenderTask::SetCameraActor( CameraActor cameraActor )
104 {
105   // NULL handle is allowed
106   Internal::CameraActor* actorImpl( NULL );
107   if ( cameraActor )
108   {
109     actorImpl = &GetImplementation( cameraActor );
110   }
111
112   GetImplementation(*this).SetCameraActor( actorImpl );
113 }
114
115 CameraActor RenderTask::GetCameraActor() const
116 {
117   return Dali::CameraActor(GetImplementation(*this).GetCameraActor());
118 }
119
120 void RenderTask::SetFrameBuffer( FrameBuffer frameBuffer )
121 {
122   Internal::FrameBuffer* frameBufferPtr( NULL );
123   if( frameBuffer )
124   {
125     frameBufferPtr = &GetImplementation( frameBuffer );
126   }
127
128   GetImplementation(*this).SetFrameBuffer( frameBufferPtr );
129 }
130
131 FrameBuffer RenderTask::GetFrameBuffer() const
132 {
133   Internal::FrameBuffer* frameBufferPtr( GetImplementation(*this).GetFrameBuffer() );
134   return FrameBuffer( frameBufferPtr );
135 }
136
137 void RenderTask::SetScreenToFrameBufferFunction( ScreenToFrameBufferFunction conversionFunction )
138 {
139   GetImplementation(*this).SetScreenToFrameBufferFunction( conversionFunction );
140 }
141
142 RenderTask::ScreenToFrameBufferFunction RenderTask::GetScreenToFrameBufferFunction() const
143 {
144   return GetImplementation(*this).GetScreenToFrameBufferFunction();
145 }
146
147 void RenderTask::SetScreenToFrameBufferMappingActor( Dali::Actor mappingActor )
148 {
149   GetImplementation(*this).SetScreenToFrameBufferMappingActor( mappingActor );
150 }
151
152 Dali::Actor RenderTask::GetScreenToFrameBufferMappingActor() const
153 {
154   return GetImplementation(*this).GetScreenToFrameBufferMappingActor();
155 }
156
157 void RenderTask::SetViewportPosition( Vector2 position )
158 {
159   GetImplementation(*this).SetViewportPosition( position );
160 }
161
162 Vector2 RenderTask::GetCurrentViewportPosition() const
163 {
164   return GetImplementation(*this).GetCurrentViewportPosition();
165 }
166
167 void RenderTask::SetViewportSize( Vector2 size )
168 {
169   GetImplementation(*this).SetViewportSize( size );
170 }
171
172 Vector2 RenderTask::GetCurrentViewportSize() const
173 {
174   return GetImplementation(*this).GetCurrentViewportSize();
175 }
176
177 void RenderTask::SetViewport( Viewport viewport )
178 {
179   GetImplementation(*this).SetViewport( viewport );
180 }
181
182 Viewport RenderTask::GetViewport() const
183 {
184   Viewport result;
185   GetImplementation(*this).GetViewport( result );
186   return result;
187 }
188
189 void RenderTask::SetClearColor( const Vector4& color )
190 {
191   GetImplementation(*this).SetClearColor( color );
192 }
193
194 Vector4 RenderTask::GetClearColor() const
195 {
196   return GetImplementation(*this).GetClearColor();
197 }
198
199 void RenderTask::SetClearEnabled( bool enabled )
200 {
201   GetImplementation(*this).SetClearEnabled( enabled );
202 }
203
204 bool RenderTask::GetClearEnabled() const
205 {
206   return GetImplementation(*this).GetClearEnabled();
207 }
208
209 void RenderTask::SetCullMode( bool mode )
210 {
211   GetImplementation(*this).SetCullMode( mode );
212 }
213
214 bool RenderTask::GetCullMode() const
215 {
216   return GetImplementation(*this).GetCullMode();
217 }
218
219 void RenderTask::SetRefreshRate( uint32_t refreshRate )
220 {
221   GetImplementation(*this).SetRefreshRate( refreshRate );
222 }
223
224 uint32_t RenderTask::GetRefreshRate() const
225 {
226   return GetImplementation(*this).GetRefreshRate();
227 }
228
229 RenderTask::RenderTaskSignalType& RenderTask::FinishedSignal()
230 {
231   return GetImplementation(*this).FinishedSignal();
232 }
233
234 void RenderTask::SetInputEnabled( bool enabled )
235 {
236   GetImplementation(*this).SetInputEnabled( enabled );
237 }
238
239 bool RenderTask::GetInputEnabled() const
240 {
241   return GetImplementation(*this).GetInputEnabled();
242 }
243
244 bool RenderTask::WorldToViewport(const Vector3 &position, float& viewportX, float& viewportY) const
245 {
246   return GetImplementation(*this).WorldToViewport(position, viewportX, viewportY);
247 }
248
249 bool RenderTask::ViewportToLocal(Actor actor, float viewportX, float viewportY, float &localX, float &localY) const
250 {
251   if( actor )
252   {
253     Internal::Actor* actorImpl( &GetImplementation( actor ) );
254     return GetImplementation(*this).ViewportToLocal( actorImpl, viewportX, viewportY, localX, localY );
255   }
256   else
257   {
258     return false;
259   }
260 }
261
262
263 RenderTask::RenderTask( Internal::RenderTask* internal )
264 : Handle(internal)
265 {
266 }
267
268 } // namespace Dali