[NUI] Refactor dispose pattern to reduce duplication (#1112)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / RenderTask.cs
1 /*
2  * Copyright(c) 2017 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 using Tizen.NUI.BaseComponents;
18
19 namespace Tizen.NUI
20 {
21     internal class RenderTask : Animatable
22     {
23
24         internal RenderTask(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.RenderTask.RenderTask_SWIGUpcast(cPtr), cMemoryOwn)
25         {
26         }
27
28         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(RenderTask obj)
29         {
30             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
31         }
32
33         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
34         {
35             Interop.RenderTask.delete_RenderTask(swigCPtr);
36         }
37
38
39         public static RenderTask GetRenderTaskFromPtr(global::System.IntPtr cPtr)
40         {
41             RenderTask ret = new RenderTask(cPtr, false);
42             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
43             return ret;
44         }
45
46         internal class Property
47         {
48             internal static readonly int VIEWPORT_POSITION = Interop.RenderTask.RenderTask_Property_VIEWPORT_POSITION_get();
49             internal static readonly int VIEWPORT_SIZE = Interop.RenderTask.RenderTask_Property_VIEWPORT_SIZE_get();
50             internal static readonly int CLEAR_COLOR = Interop.RenderTask.RenderTask_Property_CLEAR_COLOR_get();
51             internal static readonly int REQUIRES_SYNC = Interop.RenderTask.RenderTask_Property_REQUIRES_SYNC_get();
52         }
53
54         internal static SWIGTYPE_p_f_r_Dali__Vector2__bool DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION
55         {
56             get
57             {
58                 global::System.IntPtr cPtr = Interop.RenderTask.RenderTask_DEFAULT_SCREEN_TO_FRAMEBUFFER_FUNCTION_get();
59                 SWIGTYPE_p_f_r_Dali__Vector2__bool ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_f_r_Dali__Vector2__bool(cPtr, false);
60                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
61                 return ret;
62             }
63         }
64
65         internal static SWIGTYPE_p_f_r_Dali__Vector2__bool FULLSCREEN_FRAMEBUFFER_FUNCTION
66         {
67             get
68             {
69                 global::System.IntPtr cPtr = Interop.RenderTask.RenderTask_FULLSCREEN_FRAMEBUFFER_FUNCTION_get();
70                 SWIGTYPE_p_f_r_Dali__Vector2__bool ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_f_r_Dali__Vector2__bool(cPtr, false);
71                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
72                 return ret;
73             }
74         }
75
76         public static bool DEFAULT_EXCLUSIVE
77         {
78             get
79             {
80                 bool ret = Interop.RenderTask.RenderTask_DEFAULT_EXCLUSIVE_get();
81                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
82                 return ret;
83             }
84         }
85
86         public static bool DEFAULT_INPUT_ENABLED
87         {
88             get
89             {
90                 bool ret = Interop.RenderTask.RenderTask_DEFAULT_INPUT_ENABLED_get();
91                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
92                 return ret;
93             }
94         }
95
96         public static Vector4 DEFAULT_CLEAR_COLOR
97         {
98             get
99             {
100                 global::System.IntPtr cPtr = Interop.RenderTask.RenderTask_DEFAULT_CLEAR_COLOR_get();
101                 Vector4 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Vector4(cPtr, false);
102                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
103                 return ret;
104             }
105         }
106
107         public static bool DEFAULT_CLEAR_ENABLED
108         {
109             get
110             {
111                 bool ret = Interop.RenderTask.RenderTask_DEFAULT_CLEAR_ENABLED_get();
112                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
113                 return ret;
114             }
115         }
116
117         public static bool DEFAULT_CULL_MODE
118         {
119             get
120             {
121                 bool ret = Interop.RenderTask.RenderTask_DEFAULT_CULL_MODE_get();
122                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
123                 return ret;
124             }
125         }
126
127         public static uint DEFAULT_REFRESH_RATE
128         {
129             get
130             {
131                 uint ret = Interop.RenderTask.RenderTask_DEFAULT_REFRESH_RATE_get();
132                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
133                 return ret;
134             }
135         }
136
137         public RenderTask() : this(Interop.RenderTask.new_RenderTask__SWIG_0(), true)
138         {
139             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
140         }
141
142         public static RenderTask DownCast(BaseHandle handle)
143         {
144             RenderTask ret =  Registry.GetManagedBaseHandleFromNativePtr(handle) as RenderTask;
145             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
146             return ret;
147         }
148
149         public RenderTask(RenderTask handle) : this(Interop.RenderTask.new_RenderTask__SWIG_1(RenderTask.getCPtr(handle)), true)
150         {
151             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
152         }
153
154         public RenderTask Assign(RenderTask rhs)
155         {
156             RenderTask ret = new RenderTask(Interop.RenderTask.RenderTask_Assign(swigCPtr, RenderTask.getCPtr(rhs)), false);
157             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
158             return ret;
159         }
160
161         public void SetSourceView(View view)
162         {
163             Interop.RenderTask.RenderTask_SetSourceActor(swigCPtr, View.getCPtr(view));
164             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165         }
166
167         public View GetSourceView()
168         {
169             View ret = new View(Interop.RenderTask.RenderTask_GetSourceActor(swigCPtr), true);
170             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
171             return ret;
172         }
173
174         public void SetExclusive(bool exclusive)
175         {
176             Interop.RenderTask.RenderTask_SetExclusive(swigCPtr, exclusive);
177             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178         }
179
180         public bool IsExclusive()
181         {
182             bool ret = Interop.RenderTask.RenderTask_IsExclusive(swigCPtr);
183             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
184             return ret;
185         }
186
187         public void SetInputEnabled(bool enabled)
188         {
189             Interop.RenderTask.RenderTask_SetInputEnabled(swigCPtr, enabled);
190             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
191         }
192
193         public bool GetInputEnabled()
194         {
195             bool ret = Interop.RenderTask.RenderTask_GetInputEnabled(swigCPtr);
196             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
197             return ret;
198         }
199
200         internal void SetCamera(Camera camera)
201         {
202             Interop.RenderTask.RenderTask_SetCameraActor(swigCPtr, Camera.getCPtr(camera));
203             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
204         }
205
206         internal Camera GetCamera()
207         {
208             Camera ret = new Camera(Interop.RenderTask.RenderTask_GetCameraActor(swigCPtr), true);
209             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
210             return ret;
211         }
212
213         public void SetTargetFrameBuffer(FrameBufferImage frameBuffer)
214         {
215             Interop.RenderTask.RenderTask_SetTargetFrameBuffer(swigCPtr, FrameBufferImage.getCPtr(frameBuffer));
216             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
217         }
218
219         public FrameBufferImage GetTargetFrameBuffer()
220         {
221             FrameBufferImage ret = new FrameBufferImage(Interop.RenderTask.RenderTask_GetTargetFrameBuffer(swigCPtr), true);
222             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
223             return ret;
224         }
225
226         public void SetFrameBuffer(FrameBuffer frameBuffer)
227         {
228             Interop.RenderTask.RenderTask_SetFrameBuffer(swigCPtr, FrameBuffer.getCPtr(frameBuffer));
229             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230         }
231
232         public FrameBuffer GetFrameBuffer()
233         {
234             FrameBuffer ret = new FrameBuffer(Interop.RenderTask.RenderTask_GetFrameBuffer(swigCPtr), true);
235             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
236             return ret;
237         }
238
239         internal void SetScreenToFrameBufferFunction(SWIGTYPE_p_f_r_Dali__Vector2__bool conversionFunction)
240         {
241             Interop.RenderTask.RenderTask_SetScreenToFrameBufferFunction(swigCPtr, SWIGTYPE_p_f_r_Dali__Vector2__bool.getCPtr(conversionFunction));
242             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
243         }
244
245         internal SWIGTYPE_p_f_r_Dali__Vector2__bool GetScreenToFrameBufferFunction()
246         {
247             global::System.IntPtr cPtr = Interop.RenderTask.RenderTask_GetScreenToFrameBufferFunction(swigCPtr);
248             SWIGTYPE_p_f_r_Dali__Vector2__bool ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_f_r_Dali__Vector2__bool(cPtr, false);
249             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
250             return ret;
251         }
252
253         public void SetScreenToFrameBufferMappingView(View mappingView)
254         {
255             Interop.RenderTask.RenderTask_SetScreenToFrameBufferMappingActor(swigCPtr, View.getCPtr(mappingView));
256             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
257         }
258
259         public View GetScreenToFrameBufferMappingView()
260         {
261             View ret = new View(Interop.RenderTask.RenderTask_GetScreenToFrameBufferMappingActor(swigCPtr), true);
262             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
263             return ret;
264         }
265
266         public void SetViewportPosition(Vector2 position)
267         {
268             Interop.RenderTask.RenderTask_SetViewportPosition(swigCPtr, Vector2.getCPtr(position));
269             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
270         }
271
272         public Vector2 GetCurrentViewportPosition()
273         {
274             Vector2 ret = new Vector2(Interop.RenderTask.RenderTask_GetCurrentViewportPosition(swigCPtr), true);
275             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
276             return ret;
277         }
278
279         public void SetViewportSize(Vector2 size)
280         {
281             Interop.RenderTask.RenderTask_SetViewportSize(swigCPtr, Vector2.getCPtr(size));
282             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
283         }
284
285         public Vector2 GetCurrentViewportSize()
286         {
287             Vector2 ret = new Vector2(Interop.RenderTask.RenderTask_GetCurrentViewportSize(swigCPtr), true);
288             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
289             return ret;
290         }
291
292         public void SetViewport(Rectangle viewport)
293         {
294             Interop.RenderTask.RenderTask_SetViewport(swigCPtr, Rectangle.getCPtr(viewport));
295             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
296         }
297
298         public Rectangle GetViewport()
299         {
300             Rectangle ret = new Rectangle(Interop.RenderTask.RenderTask_GetViewport(swigCPtr), true);
301             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302             return ret;
303         }
304
305         public void SetClearColor(Vector4 color)
306         {
307             Interop.RenderTask.RenderTask_SetClearColor(swigCPtr, Vector4.getCPtr(color));
308             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309         }
310
311         public Vector4 GetClearColor()
312         {
313             Vector4 ret = new Vector4(Interop.RenderTask.RenderTask_GetClearColor(swigCPtr), true);
314             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
315             return ret;
316         }
317
318         public void SetClearEnabled(bool enabled)
319         {
320             Interop.RenderTask.RenderTask_SetClearEnabled(swigCPtr, enabled);
321             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
322         }
323
324         public bool GetClearEnabled()
325         {
326             bool ret = Interop.RenderTask.RenderTask_GetClearEnabled(swigCPtr);
327             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
328             return ret;
329         }
330
331         public void SetCullMode(bool cullMode)
332         {
333             Interop.RenderTask.RenderTask_SetCullMode(swigCPtr, cullMode);
334             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
335         }
336
337         public bool GetCullMode()
338         {
339             bool ret = Interop.RenderTask.RenderTask_GetCullMode(swigCPtr);
340             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
341             return ret;
342         }
343
344         public void SetRefreshRate(uint refreshRate)
345         {
346             Interop.RenderTask.RenderTask_SetRefreshRate(swigCPtr, refreshRate);
347             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
348         }
349
350         public uint GetRefreshRate()
351         {
352             uint ret = Interop.RenderTask.RenderTask_GetRefreshRate(swigCPtr);
353             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
354             return ret;
355         }
356
357         public bool WorldToViewport(Vector3 position, out float viewportX, out float viewportY)
358         {
359             bool ret = Interop.RenderTask.RenderTask_WorldToViewport(swigCPtr, Vector3.getCPtr(position), out viewportX, out viewportY);
360             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
361             return ret;
362         }
363
364         public bool ViewportToLocal(View view, float viewportX, float viewportY, out float localX, out float localY)
365         {
366             bool ret = Interop.RenderTask.RenderTask_ViewportToLocal(swigCPtr, View.getCPtr(view), viewportX, viewportY, out localX, out localY);
367             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
368             return ret;
369         }
370
371         internal RenderTaskSignal FinishedSignal()
372         {
373             RenderTaskSignal ret = new RenderTaskSignal(Interop.RenderTask.RenderTask_FinishedSignal(swigCPtr), false);
374             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
375             return ret;
376         }
377
378         /// <since_tizen> 3 </since_tizen>
379         public enum RefreshRate
380         {
381             REFRESH_ONCE = 0,
382             REFRESH_ALWAYS = 1
383         }
384
385         public Vector2 ViewportPosition
386         {
387             get
388             {
389                 Vector2 temp = new Vector2(0.0f, 0.0f);
390                 GetProperty(RenderTask.Property.VIEWPORT_POSITION).Get(temp);
391                 return temp;
392             }
393             set
394             {
395                 SetProperty(RenderTask.Property.VIEWPORT_POSITION, new Tizen.NUI.PropertyValue(value));
396             }
397         }
398         public Vector2 ViewportSize
399         {
400             get
401             {
402                 Vector2 temp = new Vector2(0.0f, 0.0f);
403                 GetProperty(RenderTask.Property.VIEWPORT_SIZE).Get(temp);
404                 return temp;
405             }
406             set
407             {
408                 SetProperty(RenderTask.Property.VIEWPORT_SIZE, new Tizen.NUI.PropertyValue(value));
409             }
410         }
411         public Vector4 ClearColor
412         {
413             get
414             {
415                 Vector4 temp = new Vector4(0.0f, 0.0f, 0.0f, 0.0f);
416                 GetProperty(RenderTask.Property.CLEAR_COLOR).Get(temp);
417                 return temp;
418             }
419             set
420             {
421                 SetProperty(RenderTask.Property.CLEAR_COLOR, new Tizen.NUI.PropertyValue(value));
422             }
423         }
424         public bool RequiresSync
425         {
426             get
427             {
428                 bool temp = false;
429                 GetProperty(RenderTask.Property.REQUIRES_SYNC).Get(out temp);
430                 return temp;
431             }
432             set
433             {
434                 SetProperty(RenderTask.Property.REQUIRES_SYNC, new Tizen.NUI.PropertyValue(value));
435             }
436         }
437     }
438 }