4 // Rodrigo Kumpera (rkumpera@novell.com)
6 // (C) 2008 Novell, Inc. (http://www.novell.com)
8 // Permission is hereby granted, free of charge, to any person obtaining
9 // a copy of this software and associated documentation files (the
10 // "Software"), to deal in the Software without restriction, including
11 // without limitation the rights to use, copy, modify, merge, publish,
12 // distribute, sublicense, and/or sell copies of the Software, and to
13 // permit persons to whom the Software is furnished to do so, subject to
14 // the following conditions:
16 // The above copyright notice and this permission notice shall be
17 // included in all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 using System.Runtime.InteropServices;
\r
32 [StructLayout(LayoutKind.Sequential, Pack = 0, Size = 16)]
\r
33 public struct Vector2l
\r
38 public long X { get { return x; } set { x = value; } }
\r
39 public long Y { get { return y; } set { y = value; } }
\r
41 public Vector2l (long x, long y)
\r
48 public static Vector2l operator + (Vector2l v1, Vector2l v2)
\r
50 return new Vector2l (v1.x + v2.x, v1.y + v2.y);
\r
54 public static Vector2l operator - (Vector2l v1, Vector2l v2)
\r
56 return new Vector2l (v1.x - v2.x, v1.y - v2.y);
\r
59 public static unsafe Vector2l operator << (Vector2l v1, int amount)
\r
61 return new Vector2l (v1.x << amount, v1.y << amount);
\r
64 public static Vector2l operator & (Vector2l v1, Vector2l v2)
\r
66 return new Vector2l (v1.x & v2.x, v1.y & v2.y);
\r
69 public static Vector2l operator | (Vector2l v1, Vector2l v2)
\r
71 return new Vector2l (v1.x | v2.x, v1.y | v2.y);
\r
74 public static Vector2l operator ^ (Vector2l v1, Vector2l v2)
\r
76 return new Vector2l (v1.x ^ v2.x, v1.y ^ v2.y);
\r
79 public static Vector2l UnpackLow (Vector2l v1, Vector2l v2)
81 return new Vector2l (v1.x, v2.x);
84 public static Vector2l UnpackHigh (Vector2l v1, Vector2l v2)
86 return new Vector2l (v1.y, v2.y);
89 public static unsafe Vector2l ShiftRightLogic (Vector2l v1, int amount)
\r
91 return new Vector2l ((long)((ulong)(v1.x) >> amount), (long)((ulong)(v1.y) >> amount));
\r
94 public static unsafe long ExtractByteMask (Vector2l va) {
97 for (int i = 0; i < 16; ++i)
98 res |= (*a++ & 0x80) >> 7 << i;
103 public static Vector2l CompareEqual (Vector2l v1, Vector2l v2)
105 return new Vector2l ((long)(v1.x == v2.x ? -1 : 0), (long)(v1.y == v2.y ? -1 : 0));
109 public static Vector2l CompareGreaterThan (Vector2l v1, Vector2l v2)
111 return new Vector2l ((long)(v1.x > v2.x ? -1 : 0), (long)(v1.y > v2.y ? -1 : 0));
114 public static unsafe explicit operator Vector4f (Vector2l v1)
\r
116 Vector4f* p = (Vector4f*)&v1;
\r
120 [CLSCompliant(false)]
\r
121 public static unsafe explicit operator Vector8us (Vector2l v1)
\r
123 Vector8us* p = (Vector8us*)&v1;
\r
127 [CLSCompliant(false)]
\r
128 public static unsafe explicit operator Vector16b (Vector2l v1)
\r
130 Vector16b* p = (Vector16b*)&v1;
\r
134 public static Vector2l LoadAligned (ref Vector2l v)
\r
139 public static void StoreAligned (ref Vector2l res, Vector2l val)
\r
144 [CLSCompliant(false)]
\r
145 public static unsafe Vector2l LoadAligned (Vector2l *v)
\r
150 [CLSCompliant(false)]
\r
151 public static unsafe void StoreAligned (Vector2l *res, Vector2l val)
\r