[NUI] Refactor dispose pattern to reduce duplication (#1112)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Shader.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 System;
18 using System.ComponentModel;
19
20 namespace Tizen.NUI
21 {
22     /// <summary>
23     /// Shader.
24     /// </summary>
25     /// <since_tizen> 3 </since_tizen>
26     public class Shader : Animatable
27     {
28
29         /// <summary>
30         /// Creates Shader object.
31         /// </summary>
32         /// <param name="vertexShader">The vertex shader code for the effect.</param>
33         /// <param name="fragmentShader">The fragment Shader code for the effect.</param>
34         /// <param name="hints">The hints to define the geometry of the rendered object.</param>
35         /// <since_tizen> 3 </since_tizen>
36         public Shader(string vertexShader, string fragmentShader, Shader.Hint.Value hints) : this(Interop.Shader.Shader_New__SWIG_0(vertexShader, fragmentShader, (int)hints), true)
37         {
38             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
39         }
40
41         /// <summary>
42         /// Creates Shader object.
43         /// </summary>
44         /// <param name="vertexShader">The vertex shader code for the effect.</param>
45         /// <param name="fragmentShader">The fragment Shader code for the effect.</param>
46         /// <since_tizen> 3 </since_tizen>
47         public Shader(string vertexShader, string fragmentShader) : this(Interop.Shader.Shader_New__SWIG_1(vertexShader, fragmentShader), true)
48         {
49             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
50         }
51
52         /// <summary>
53         /// Gets and Sets the program property.
54         /// </summary>
55         /// <since_tizen> 3 </since_tizen>
56         public Tizen.NUI.PropertyMap Program
57         {
58             get
59             {
60                 Tizen.NUI.PropertyMap temp = new Tizen.NUI.PropertyMap();
61                 Tizen.NUI.Object.GetProperty(swigCPtr, Shader.Property.PROGRAM).Get(temp);
62                 return temp;
63             }
64             set
65             {
66                 Tizen.NUI.Object.SetProperty(swigCPtr, Shader.Property.PROGRAM, new Tizen.NUI.PropertyValue(value));
67             }
68         }
69
70         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Shader obj)
71         {
72             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
73         }
74
75         internal Shader(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Shader.Shader_SWIGUpcast(cPtr), cMemoryOwn)
76         {
77         }
78
79         /// This will not be public opened.
80         [EditorBrowsable(EditorBrowsableState.Never)]
81         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
82         {
83             Interop.Shader.delete_Shader(swigCPtr);
84         }
85
86         /// <summary>
87         /// Hint.
88         /// </summary>
89         /// <since_tizen> 3 </since_tizen>
90         public class Hint
91         {
92             /// <summary>
93             /// Enumeration for the hint value.
94             /// </summary>
95             /// <since_tizen> 3 </since_tizen>
96             public enum Value
97             {
98                 /// <summary>
99                 /// No hints.
100                 /// </summary>
101                 /// <since_tizen> 3 </since_tizen>
102                 NONE = 0x00,
103
104                 /// <summary>
105                 /// Might generate transparent alpha from opaque inputs
106                 /// </summary>
107                 /// <since_tizen> 3 </since_tizen>
108                 OUTPUT_IS_TRANSPARENT = 0x01,
109
110                 /// <summary>
111                 /// Might change position of vertices, this option disables any culling optimizations
112                 /// </summary>
113                 /// <since_tizen> 3 </since_tizen>
114                 MODIFIES_GEOMETRY = 0x02
115             }
116         }
117
118         /// <summary>
119         /// Enumeration for instances of properties belonging to the Shader class.
120         /// </summary>
121         /// <since_tizen> 3 </since_tizen>
122         [EditorBrowsable(EditorBrowsableState.Never)]
123         [Obsolete("Deprecated in API6; Will be removed in API9.")]
124         public class Property
125         {
126             /// <summary>
127             /// The default value is empty.
128             /// Format: {"vertex":"","fragment":"",hints:"","vertexPrefix":"","fragmentPrefix":""}
129             /// </summary>
130             /// <since_tizen> 3 </since_tizen>
131             [EditorBrowsable(EditorBrowsableState.Never)]
132             [Obsolete("Deprecated in API6; Will be removed in API9.")]
133             public static readonly int PROGRAM = Interop.Shader.Shader_Property_PROGRAM_get();
134         }
135     }
136 }