[NUI] Skip adding cell padding to last LinearLayout item (#1815)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Texture.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 using System.ComponentModel;
18
19 namespace Tizen.NUI
20 {
21     /// <summary>
22     /// Texture represents a texture object used as input or output by shaders.
23     /// </summary>
24     /// <since_tizen> 3 </since_tizen>
25     public class Texture : BaseHandle
26     {
27
28         /// <summary>
29         /// Creates a new Texture object.
30         /// </summary>
31         /// <param name="type">The type of the texture.</param>
32         /// <param name="format">The format of the pixel data.</param>
33         /// <param name="width">The width of the texture.</param>
34         /// <param name="height">The height of the texture.</param>
35         /// <since_tizen> 3 </since_tizen>
36         public Texture(TextureType type, PixelFormat format, uint width, uint height) : this(Interop.Texture.Texture_New__SWIG_0((int)type, (int)format, width, height), true)
37         {
38             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
39
40         }
41
42         [EditorBrowsable(EditorBrowsableState.Never)]
43         public Texture(NativeImageInterface nativeImageInterface) : this(Interop.Texture.Texture_New__SWIG_1(NativeImageInterface.getCPtr(nativeImageInterface)), true)
44         {
45             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
46
47         }
48
49         internal Texture(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.Texture.Texture_SWIGUpcast(cPtr), cMemoryOwn)
50         {
51         }
52
53         /// <summary>
54         /// Uploads data to the texture from a PixelData object.
55         /// </summary>
56         /// <param name="pixelData">The pixelData object.</param>
57         /// <returns>True if the PixelData object has compatible pixel format and fits within the texture, false otherwise.</returns>
58         /// <since_tizen> 3 </since_tizen>
59         public bool Upload(PixelData pixelData)
60         {
61             bool ret = Interop.Texture.Texture_Upload__SWIG_0(swigCPtr, PixelData.getCPtr(pixelData));
62             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
63             return ret;
64         }
65
66         /// <summary>
67         /// Uploads data to the texture from a PixelData object.
68         /// </summary>
69         /// <param name="pixelData">The pixelData object.</param>
70         /// <param name="layer">The layer of a cube map or array texture.</param>
71         /// <param name="mipmap">The level-of-detail number. Level 0 is the base image level. Level n is the nth mipmap reduction image.</param>
72         /// <param name="xOffset">The horizontal offset of the rectangular area in the texture that will be updated.</param>
73         /// <param name="yOffset">The vertical offset of the rectangular area in the texture that will be updated.</param>
74         /// <param name="width">The width of the rectangular area in the texture that will be updated.</param>
75         /// <param name="height">height of the rectangular area in the texture that will be updated.</param>
76         /// <returns>True if the PixelData object has compatible pixel format and fits within the texture, false otherwise.</returns>
77         /// <since_tizen> 3 </since_tizen>
78         public bool Upload(PixelData pixelData, uint layer, uint mipmap, uint xOffset, uint yOffset, uint width, uint height)
79         {
80             bool ret = Interop.Texture.Texture_Upload__SWIG_1(swigCPtr, PixelData.getCPtr(pixelData), layer, mipmap, xOffset, yOffset, width, height);
81             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
82             return ret;
83         }
84
85         /// <summary>
86         /// Generates mipmaps for the texture.<br />
87         /// This will auto generate all the mipmaps for the texture based on the data in the base level.
88         /// </summary>
89         /// <since_tizen> 3 </since_tizen>
90         public void GenerateMipmaps()
91         {
92             Interop.Texture.Texture_GenerateMipmaps(swigCPtr);
93             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
94         }
95
96         /// <summary>
97         /// Returns the width of the texture.<br />
98         /// </summary>
99         /// <returns>The width, in pixels, of the texture.</returns>
100         /// <since_tizen> 3 </since_tizen>
101         public uint GetWidth()
102         {
103             uint ret = Interop.Texture.Texture_GetWidth(swigCPtr);
104             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
105             return ret;
106         }
107
108         /// <summary>
109         /// Returns the height of the texture..<br />
110         /// </summary>
111         /// <returns>The height, in pixels, of the texture.</returns>
112         /// <since_tizen> 3 </since_tizen>
113         public uint GetHeight()
114         {
115             uint ret = Interop.Texture.Texture_GetHeight(swigCPtr);
116             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
117             return ret;
118         }
119
120         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Texture obj)
121         {
122             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
123         }
124
125         /// This will not be public opened.
126         [EditorBrowsable(EditorBrowsableState.Never)]
127         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
128         {
129             Interop.Texture.delete_Texture(swigCPtr);
130         }
131     }
132 }