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