2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 using System.Runtime.InteropServices;
23 /// TextureSet is a handle to an object that specifies the set of images used as textures by a renderer.<br />
24 /// The images have to be ordered in the same order they are declared in the shader.
26 /// <since_tizen> 3 </since_tizen>
27 public class TextureSet : BaseHandle
29 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
31 internal TextureSet(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.TextureSet_SWIGUpcast(cPtr), cMemoryOwn)
33 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
36 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextureSet obj)
38 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
44 /// <since_tizen> 3 </since_tizen>
45 protected override void Dispose(DisposeTypes type)
52 if (type == DisposeTypes.Explicit)
55 //Release your own managed resources here.
56 //You should release all of your own disposable objects here.
60 //Release your own unmanaged resources here.
61 //You should not access any managed member here except static instance.
62 //because the execution order of Finalizes is non-deterministic.
64 if (swigCPtr.Handle != global::System.IntPtr.Zero)
69 NDalicPINVOKE.delete_TextureSet(swigCPtr);
71 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
78 /// Create an instance of TextureSet.
80 /// <since_tizen> 3 </since_tizen>
81 public TextureSet() : this(NDalicPINVOKE.TextureSet_New(), true)
83 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
88 /// Sets the texture at position "index".
90 /// <param name="index">The position in the texture set of the texture.</param>
91 /// <param name="texture">The texture.</param>
92 /// <since_tizen> 3 </since_tizen>
93 public void SetTexture(uint index, Texture texture)
95 NDalicPINVOKE.TextureSet_SetTexture(swigCPtr, index, Texture.getCPtr(texture));
96 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
100 /// Gets the image at position "index".
102 /// <param name="index">The position in the texture set of the image.</param>
103 /// <returns>A handle to the image at the the specified position.</returns>
104 /// <since_tizen> 3 </since_tizen>
105 public Texture GetTexture(uint index)
107 //to fix memory leak issue, match the handle count with native side.
108 System.IntPtr cPtr = NDalicPINVOKE.TextureSet_GetTexture(swigCPtr, index);
109 HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
110 Texture ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as Texture;
111 NDalicPINVOKE.delete_BaseHandle(CPtr);
112 CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
114 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
119 /// Sets the sampler to be used by the image at position "index".
121 /// <param name="index">The position in the texture set of the image.</param>
122 /// <param name="sampler">The sampler to use.</param>
123 /// <since_tizen> 3 </since_tizen>
124 public void SetSampler(uint index, Sampler sampler)
126 NDalicPINVOKE.TextureSet_SetSampler(swigCPtr, index, Sampler.getCPtr(sampler));
127 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131 /// Sets the sampler to be used by the image at position "index".
133 /// <param name="index">The position in the texture set of the image.</param>
134 /// <returns>A handle to the sampler at the specified position.</returns>
135 /// <since_tizen> 3 </since_tizen>
136 public Sampler GetSampler(uint index)
138 //to fix memory leak issue, match the handle count with native side.
139 System.IntPtr cPtr = NDalicPINVOKE.TextureSet_GetSampler(swigCPtr, index);
140 HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
141 Sampler ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as Sampler;
142 NDalicPINVOKE.delete_BaseHandle(CPtr);
143 CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
145 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
150 /// Gets the number of textures present in the TextureSet.
152 /// <returns>The number of textures in the TextureSet.</returns>
153 /// <since_tizen> 3 </since_tizen>
154 public uint GetTextureCount()
156 uint ret = NDalicPINVOKE.TextureSet_GetTextureCount(swigCPtr);
157 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();