/* * Copyright(c) 2019 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ using System.ComponentModel; using System.Runtime.InteropServices; namespace Tizen.NUI { /// /// TextureSet is a handle to an object that specifies the set of images used as textures by a renderer.
/// The images have to be ordered in the same order they are declared in the shader. ///
/// 3 public class TextureSet : BaseHandle { /// /// Create an instance of TextureSet. /// /// 3 public TextureSet() : this(Interop.TextureSet.New(), true) { if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } internal TextureSet(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.TextureSet.Upcast(cPtr), cMemoryOwn) { } /// /// Sets the texture at position "index". /// /// The position in the texture set of the texture. /// The texture. /// 3 public void SetTexture(uint index, Texture texture) { Interop.TextureSet.SetTexture(SwigCPtr, index, Texture.getCPtr(texture)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Gets the image at position "index". /// /// The position in the texture set of the image. /// A handle to the image at the the specified position. /// 3 public Texture GetTexture(uint index) { //to fix memory leak issue, match the handle count with native side. System.IntPtr cPtr = Interop.TextureSet.GetTexture(SwigCPtr, index); HandleRef CPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr); Texture ret = Registry.GetManagedBaseHandleFromNativePtr(CPtr.Handle) as Texture; if (cPtr != null && ret == null) { ret = new Texture(cPtr, false); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } Interop.BaseHandle.DeleteBaseHandle(CPtr); CPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Sets the sampler to be used by the image at position "index". /// /// The position in the texture set of the image. /// The sampler to use. /// 3 public void SetSampler(uint index, Sampler sampler) { Interop.TextureSet.SetSampler(SwigCPtr, index, Sampler.getCPtr(sampler)); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); } /// /// Sets the sampler to be used by the image at position "index". /// /// The position in the texture set of the image. /// A handle to the sampler at the specified position. /// 3 public Sampler GetSampler(uint index) { //to fix memory leak issue, match the handle count with native side. System.IntPtr cPtr = Interop.TextureSet.GetSampler(SwigCPtr, index); Sampler ret = this.GetInstanceSafely(cPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } /// /// Gets the number of textures present in the TextureSet. /// /// The number of textures in the TextureSet. /// 3 public uint GetTextureCount() { uint ret = Interop.TextureSet.GetTextureCount(SwigCPtr); if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve(); return ret; } internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TextureSet obj) { return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr; } /// This will not be public opened. [EditorBrowsable(EditorBrowsableState.Never)] protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr) { Interop.TextureSet.DeleteTextureSet(swigCPtr); } } }