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;
32 /// Create an instance of TextureSet.
34 /// <since_tizen> 3 </since_tizen>
35 public TextureSet() : this(NDalicPINVOKE.TextureSet_New(), true)
37 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
41 internal TextureSet(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.TextureSet_SWIGUpcast(cPtr), cMemoryOwn)
43 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
47 /// Sets the texture at position "index".
49 /// <param name="index">The position in the texture set of the texture.</param>
50 /// <param name="texture">The texture.</param>
51 /// <since_tizen> 3 </since_tizen>
52 public void SetTexture(uint index, Texture texture)
54 NDalicPINVOKE.TextureSet_SetTexture(swigCPtr, index, Texture.getCPtr(texture));
55 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
59 /// Gets the image at position "index".
61 /// <param name="index">The position in the texture set of the image.</param>
62 /// <returns>A handle to the image at the the specified position.</returns>
63 /// <since_tizen> 3 </since_tizen>
64 public Texture GetTexture(uint index)
66 //to fix memory leak issue, match the handle count with native side.
67 System.IntPtr cPtr = NDalicPINVOKE.TextureSet_GetTexture(swigCPtr, index);
68 HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
69 Texture ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as Texture;
70 NDalicPINVOKE.delete_BaseHandle(CPtr);
71 CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
73 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
78 /// Sets the sampler to be used by the image at position "index".
80 /// <param name="index">The position in the texture set of the image.</param>
81 /// <param name="sampler">The sampler to use.</param>
82 /// <since_tizen> 3 </since_tizen>
83 public void SetSampler(uint index, Sampler sampler)
85 NDalicPINVOKE.TextureSet_SetSampler(swigCPtr, index, Sampler.getCPtr(sampler));
86 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
90 /// Sets the sampler to be used by the image at position "index".
92 /// <param name="index">The position in the texture set of the image.</param>
93 /// <returns>A handle to the sampler at the specified position.</returns>
94 /// <since_tizen> 3 </since_tizen>
95 public Sampler GetSampler(uint index)
97 //to fix memory leak issue, match the handle count with native side.
98 System.IntPtr cPtr = NDalicPINVOKE.TextureSet_GetSampler(swigCPtr, index);
99 HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
100 Sampler ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as Sampler;
101 NDalicPINVOKE.delete_BaseHandle(CPtr);
102 CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
104 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109 /// Gets the number of textures present in the TextureSet.
111 /// <returns>The number of textures in the TextureSet.</returns>
112 /// <since_tizen> 3 </since_tizen>
113 public uint GetTextureCount()
115 uint ret = NDalicPINVOKE.TextureSet_GetTextureCount(swigCPtr);
116 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
120 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextureSet obj)
122 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
128 /// <since_tizen> 3 </since_tizen>
129 protected override void Dispose(DisposeTypes type)
136 if (type == DisposeTypes.Explicit)
139 //Release your own managed resources here.
140 //You should release all of your own disposable objects here.
144 //Release your own unmanaged resources here.
145 //You should not access any managed member here except static instance.
146 //because the execution order of Finalizes is non-deterministic.
148 if (swigCPtr.Handle != global::System.IntPtr.Zero)
153 NDalicPINVOKE.delete_TextureSet(swigCPtr);
155 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);