5cec963bd7e8cd10251f13800757c934cea19ca5
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / TextureSet.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
18 namespace Tizen.NUI
19 {
20     /// <summary>
21     /// TextureSet is a handle to an object that specifies the set of images used as textures by a renderer.<br />
22     /// The images have to be ordered in the same order they are declared in the shader.
23     /// </summary>
24     public class TextureSet : BaseHandle
25     {
26         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
27
28         internal TextureSet(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.TextureSet_SWIGUpcast(cPtr), cMemoryOwn)
29         {
30             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
31         }
32
33         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextureSet obj)
34         {
35             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
36         }
37
38         /// <summary>
39         /// Dispose.
40         /// </summary>
41         /// <since_tizen> 3 </since_tizen>
42         protected override void Dispose(DisposeTypes type)
43         {
44             if (disposed)
45             {
46                 return;
47             }
48
49             if (type == DisposeTypes.Explicit)
50             {
51                 //Called by User
52                 //Release your own managed resources here.
53                 //You should release all of your own disposable objects here.
54
55             }
56
57             //Release your own unmanaged resources here.
58             //You should not access any managed member here except static instance.
59             //because the execution order of Finalizes is non-deterministic.
60
61             if (swigCPtr.Handle != global::System.IntPtr.Zero)
62             {
63                 if (swigCMemOwn)
64                 {
65                     swigCMemOwn = false;
66                     NDalicPINVOKE.delete_TextureSet(swigCPtr);
67                 }
68                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
69             }
70
71             base.Dispose(type);
72         }
73
74         /// <summary>
75         /// Create an instance of TextureSet.
76         /// </summary>
77         /// <since_tizen> 3 </since_tizen>
78         public TextureSet() : this(NDalicPINVOKE.TextureSet_New(), true)
79         {
80             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81
82         }
83
84         /// <summary>
85         /// Sets the texture at position "index".
86         /// </summary>
87         /// <param name="index">The position in the texture set of the texture.</param>
88         /// <param name="texture">The texture.</param>
89         /// <since_tizen> 3 </since_tizen>
90         public void SetTexture(uint index, Texture texture)
91         {
92             NDalicPINVOKE.TextureSet_SetTexture(swigCPtr, index, Texture.getCPtr(texture));
93             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
94         }
95
96         /// <summary>
97         /// Gets the image at position "index".
98         /// </summary>
99         /// <param name="index">The position in the texture set of the image.</param>
100         /// <returns>A handle to the image at the the specified position.</returns>
101         /// <since_tizen> 3 </since_tizen>
102         public Texture GetTexture(uint index)
103         {
104             System.IntPtr cPtr = NDalicPINVOKE.TextureSet_GetTexture(swigCPtr, index);
105             Texture ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Texture;
106
107             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
108             return ret;
109         }
110
111         /// <summary>
112         /// Sets the sampler to be used by the image at position "index".
113         /// </summary>
114         /// <param name="index">The position in the texture set of the image.</param>
115         /// <param name="sampler">The sampler to use.</param>
116         /// <since_tizen> 3 </since_tizen>
117         public void SetSampler(uint index, Sampler sampler)
118         {
119             NDalicPINVOKE.TextureSet_SetSampler(swigCPtr, index, Sampler.getCPtr(sampler));
120             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
121         }
122
123         /// <summary>
124         /// Sets the sampler to be used by the image at position "index".
125         /// </summary>
126         /// <param name="index">The position in the texture set of the image.</param>
127         /// <returns>A handle to the sampler at the specified position.</returns>
128         /// <since_tizen> 3 </since_tizen>
129         public Sampler GetSampler(uint index)
130         {
131             System.IntPtr cPtr = NDalicPINVOKE.TextureSet_GetSampler(swigCPtr, index);
132             Sampler ret = Registry.GetManagedBaseHandleFromNativePtr(cPtr) as Sampler;
133
134             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135             return ret;
136         }
137
138         /// <summary>
139         /// Gets the number of textures present in the TextureSet.
140         /// </summary>
141         /// <returns>The number of textures in the TextureSet.</returns>
142         /// <since_tizen> 3 </since_tizen>
143         public uint GetTextureCount()
144         {
145             uint ret = NDalicPINVOKE.TextureSet_GetTextureCount(swigCPtr);
146             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
147             return ret;
148         }
149
150     }
151
152 }