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