[NUI] TCSACR-226 code change (#1032)
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / BufferImage.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     internal class BufferImage : Image
21     {
22         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
23
24         internal BufferImage(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.BufferImage.BufferImage_SWIGUpcast(cPtr), cMemoryOwn)
25         {
26             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
27         }
28
29         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(BufferImage obj)
30         {
31             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
32         }
33
34         protected override void Dispose(DisposeTypes type)
35         {
36             if (disposed)
37             {
38                 return;
39             }
40
41             //Release your own unmanaged resources here.
42             //You should not access any managed member here except static instance.
43             //because the execution order of Finalizes is non-deterministic.
44
45             if (swigCPtr.Handle != global::System.IntPtr.Zero)
46             {
47                 if (swigCMemOwn)
48                 {
49                     swigCMemOwn = false;
50                     Interop.BufferImage.delete_BufferImage(swigCPtr);
51                 }
52                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
53             }
54
55             base.Dispose(type);
56         }
57
58         public BufferImage(uint width, uint height, PixelFormat pixelformat) : this(Interop.BufferImage.BufferImage_New__SWIG_0(width, height, (int)pixelformat), true)
59         {
60             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
61         }
62
63         public BufferImage(uint width, uint height) : this(Interop.BufferImage.BufferImage_New__SWIG_1(width, height), true)
64         {
65             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
66         }
67
68         public BufferImage(byte[] pixelBuffer, uint width, uint height, PixelFormat pixelFormat, uint stride) : this(Interop.BufferImage.BufferImage_New__SWIG_2(pixelBuffer, width, height, (int)pixelFormat, stride), true)
69         {
70             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
71         }
72
73         public BufferImage(byte[] pixelBuffer, uint width, uint height, PixelFormat pixelFormat) : this(Interop.BufferImage.BufferImage_New__SWIG_3(pixelBuffer, width, height, (int)pixelFormat), true)
74         {
75             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
76         }
77
78         public BufferImage(byte[] pixelBuffer, uint width, uint height) : this(Interop.BufferImage.BufferImage_New__SWIG_4(pixelBuffer, width, height), true)
79         {
80             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
81         }
82
83         public new static BufferImage DownCast(BaseHandle handle)
84         {
85             BufferImage ret = Registry.GetManagedBaseHandleFromNativePtr(handle) as BufferImage;
86             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
87             return ret;
88         }
89
90         public BufferImage(BufferImage handle) : this(Interop.BufferImage.new_BufferImage__SWIG_1(BufferImage.getCPtr(handle)), true)
91         {
92             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
93         }
94
95         public BufferImage Assign(BufferImage rhs)
96         {
97             BufferImage ret = new BufferImage(Interop.BufferImage.BufferImage_Assign(swigCPtr, BufferImage.getCPtr(rhs)), false);
98             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
99             return ret;
100         }
101
102         public static BufferImage WHITE()
103         {
104             BufferImage ret = new BufferImage(Interop.BufferImage.BufferImage_WHITE(), true);
105             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
106             return ret;
107         }
108
109         public SWIGTYPE_p_unsigned_char GetBuffer()
110         {
111             global::System.IntPtr cPtr = Interop.BufferImage.BufferImage_GetBuffer(swigCPtr);
112             SWIGTYPE_p_unsigned_char ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_unsigned_char(cPtr, false);
113             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
114             return ret;
115         }
116
117         public uint GetBufferSize()
118         {
119             uint ret = Interop.BufferImage.BufferImage_GetBufferSize(swigCPtr);
120             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
121             return ret;
122         }
123
124         public uint GetBufferStride()
125         {
126             uint ret = Interop.BufferImage.BufferImage_GetBufferStride(swigCPtr);
127             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
128             return ret;
129         }
130
131         public PixelFormat GetPixelFormat()
132         {
133             PixelFormat ret = (PixelFormat)Interop.BufferImage.BufferImage_GetPixelFormat(swigCPtr);
134             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
135             return ret;
136         }
137
138         public void Update()
139         {
140             Interop.BufferImage.BufferImage_Update__SWIG_0(swigCPtr);
141             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
142         }
143
144         public void Update(SWIGTYPE_p_Dali__RectT_unsigned_int_t updateArea)
145         {
146             Interop.BufferImage.BufferImage_Update__SWIG_1(swigCPtr, SWIGTYPE_p_Dali__RectT_unsigned_int_t.getCPtr(updateArea));
147             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
148         }
149
150         public bool IsDataExternal()
151         {
152             bool ret = Interop.BufferImage.BufferImage_IsDataExternal(swigCPtr);
153             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
154             return ret;
155         }
156     }
157 }