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