Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / Matrix3.cs
1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 *
15 */
16
17 namespace Tizen.NUI
18 {
19
20     internal class Matrix3 : global::System.IDisposable
21     {
22         private global::System.Runtime.InteropServices.HandleRef swigCPtr;
23         protected bool swigCMemOwn;
24
25         internal Matrix3(global::System.IntPtr cPtr, bool cMemoryOwn)
26         {
27             swigCMemOwn = cMemoryOwn;
28             swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
29         }
30
31         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Matrix3 obj)
32         {
33             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
34         }
35
36         //A Flag to check who called Dispose(). (By User or DisposeQueue)
37         private bool isDisposeQueued = false;
38         //A Flat to check if it is already disposed.
39         protected bool disposed = false;
40
41
42         ~Matrix3()
43         {
44             if (!isDisposeQueued)
45             {
46                 isDisposeQueued = true;
47                 DisposeQueue.Instance.Add(this);
48             }
49         }
50
51         public void Dispose()
52         {
53             //Throw excpetion if Dispose() is called in separate thread.
54             if (!Window.IsInstalled())
55             {
56                 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
57             }
58
59             if (isDisposeQueued)
60             {
61                 Dispose(DisposeTypes.Implicit);
62             }
63             else
64             {
65                 Dispose(DisposeTypes.Explicit);
66                 System.GC.SuppressFinalize(this);
67             }
68         }
69
70         protected virtual void Dispose(DisposeTypes type)
71         {
72             if (disposed)
73             {
74                 return;
75             }
76
77             if (type == DisposeTypes.Explicit)
78             {
79                 //Called by User
80                 //Release your own managed resources here.
81                 //You should release all of your own disposable objects here.
82
83             }
84
85             //Release your own unmanaged resources here.
86             //You should not access any managed member here except static instance.
87             //because the execution order of Finalizes is non-deterministic.
88
89             if (swigCPtr.Handle != global::System.IntPtr.Zero)
90             {
91                 if (swigCMemOwn)
92                 {
93                     swigCMemOwn = false;
94                     NDalicPINVOKE.delete_Matrix3(swigCPtr);
95                 }
96                 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
97             }
98
99             disposed = true;
100         }
101
102         public static Matrix3 IDENTITY
103         {
104             get
105             {
106                 global::System.IntPtr cPtr = NDalicPINVOKE.Matrix3_IDENTITY_get();
107                 Matrix3 ret = (cPtr == global::System.IntPtr.Zero) ? null : new Matrix3(cPtr, false);
108                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
109                 return ret;
110             }
111         }
112
113         public Matrix3() : this(NDalicPINVOKE.new_Matrix3__SWIG_0(), true)
114         {
115             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
116         }
117
118         public Matrix3(Matrix3 m) : this(NDalicPINVOKE.new_Matrix3__SWIG_1(Matrix3.getCPtr(m)), true)
119         {
120             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
121         }
122
123         public Matrix3(Matrix m) : this(NDalicPINVOKE.new_Matrix3__SWIG_2(Matrix.getCPtr(m)), true)
124         {
125             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
126         }
127
128         public Matrix3(float s00, float s01, float s02, float s10, float s11, float s12, float s20, float s21, float s22) : this(NDalicPINVOKE.new_Matrix3__SWIG_3(s00, s01, s02, s10, s11, s12, s20, s21, s22), true)
129         {
130             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
131         }
132
133         public Matrix3 Assign(Matrix3 matrix)
134         {
135             Matrix3 ret = new Matrix3(NDalicPINVOKE.Matrix3_Assign__SWIG_0(swigCPtr, Matrix3.getCPtr(matrix)), false);
136             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
137             return ret;
138         }
139
140         public Matrix3 Assign(Matrix matrix)
141         {
142             Matrix3 ret = new Matrix3(NDalicPINVOKE.Matrix3_Assign__SWIG_1(swigCPtr, Matrix.getCPtr(matrix)), false);
143             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
144             return ret;
145         }
146
147         public bool EqualTo(Matrix3 rhs)
148         {
149             bool ret = NDalicPINVOKE.Matrix3_EqualTo(swigCPtr, Matrix3.getCPtr(rhs));
150             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
151             return ret;
152         }
153
154         public bool NotEqualTo(Matrix3 rhs)
155         {
156             bool ret = NDalicPINVOKE.Matrix3_NotEqualTo(swigCPtr, Matrix3.getCPtr(rhs));
157             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
158             return ret;
159         }
160
161         public void SetIdentity()
162         {
163             NDalicPINVOKE.Matrix3_SetIdentity(swigCPtr);
164             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
165         }
166
167         public SWIGTYPE_p_float AsFloat()
168         {
169             global::System.IntPtr cPtr = NDalicPINVOKE.Matrix3_AsFloat__SWIG_0(swigCPtr);
170             SWIGTYPE_p_float ret = (cPtr == global::System.IntPtr.Zero) ? null : new SWIGTYPE_p_float(cPtr, false);
171             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
172             return ret;
173         }
174
175         public bool Invert()
176         {
177             bool ret = NDalicPINVOKE.Matrix3_Invert(swigCPtr);
178             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
179             return ret;
180         }
181
182         public bool Transpose()
183         {
184             bool ret = NDalicPINVOKE.Matrix3_Transpose(swigCPtr);
185             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
186             return ret;
187         }
188
189         public void Scale(float scale)
190         {
191             NDalicPINVOKE.Matrix3_Scale(swigCPtr, scale);
192             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
193         }
194
195         public float Magnitude()
196         {
197             float ret = NDalicPINVOKE.Matrix3_Magnitude(swigCPtr);
198             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199             return ret;
200         }
201
202         public bool ScaledInverseTranspose()
203         {
204             bool ret = NDalicPINVOKE.Matrix3_ScaledInverseTranspose(swigCPtr);
205             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
206             return ret;
207         }
208
209         public static void Multiply(Matrix3 result, Matrix3 lhs, Matrix3 rhs)
210         {
211             NDalicPINVOKE.Matrix3_Multiply(Matrix3.getCPtr(result), Matrix3.getCPtr(lhs), Matrix3.getCPtr(rhs));
212             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213         }
214
215     }
216
217 }