summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Sams <jsams@google.com>2013-11-26 12:32:22 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2013-11-26 12:32:22 -0800
commit1ccc6633bf47c95601cc13a2566c702bb8d986cd (patch)
treed12af54786f61168ceef1f3fd9f3ad1ab4e2a3f7
parentad0cab26a7abb0b6d08e5a807bf8aff87db0a52a (diff)
parent9e6d8f04940fd710ae858ff7ee4df43eb03ea85e (diff)
downloadframeworks_base-1ccc6633bf47c95601cc13a2566c702bb8d986cd.zip
frameworks_base-1ccc6633bf47c95601cc13a2566c702bb8d986cd.tar.gz
frameworks_base-1ccc6633bf47c95601cc13a2566c702bb8d986cd.tar.bz2
am 9e6d8f04: Merge "Adding operations to reflected Renderscript class"
* commit '9e6d8f04940fd710ae858ff7ee4df43eb03ea85e': Adding operations to reflected Renderscript class
-rw-r--r--graphics/java/android/renderscript/Byte2.java356
-rw-r--r--graphics/java/android/renderscript/Byte3.java388
-rw-r--r--graphics/java/android/renderscript/Byte4.java420
-rw-r--r--graphics/java/android/renderscript/Double2.java372
-rw-r--r--graphics/java/android/renderscript/Double3.java406
-rw-r--r--graphics/java/android/renderscript/Double4.java442
-rw-r--r--graphics/java/android/renderscript/Float2.java372
-rw-r--r--graphics/java/android/renderscript/Float3.java406
-rw-r--r--graphics/java/android/renderscript/Float4.java441
-rw-r--r--graphics/java/android/renderscript/Int2.java426
-rw-r--r--graphics/java/android/renderscript/Int3.java465
-rw-r--r--graphics/java/android/renderscript/Int4.java505
-rw-r--r--graphics/java/android/renderscript/Long2.java425
-rw-r--r--graphics/java/android/renderscript/Long3.java464
-rw-r--r--graphics/java/android/renderscript/Long4.java504
-rw-r--r--graphics/java/android/renderscript/Short2.java428
-rw-r--r--graphics/java/android/renderscript/Short3.java465
-rw-r--r--graphics/java/android/renderscript/Short4.java505
18 files changed, 7539 insertions, 251 deletions
diff --git a/graphics/java/android/renderscript/Byte2.java b/graphics/java/android/renderscript/Byte2.java
index cf34f3a..f796de3 100644
--- a/graphics/java/android/renderscript/Byte2.java
+++ b/graphics/java/android/renderscript/Byte2.java
@@ -25,6 +25,9 @@ import android.util.Log;
*
**/
public class Byte2 {
+ public byte x;
+ public byte y;
+
public Byte2() {
}
@@ -33,8 +36,357 @@ public class Byte2 {
y = initY;
}
- public byte x;
- public byte y;
+ /** @hide */
+ public Byte2(Byte2 source) {
+ this.x = source.x;
+ this.y = source.y;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ */
+ public void add(Byte2 a) {
+ this.x += a.x;
+ this.y += a.y;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte2 add(Byte2 a, Byte2 b) {
+ Byte2 result = new Byte2();
+ result.x = (byte)(a.x + b.x);
+ result.y = (byte)(a.y + b.y);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(byte value) {
+ x += value;
+ y += value;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte2 add(Byte2 a, byte b) {
+ Byte2 result = new Byte2();
+ result.x = (byte)(a.x + b);
+ result.y = (byte)(a.y + b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ */
+ public void sub(Byte2 a) {
+ this.x -= a.x;
+ this.y -= a.y;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte2 sub(Byte2 a, Byte2 b) {
+ Byte2 result = new Byte2();
+ result.x = (byte)(a.x - b.x);
+ result.y = (byte)(a.y - b.y);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(byte value) {
+ x -= value;
+ y -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte2 sub(Byte2 a, byte b) {
+ Byte2 result = new Byte2();
+ result.x = (byte)(a.x - b);
+ result.y = (byte)(a.y - b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ */
+ public void mul(Byte2 a) {
+ this.x *= a.x;
+ this.y *= a.y;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte2 mul(Byte2 a, Byte2 b) {
+ Byte2 result = new Byte2();
+ result.x = (byte)(a.x * b.x);
+ result.y = (byte)(a.y * b.y);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(byte value) {
+ x *= value;
+ y *= value;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte2 mul(Byte2 a, byte b) {
+ Byte2 result = new Byte2();
+ result.x = (byte)(a.x * b);
+ result.y = (byte)(a.y * b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ */
+ public void div(Byte2 a) {
+ this.x /= a.x;
+ this.y /= a.y;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte2 div(Byte2 a, Byte2 b) {
+ Byte2 result = new Byte2();
+ result.x = (byte)(a.x / b.x);
+ result.y = (byte)(a.y / b.y);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(byte value) {
+ x /= value;
+ y /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte2 div(Byte2 a, byte b) {
+ Byte2 result = new Byte2();
+ result.x = (byte)(a.x / b);
+ result.y = (byte)(a.y / b);
+
+ return result;
+ }
+
+ /** @hide
+ * get vector length
+ *
+ * @return
+ */
+ public byte length() {
+ return 2;
+ }
+
+ /** @hide
+ * set vector negate
+ */
+ public void negate() {
+ this.x = (byte)(-x);
+ this.y = (byte)(-y);
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public byte dotProduct(Byte2 a) {
+ return (byte)((x * a.x) + (y * a.y));
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static byte dotProduct(Byte2 a, Byte2 b) {
+ return (byte)((b.x * a.x) + (b.y * a.y));
+ }
+
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Byte2 a, byte factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ }
+
+ /** @hide
+ * set vector value by Byte2
+ *
+ * @param a
+ */
+ public void set(Byte2 a) {
+ this.x = a.x;
+ this.y = a.y;
+ }
+
+ /** @hide
+ * set the vector field value by Char
+ *
+ * @param a
+ * @param b
+ */
+ public void setValues(byte a, byte b) {
+ this.x = a;
+ this.y = b;
+ }
+
+ /** @hide
+ * return the element sum of vector
+ *
+ * @return
+ */
+ public byte elementSum() {
+ return (byte)(x + y);
+ }
+
+ /** @hide
+ * get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public byte get(int i) {
+ switch (i) {
+ case 0:
+ return x;
+ case 1:
+ return y;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, byte value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, byte value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * copy the vector to Char array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(byte[] data, int offset) {
+ data[offset] = x;
+ data[offset + 1] = y;
+ }
+
}
diff --git a/graphics/java/android/renderscript/Byte3.java b/graphics/java/android/renderscript/Byte3.java
index 266e94d..f2a95ac 100644
--- a/graphics/java/android/renderscript/Byte3.java
+++ b/graphics/java/android/renderscript/Byte3.java
@@ -25,6 +25,10 @@ import android.util.Log;
*
**/
public class Byte3 {
+ public byte x;
+ public byte y;
+ public byte z;
+
public Byte3() {
}
@@ -34,9 +38,387 @@ public class Byte3 {
z = initZ;
}
- public byte x;
- public byte y;
- public byte z;
+ /** @hide */
+ public Byte3(Byte3 source) {
+ this.x = source.x;
+ this.y = source.y;
+ this.z = source.z;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ */
+ public void add(Byte3 a) {
+ this.x += a.x;
+ this.y += a.y;
+ this.z += a.z;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte3 add(Byte3 a, Byte3 b) {
+ Byte3 result = new Byte3();
+ result.x = (byte)(a.x + b.x);
+ result.y = (byte)(a.y + b.y);
+ result.z = (byte)(a.z + b.z);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(byte value) {
+ x += value;
+ y += value;
+ z += value;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte3 add(Byte3 a, byte b) {
+ Byte3 result = new Byte3();
+ result.x = (byte)(a.x + b);
+ result.y = (byte)(a.y + b);
+ result.z = (byte)(a.z + b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ */
+ public void sub(Byte3 a) {
+ this.x -= a.x;
+ this.y -= a.y;
+ this.z -= a.z;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte3 sub(Byte3 a, Byte3 b) {
+ Byte3 result = new Byte3();
+ result.x = (byte)(a.x - b.x);
+ result.y = (byte)(a.y - b.y);
+ result.z = (byte)(a.z - b.z);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(byte value) {
+ x -= value;
+ y -= value;
+ z -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte3 sub(Byte3 a, byte b) {
+ Byte3 result = new Byte3();
+ result.x = (byte)(a.x - b);
+ result.y = (byte)(a.y - b);
+ result.z = (byte)(a.z - b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ */
+ public void mul(Byte3 a) {
+ this.x *= a.x;
+ this.y *= a.y;
+ this.z *= a.z;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte3 mul(Byte3 a, Byte3 b) {
+ Byte3 result = new Byte3();
+ result.x = (byte)(a.x * b.x);
+ result.y = (byte)(a.y * b.y);
+ result.z = (byte)(a.z * b.z);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(byte value) {
+ x *= value;
+ y *= value;
+ z *= value;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte3 mul(Byte3 a, byte b) {
+ Byte3 result = new Byte3();
+ result.x = (byte)(a.x * b);
+ result.y = (byte)(a.y * b);
+ result.z = (byte)(a.z * b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ */
+ public void div(Byte3 a) {
+ this.x /= a.x;
+ this.y /= a.y;
+ this.z /= a.z;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte3 div(Byte3 a, Byte3 b) {
+ Byte3 result = new Byte3();
+ result.x = (byte)(a.x / b.x);
+ result.y = (byte)(a.y / b.y);
+ result.z = (byte)(a.z / b.z);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(byte value) {
+ x /= value;
+ y /= value;
+ z /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte3 div(Byte3 a, byte b) {
+ Byte3 result = new Byte3();
+ result.x = (byte)(a.x / b);
+ result.y = (byte)(a.y / b);
+ result.z = (byte)(a.z / b);
+
+ return result;
+ }
+
+ /** @hide
+ * get vector length
+ *
+ * @return
+ */
+ public byte length() {
+ return 3;
+ }
+
+ /** @hide
+ * set vector negate
+ */
+ public void negate() {
+ this.x = (byte)(-x);
+ this.y = (byte)(-y);
+ this.z = (byte)(-z);
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public byte dotProduct(Byte3 a) {
+ return (byte)((byte)((byte)(x * a.x) + (byte)(y * a.y)) + (byte)(z * a.z));
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static byte dotProduct(Byte3 a, Byte3 b) {
+ return (byte)((byte)((byte)(b.x * a.x) + (byte)(b.y * a.y)) + (byte)(b.z * a.z));
+ }
+
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Byte3 a, byte factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ z += a.z * factor;
+ }
+
+ /** @hide
+ * set vector value by Byte3
+ *
+ * @param a
+ */
+ public void set(Byte3 a) {
+ this.x = a.x;
+ this.y = a.y;
+ this.z = a.z;
+ }
+
+ /** @hide
+ * set the vector field value by Char
+ *
+ * @param a
+ * @param b
+ * @param c
+ */
+ public void setValues(byte a, byte b, byte c) {
+ this.x = a;
+ this.y = b;
+ this.z = c;
+ }
+
+ /** @hide
+ * return the element sum of vector
+ *
+ * @return
+ */
+ public byte elementSum() {
+ return (byte)(x + y + z);
+ }
+
+ /** @hide
+ * get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public byte get(int i) {
+ switch (i) {
+ case 0:
+ return x;
+ case 1:
+ return y;
+ case 2:
+ return z;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, byte value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ case 2:
+ z = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, byte value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ case 2:
+ z += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * copy the vector to Char array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(byte[] data, int offset) {
+ data[offset] = x;
+ data[offset + 1] = y;
+ data[offset + 2] = z;
+ }
}
diff --git a/graphics/java/android/renderscript/Byte4.java b/graphics/java/android/renderscript/Byte4.java
index 68c8f52..b8a8a6b 100644
--- a/graphics/java/android/renderscript/Byte4.java
+++ b/graphics/java/android/renderscript/Byte4.java
@@ -25,6 +25,11 @@ import android.util.Log;
*
**/
public class Byte4 {
+ public byte x;
+ public byte y;
+ public byte z;
+ public byte w;
+
public Byte4() {
}
@@ -34,11 +39,418 @@ public class Byte4 {
z = initZ;
w = initW;
}
+ /** @hide */
+ public Byte4(Byte4 source) {
+ this.x = source.x;
+ this.y = source.y;
+ this.z = source.z;
+ this.w = source.w;
+ }
- public byte x;
- public byte y;
- public byte z;
- public byte w;
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ */
+ public void add(Byte4 a) {
+ this.x += a.x;
+ this.y += a.y;
+ this.z += a.z;
+ this.w += a.w;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte4 add(Byte4 a, Byte4 b) {
+ Byte4 result = new Byte4();
+ result.x = (byte)(a.x + b.x);
+ result.y = (byte)(a.y + b.y);
+ result.z = (byte)(a.z + b.z);
+ result.w = (byte)(a.w + b.w);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(byte value) {
+ x += value;
+ y += value;
+ z += value;
+ w += value;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte4 add(Byte4 a, byte b) {
+ Byte4 result = new Byte4();
+ result.x = (byte)(a.x + b);
+ result.y = (byte)(a.y + b);
+ result.z = (byte)(a.z + b);
+ result.w = (byte)(a.w + b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ */
+ public void sub(Byte4 a) {
+ this.x -= a.x;
+ this.y -= a.y;
+ this.z -= a.z;
+ this.w -= a.w;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte4 sub(Byte4 a, Byte4 b) {
+ Byte4 result = new Byte4();
+ result.x = (byte)(a.x - b.x);
+ result.y = (byte)(a.y - b.y);
+ result.z = (byte)(a.z - b.z);
+ result.w = (byte)(a.w - b.w);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(byte value) {
+ x -= value;
+ y -= value;
+ z -= value;
+ w -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte4 sub(Byte4 a, byte b) {
+ Byte4 result = new Byte4();
+ result.x = (byte)(a.x - b);
+ result.y = (byte)(a.y - b);
+ result.z = (byte)(a.z - b);
+ result.w = (byte)(a.w - b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ */
+ public void mul(Byte4 a) {
+ this.x *= a.x;
+ this.y *= a.y;
+ this.z *= a.z;
+ this.w *= a.w;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte4 mul(Byte4 a, Byte4 b) {
+ Byte4 result = new Byte4();
+ result.x = (byte)(a.x * b.x);
+ result.y = (byte)(a.y * b.y);
+ result.z = (byte)(a.z * b.z);
+ result.w = (byte)(a.w * b.w);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(byte value) {
+ x *= value;
+ y *= value;
+ z *= value;
+ w *= value;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte4 mul(Byte4 a, byte b) {
+ Byte4 result = new Byte4();
+ result.x = (byte)(a.x * b);
+ result.y = (byte)(a.y * b);
+ result.z = (byte)(a.z * b);
+ result.w = (byte)(a.w * b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ */
+ public void div(Byte4 a) {
+ this.x /= a.x;
+ this.y /= a.y;
+ this.z /= a.z;
+ this.w /= a.w;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte4 div(Byte4 a, Byte4 b) {
+ Byte4 result = new Byte4();
+ result.x = (byte)(a.x / b.x);
+ result.y = (byte)(a.y / b.y);
+ result.z = (byte)(a.z / b.z);
+ result.w = (byte)(a.w / b.w);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(byte value) {
+ x /= value;
+ y /= value;
+ z /= value;
+ w /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Byte4 div(Byte4 a, byte b) {
+ Byte4 result = new Byte4();
+ result.x = (byte)(a.x / b);
+ result.y = (byte)(a.y / b);
+ result.z = (byte)(a.z / b);
+ result.w = (byte)(a.w / b);
+
+ return result;
+ }
+
+ /** @hide
+ * get vector length
+ *
+ * @return
+ */
+ public byte length() {
+ return 4;
+ }
+
+ /** @hide
+ * set vector negate
+ */
+ public void negate() {
+ this.x = (byte)(-x);
+ this.y = (byte)(-y);
+ this.z = (byte)(-z);
+ this.w = (byte)(-w);
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public byte dotProduct(Byte4 a) {
+ return (byte)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w));
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static byte dotProduct(Byte4 a, Byte4 b) {
+ return (byte)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w));
+ }
+
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Byte4 a, byte factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ z += a.z * factor;
+ w += a.w * factor;
+ }
+
+ /** @hide
+ * set vector value by Byte4
+ *
+ * @param a
+ */
+ public void set(Byte4 a) {
+ this.x = a.x;
+ this.y = a.y;
+ this.z = a.z;
+ this.w = a.w;
+ }
+
+ /** @hide
+ * set the vector field values
+ *
+ * @param a
+ * @param b
+ * @param c
+ * @param d
+ */
+ public void setValues(byte a, byte b, byte c, byte d) {
+ this.x = a;
+ this.y = b;
+ this.z = c;
+ this.w = d;
+ }
+
+ /** @hide
+ * return the element sum of vector
+ *
+ * @return
+ */
+ public byte elementSum() {
+ return (byte)(x + y + z + w);
+ }
+
+ /** @hide
+ * get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public byte get(int i) {
+ switch (i) {
+ case 0:
+ return x;
+ case 1:
+ return y;
+ case 2:
+ return z;
+ case 3:
+ return w;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, byte value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ case 2:
+ z = value;
+ return;
+ case 3:
+ w = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, byte value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ case 2:
+ z += value;
+ return;
+ case 3:
+ w += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * copy the vector to Char array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(byte[] data, int offset) {
+ data[offset] = x;
+ data[offset + 1] = y;
+ data[offset + 2] = z;
+ data[offset + 3] = w;
+ }
}
diff --git a/graphics/java/android/renderscript/Double2.java b/graphics/java/android/renderscript/Double2.java
index 29fd515..4c7319d 100644
--- a/graphics/java/android/renderscript/Double2.java
+++ b/graphics/java/android/renderscript/Double2.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,28 +16,370 @@
package android.renderscript;
-import java.lang.Math;
-import android.util.Log;
-
-
/**
- * Class for exposing the native RenderScript double2 type back
- * to the Android system.
- *
- **/
+ * Vector version of the basic double type.
+ * Provides two double fields packed.
+ */
public class Double2 {
+ public double x;
+ public double y;
+
public Double2() {
}
- public Double2(double initX, double initY) {
- x = initX;
- y = initY;
+ /** @hide */
+ public Double2(Double2 data) {
+ this.x = data.x;
+ this.y = data.y;
}
- public double x;
- public double y;
-}
+ public Double2(double x, double y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double2 add(Double2 a, Double2 b) {
+ Double2 res = new Double2();
+ res.x = a.x + b.x;
+ res.y = a.y + b.y;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(Double2 value) {
+ x += value.x;
+ y += value.y;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(double value) {
+ x += value;
+ y += value;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double2 add(Double2 a, double b) {
+ Double2 res = new Double2();
+ res.x = a.x + b;
+ res.y = a.y + b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(Double2 value) {
+ x -= value.x;
+ y -= value.y;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double2 sub(Double2 a, Double2 b) {
+ Double2 res = new Double2();
+ res.x = a.x - b.x;
+ res.y = a.y - b.y;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(double value) {
+ x -= value;
+ y -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double2 sub(Double2 a, double b) {
+ Double2 res = new Double2();
+ res.x = a.x - b;
+ res.y = a.y - b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(Double2 value) {
+ x *= value.x;
+ y *= value.y;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double2 mul(Double2 a, Double2 b) {
+ Double2 res = new Double2();
+ res.x = a.x * b.x;
+ res.y = a.y * b.y;
+
+ return res;
+ }
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(double value) {
+ x *= value;
+ y *= value;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double2 mul(Double2 a, double b) {
+ Double2 res = new Double2();
+ res.x = a.x * b;
+ res.y = a.y * b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(Double2 value) {
+ x /= value.x;
+ y /= value.y;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double2 div(Double2 a, Double2 b) {
+ Double2 res = new Double2();
+ res.x = a.x / b.x;
+ res.y = a.y / b.y;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(double value) {
+ x /= value;
+ y /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double2 div(Double2 a, double b) {
+ Double2 res = new Double2();
+ res.x = a.x / b;
+ res.y = a.y / b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public double dotProduct(Double2 a) {
+ return (x * a.x) + (y * a.y);
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double dotProduct(Double2 a, Double2 b) {
+ return (b.x * a.x) + (b.y * a.y);
+ }
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Double2 a, double factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ }
+
+ /** @hide
+ * Set vector value by double2
+ *
+ * @param a
+ */
+ public void set(Double2 a) {
+ this.x = a.x;
+ this.y = a.y;
+ }
+
+ /** @hide
+ * Set vector negate
+ */
+ public void negate() {
+ x = -x;
+ y = -y;
+ }
+
+ /** @hide
+ * Get vector length
+ *
+ * @return
+ */
+ public int length() {
+ return 2;
+ }
+
+ /** @hide
+ * Return the element sum of vector
+ *
+ * @return
+ */
+ public double elementSum() {
+ return x + y;
+ }
+ /** @hide
+ * Get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public double get(int i) {
+ switch (i) {
+ case 0:
+ return x;
+ case 1:
+ return y;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * Set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, double value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * Add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, double value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+ /** @hide
+ * Set the vector field value
+ *
+ * @param x
+ * @param y
+ */
+ public void setValues(double x, double y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ /** @hide
+ * Copy the vector to double array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(double[] data, int offset) {
+ data[offset] = x;
+ data[offset + 1] = y;
+ }
+}
diff --git a/graphics/java/android/renderscript/Double3.java b/graphics/java/android/renderscript/Double3.java
index 818952e..b819716 100644
--- a/graphics/java/android/renderscript/Double3.java
+++ b/graphics/java/android/renderscript/Double3.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,30 +16,402 @@
package android.renderscript;
-import java.lang.Math;
-import android.util.Log;
-
-
/**
- * Class for exposing the native RenderScript double3 type back
- * to the Android system.
- *
- **/
+ * Vector version of the basic double type.
+ * Provides three double fields packed.
+ */
public class Double3 {
+ public double x;
+ public double y;
+ public double z;
+
public Double3() {
}
+ /** @hide */
+ public Double3(Double3 data) {
+ this.x = data.x;
+ this.y = data.y;
+ this.z = data.z;
+ }
- public Double3(double initX, double initY, double initZ) {
- x = initX;
- y = initY;
- z = initZ;
+ public Double3(double x, double y, double z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
}
- public double x;
- public double y;
- public double z;
-}
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double3 add(Double3 a, Double3 b) {
+ Double3 res = new Double3();
+ res.x = a.x + b.x;
+ res.y = a.y + b.y;
+ res.z = a.z + b.z;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(Double3 value) {
+ x += value.x;
+ y += value.y;
+ z += value.z;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(double value) {
+ x += value;
+ y += value;
+ z += value;
+ }
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double3 add(Double3 a, double b) {
+ Double3 res = new Double3();
+ res.x = a.x + b;
+ res.y = a.y + b;
+ res.z = a.z + b;
+ return res;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(Double3 value) {
+ x -= value.x;
+ y -= value.y;
+ z -= value.z;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double3 sub(Double3 a, Double3 b) {
+ Double3 res = new Double3();
+ res.x = a.x - b.x;
+ res.y = a.y - b.y;
+ res.z = a.z - b.z;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(double value) {
+ x -= value;
+ y -= value;
+ z -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double3 sub(Double3 a, double b) {
+ Double3 res = new Double3();
+ res.x = a.x - b;
+ res.y = a.y - b;
+ res.z = a.z - b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(Double3 value) {
+ x *= value.x;
+ y *= value.y;
+ z *= value.z;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double3 mul(Double3 a, Double3 b) {
+ Double3 res = new Double3();
+ res.x = a.x * b.x;
+ res.y = a.y * b.y;
+ res.z = a.z * b.z;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(double value) {
+ x *= value;
+ y *= value;
+ z *= value;
+ }
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double3 mul(Double3 a, double b) {
+ Double3 res = new Double3();
+ res.x = a.x * b;
+ res.y = a.y * b;
+ res.z = a.z * b;
+ return res;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(Double3 value) {
+ x /= value.x;
+ y /= value.y;
+ z /= value.z;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double3 div(Double3 a, Double3 b) {
+ Double3 res = new Double3();
+ res.x = a.x / b.x;
+ res.y = a.y / b.y;
+ res.z = a.z / b.z;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(double value) {
+ x /= value;
+ y /= value;
+ z /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double3 div(Double3 a, double b) {
+ Double3 res = new Double3();
+ res.x = a.x / b;
+ res.y = a.y / b;
+ res.z = a.z / b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public double dotProduct(Double3 a) {
+ return (x * a.x) + (y * a.y) + (z * a.z);
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static double dotProduct(Double3 a, Double3 b) {
+ return (b.x * a.x) + (b.y * a.y) + (b.z * a.z);
+ }
+
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Double3 a, double factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ z += a.z * factor;
+ }
+
+ /** @hide
+ * Set vector value by double3
+ *
+ * @param a
+ */
+ public void set(Double3 a) {
+ this.x = a.x;
+ this.y = a.y;
+ this.z = a.z;
+ }
+
+ /** @hide
+ * Set vector negate
+ */
+ public void negate() {
+ x = -x;
+ y = -y;
+ z = -z;
+ }
+
+ /** @hide
+ * Get vector length
+ *
+ * @return
+ */
+ public int length() {
+ return 3;
+ }
+
+ /** @hide
+ * Return the element sum of vector
+ *
+ * @return
+ */
+ public double elementSum() {
+ return x + y + z;
+ }
+
+ /** @hide
+ * Get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public double get(int i) {
+ switch (i) {
+ case 0:
+ return x;
+ case 1:
+ return y;
+ case 2:
+ return z;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * Set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, double value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ case 2:
+ z = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * Add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, double value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ case 2:
+ z += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * Set the vector field value
+ *
+ * @param x
+ * @param y
+ * @param z
+ */
+ public void setValues(double x, double y, double z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ /** @hide
+ * Copy the vector to double array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(double[] data, int offset) {
+ data[offset] = x;
+ data[offset + 1] = y;
+ data[offset + 2] = z;
+ }
+}
diff --git a/graphics/java/android/renderscript/Double4.java b/graphics/java/android/renderscript/Double4.java
index 7775ab7..e4829f7 100644
--- a/graphics/java/android/renderscript/Double4.java
+++ b/graphics/java/android/renderscript/Double4.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2011 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,31 +16,435 @@
package android.renderscript;
-import java.lang.Math;
-import android.util.Log;
-
-
/**
- * Class for exposing the native RenderScript double4 type back
- * to the Android system.
- *
- **/
+ * Vector version of the basic double type.
+ * Provides four double fields packed.
+ */
public class Double4 {
+ public double x;
+ public double y;
+ public double z;
+ public double w;
+
public Double4() {
}
+ /** @hide */
+ public Double4(Double4 data) {
+ this.x = data.x;
+ this.y = data.y;
+ this.z = data.z;
+ this.w = data.w;
+ }
- public Double4(double initX, double initY, double initZ, double initW) {
- x = initX;
- y = initY;
- z = initZ;
- w = initW;
+ public Double4(double x, double y, double z, double w) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
}
- public double x;
- public double y;
- public double z;
- public double w;
-}
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double4 add(Double4 a, Double4 b) {
+ Double4 res = new Double4();
+ res.x = a.x + b.x;
+ res.y = a.y + b.y;
+ res.z = a.z + b.z;
+ res.w = a.w + b.w;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(Double4 value) {
+ x += value.x;
+ y += value.y;
+ z += value.z;
+ w += value.w;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(double value) {
+ x += value;
+ y += value;
+ z += value;
+ w += value;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double4 add(Double4 a, double b) {
+ Double4 res = new Double4();
+ res.x = a.x + b;
+ res.y = a.y + b;
+ res.z = a.z + b;
+ res.w = a.w + b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(Double4 value) {
+ x -= value.x;
+ y -= value.y;
+ z -= value.z;
+ w -= value.w;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(double value) {
+ x -= value;
+ y -= value;
+ z -= value;
+ w -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double4 sub(Double4 a, double b) {
+ Double4 res = new Double4();
+ res.x = a.x - b;
+ res.y = a.y - b;
+ res.z = a.z - b;
+ res.w = a.w - b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double4 sub(Double4 a, Double4 b) {
+ Double4 res = new Double4();
+ res.x = a.x - b.x;
+ res.y = a.y - b.y;
+ res.z = a.z - b.z;
+ res.w = a.w - b.w;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(Double4 value) {
+ x *= value.x;
+ y *= value.y;
+ z *= value.z;
+ w *= value.w;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(double value) {
+ x *= value;
+ y *= value;
+ z *= value;
+ w *= value;
+ }
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double4 mul(Double4 a, Double4 b) {
+ Double4 res = new Double4();
+ res.x = a.x * b.x;
+ res.y = a.y * b.y;
+ res.z = a.z * b.z;
+ res.w = a.w * b.w;
+ return res;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double4 mul(Double4 a, double b) {
+ Double4 res = new Double4();
+ res.x = a.x * b;
+ res.y = a.y * b;
+ res.z = a.z * b;
+ res.w = a.w * b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(Double4 value) {
+ x /= value.x;
+ y /= value.y;
+ z /= value.z;
+ w /= value.w;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(double value) {
+ x /= value;
+ y /= value;
+ z /= value;
+ w /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double4 div(Double4 a, double b) {
+ Double4 res = new Double4();
+ res.x = a.x / b;
+ res.y = a.y / b;
+ res.z = a.z / b;
+ res.w = a.w / b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Double4 div(Double4 a, Double4 b) {
+ Double4 res = new Double4();
+ res.x = a.x / b.x;
+ res.y = a.y / b.y;
+ res.z = a.z / b.z;
+ res.w = a.w / b.w;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public double dotProduct(Double4 a) {
+ return (x * a.x) + (y * a.y) + (z * a.z) + (w * a.w);
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static double dotProduct(Double4 a, Double4 b) {
+ return (b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w);
+ }
+
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Double4 a, double factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ z += a.z * factor;
+ w += a.w * factor;
+ }
+
+ /** @hide
+ * Set vector value by double4
+ *
+ * @param a
+ */
+ public void set(Double4 a) {
+ this.x = a.x;
+ this.y = a.y;
+ this.z = a.z;
+ this.w = a.w;
+ }
+
+ /** @hide
+ * Set vector negate
+ */
+ public void negate() {
+ x = -x;
+ y = -y;
+ z = -z;
+ w = -w;
+ }
+ /** @hide
+ * Get vector length
+ *
+ * @return
+ */
+ public int length() {
+ return 4;
+ }
+
+ /** @hide
+ * Return the element sum of vector
+ *
+ * @return
+ */
+ public double elementSum() {
+ return x + y + z + w;
+ }
+
+ /** @hide
+ * Get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public double get(int i) {
+ switch (i) {
+ case 0:
+ return x;
+ case 1:
+ return y;
+ case 2:
+ return z;
+ case 3:
+ return w;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * Set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, double value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ case 2:
+ z = value;
+ return;
+ case 3:
+ w = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * Add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, double value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ case 2:
+ z += value;
+ return;
+ case 3:
+ w += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * Set the vector field value
+ *
+ * @param x
+ * @param y
+ * @param z
+ * @param w
+ */
+ public void setValues(double x, double y, double z, double w) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
+ }
+
+ /** @hide
+ * Copy the vector to double array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(double[] data, int offset) {
+ data[offset] = x;
+ data[offset + 1] = y;
+ data[offset + 2] = z;
+ data[offset + 3] = w;
+ }
+}
diff --git a/graphics/java/android/renderscript/Float2.java b/graphics/java/android/renderscript/Float2.java
index 0f730fe..26193d2 100644
--- a/graphics/java/android/renderscript/Float2.java
+++ b/graphics/java/android/renderscript/Float2.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,27 +16,369 @@
package android.renderscript;
-import java.lang.Math;
-import android.util.Log;
-
-
/**
- * Class for exposing the native RenderScript float2 type back to the Android system.
- *
- **/
-public class Float2 {
+ * Vector version of the basic float type.
+ * Provides two float fields packed.
+ */
+public class Float2 {
+ public float x;
+ public float y;
+
public Float2() {
}
+ /** @hide */
+ public Float2(Float2 data) {
+ this.x = data.x;
+ this.y = data.y;
+ }
- public Float2(float initX, float initY) {
- x = initX;
- y = initY;
+ public Float2(float x, float y) {
+ this.x = x;
+ this.y = y;
}
- public float x;
- public float y;
-}
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float2 add(Float2 a, Float2 b) {
+ Float2 res = new Float2();
+ res.x = a.x + b.x;
+ res.y = a.y + b.y;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(Float2 value) {
+ x += value.x;
+ y += value.y;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(float value) {
+ x += value;
+ y += value;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float2 add(Float2 a, float b) {
+ Float2 res = new Float2();
+ res.x = a.x + b;
+ res.y = a.y + b;
+ return res;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(Float2 value) {
+ x -= value.x;
+ y -= value.y;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float2 sub(Float2 a, Float2 b) {
+ Float2 res = new Float2();
+ res.x = a.x - b.x;
+ res.y = a.y - b.y;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(float value) {
+ x -= value;
+ y -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float2 sub(Float2 a, float b) {
+ Float2 res = new Float2();
+ res.x = a.x - b;
+ res.y = a.y - b;
+ return res;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(Float2 value) {
+ x *= value.x;
+ y *= value.y;
+ }
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float2 mul(Float2 a, Float2 b) {
+ Float2 res = new Float2();
+ res.x = a.x * b.x;
+ res.y = a.y * b.y;
+
+ return res;
+ }
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(float value) {
+ x *= value;
+ y *= value;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float2 mul(Float2 a, float b) {
+ Float2 res = new Float2();
+ res.x = a.x * b;
+ res.y = a.y * b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(Float2 value) {
+ x /= value.x;
+ y /= value.y;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float2 div(Float2 a, Float2 b) {
+ Float2 res = new Float2();
+ res.x = a.x / b.x;
+ res.y = a.y / b.y;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(float value) {
+ x /= value;
+ y /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float2 div(Float2 a, float b) {
+ Float2 res = new Float2();
+ res.x = a.x / b;
+ res.y = a.y / b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public float dotProduct(Float2 a) {
+ return (x * a.x) + (y * a.y);
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static float dotProduct(Float2 a, Float2 b) {
+ return (b.x * a.x) + (b.y * a.y);
+ }
+
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Float2 a, float factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ }
+
+ /** @hide
+ * set vector value by float2
+ *
+ * @param a
+ */
+ public void set(Float2 a) {
+ this.x = a.x;
+ this.y = a.y;
+ }
+
+ /** @hide
+ * set vector negate
+ */
+ public void negate() {
+ x = -x;
+ y = -y;
+ }
+
+ /** @hide
+ * get vector length
+ *
+ * @return
+ */
+ public int length() {
+ return 2;
+ }
+
+ /** @hide
+ * return the element sum of vector
+ *
+ * @return
+ */
+ public float elementSum() {
+ return x + y;
+ }
+
+ /** @hide
+ * get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public float get(int i) {
+ switch (i) {
+ case 0:
+ return x;
+ case 1:
+ return y;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, float value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, float value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value
+ *
+ * @param x
+ * @param y
+ */
+ public void setValues(float x, float y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ /** @hide
+ * copy the vector to float array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(float[] data, int offset) {
+ data[offset] = x;
+ data[offset + 1] = y;
+ }
+}
diff --git a/graphics/java/android/renderscript/Float3.java b/graphics/java/android/renderscript/Float3.java
index 749865f..555bdf6 100644
--- a/graphics/java/android/renderscript/Float3.java
+++ b/graphics/java/android/renderscript/Float3.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,28 +16,402 @@
package android.renderscript;
-import java.lang.Math;
-import android.util.Log;
-
-
/**
- * Class for exposing the native RenderScript float2 type back to the Android system.
- *
- **/
+ * Vector version of the basic float type.
+ * Provides three float fields packed.
+ */
public class Float3 {
+ public float x;
+ public float y;
+ public float z;
+
public Float3() {
}
- public Float3(float initX, float initY, float initZ) {
- x = initX;
- y = initY;
- z = initZ;
+ /** @hide */
+ public Float3(Float3 data) {
+ this.x = data.x;
+ this.y = data.y;
+ this.z = data.z;
}
- public float x;
- public float y;
- public float z;
-}
+ public Float3(float x, float y, float z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float3 add(Float3 a, Float3 b) {
+ Float3 res = new Float3();
+ res.x = a.x + b.x;
+ res.y = a.y + b.y;
+ res.z = a.z + b.z;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(Float3 value) {
+ x += value.x;
+ y += value.y;
+ z += value.z;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(float value) {
+ x += value;
+ y += value;
+ z += value;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float3 add(Float3 a, float b) {
+ Float3 res = new Float3();
+ res.x = a.x + b;
+ res.y = a.y + b;
+ res.z = a.z + b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(Float3 value) {
+ x -= value.x;
+ y -= value.y;
+ z -= value.z;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float3 sub(Float3 a, Float3 b) {
+ Float3 res = new Float3();
+ res.x = a.x - b.x;
+ res.y = a.y - b.y;
+ res.z = a.z - b.z;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(float value) {
+ x -= value;
+ y -= value;
+ z -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float3 sub(Float3 a, float b) {
+ Float3 res = new Float3();
+ res.x = a.x - b;
+ res.y = a.y - b;
+ res.z = a.z - b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(Float3 value) {
+ x *= value.x;
+ y *= value.y;
+ z *= value.z;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float3 mul(Float3 a, Float3 b) {
+ Float3 res = new Float3();
+ res.x = a.x * b.x;
+ res.y = a.y * b.y;
+ res.z = a.z * b.z;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(float value) {
+ x *= value;
+ y *= value;
+ z *= value;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float3 mul(Float3 a, float b) {
+ Float3 res = new Float3();
+ res.x = a.x * b;
+ res.y = a.y * b;
+ res.z = a.z * b;
+
+ return res;
+ }
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(Float3 value) {
+ x /= value.x;
+ y /= value.y;
+ z /= value.z;
+ }
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float3 div(Float3 a, Float3 b) {
+ Float3 res = new Float3();
+ res.x = a.x / b.x;
+ res.y = a.y / b.y;
+ res.z = a.z / b.z;
+ return res;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(float value) {
+ x /= value;
+ y /= value;
+ z /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float3 div(Float3 a, float b) {
+ Float3 res = new Float3();
+ res.x = a.x / b;
+ res.y = a.y / b;
+ res.z = a.z / b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public Float dotProduct(Float3 a) {
+ return new Float((x * a.x) + (y * a.y) + (z * a.z));
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float dotProduct(Float3 a, Float3 b) {
+ return new Float((b.x * a.x) + (b.y * a.y) + (b.z * a.z));
+ }
+
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Float3 a, float factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ z += a.z * factor;
+ }
+ /** @hide
+ * set vector value by float3
+ *
+ * @param a
+ */
+ public void set(Float3 a) {
+ this.x = a.x;
+ this.y = a.y;
+ this.z = a.z;
+ }
+
+ /** @hide
+ * set vector negate
+ */
+ public void negate() {
+ x = -x;
+ y = -y;
+ z = -z;
+ }
+
+ /** @hide
+ * get vector length
+ *
+ * @return
+ */
+ public int length() {
+ return 3;
+ }
+
+ /** @hide
+ * return the element sum of vector
+ *
+ * @return
+ */
+ public Float elementSum() {
+ return new Float(x + y + z);
+ }
+
+ /** @hide
+ * get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public float get(int i) {
+ switch (i) {
+ case 0:
+ return x;
+ case 1:
+ return y;
+ case 2:
+ return z;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, float value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ case 2:
+ z = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, float value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ case 2:
+ z += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value
+ *
+ * @param x
+ * @param y
+ * @param z
+ */
+ public void setValues(float x, float y, float z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ /** @hide
+ * copy the vector to float array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(float[] data, int offset) {
+ data[offset] = x;
+ data[offset + 1] = y;
+ data[offset + 2] = z;
+ }
+}
diff --git a/graphics/java/android/renderscript/Float4.java b/graphics/java/android/renderscript/Float4.java
index 7ddf6aa..6541b2e 100644
--- a/graphics/java/android/renderscript/Float4.java
+++ b/graphics/java/android/renderscript/Float4.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,30 +16,435 @@
package android.renderscript;
-import java.lang.Math;
-import android.util.Log;
-
-
/**
- * Class for exposing the native RenderScript float2 type back to the Android system.
- *
- **/
+ * Vector version of the basic float type.
+ * Provides four float fields packed.
+ */
public class Float4 {
+ public float x;
+ public float y;
+ public float z;
+ public float w;
+
public Float4() {
}
+ /** @hide */
+ public Float4(Float4 data) {
+ this.x = data.x;
+ this.y = data.y;
+ this.z = data.z;
+ this.w = data.w;
+ }
- public Float4(float initX, float initY, float initZ, float initW) {
- x = initX;
- y = initY;
- z = initZ;
- w = initW;
+ public Float4(float x, float y, float z, float w) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
}
- public float x;
- public float y;
- public float z;
- public float w;
-}
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float4 add(Float4 a, Float4 b) {
+ Float4 res = new Float4();
+ res.x = a.x + b.x;
+ res.y = a.y + b.y;
+ res.z = a.z + b.z;
+ res.w = a.w + b.w;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(Float4 value) {
+ x += value.x;
+ y += value.y;
+ z += value.z;
+ w += value.w;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(float value) {
+ x += value;
+ y += value;
+ z += value;
+ w += value;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float4 add(Float4 a, float b) {
+ Float4 res = new Float4();
+ res.x = a.x + b;
+ res.y = a.y + b;
+ res.z = a.z + b;
+ res.w = a.w + b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(Float4 value) {
+ x -= value.x;
+ y -= value.y;
+ z -= value.z;
+ w -= value.w;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(float value) {
+ x -= value;
+ y -= value;
+ z -= value;
+ w -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float4 sub(Float4 a, float b) {
+ Float4 res = new Float4();
+ res.x = a.x - b;
+ res.y = a.y - b;
+ res.z = a.z - b;
+ res.w = a.w - b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float4 sub(Float4 a, Float4 b) {
+ Float4 res = new Float4();
+ res.x = a.x - b.x;
+ res.y = a.y - b.y;
+ res.z = a.z - b.z;
+ res.w = a.w - b.w;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(Float4 value) {
+ x *= value.x;
+ y *= value.y;
+ z *= value.z;
+ w *= value.w;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(float value) {
+ x *= value;
+ y *= value;
+ z *= value;
+ w *= value;
+ }
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float4 mul(Float4 a, Float4 b) {
+ Float4 res = new Float4();
+ res.x = a.x * b.x;
+ res.y = a.y * b.y;
+ res.z = a.z * b.z;
+ res.w = a.w * b.w;
+ return res;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float4 mul(Float4 a, float b) {
+ Float4 res = new Float4();
+ res.x = a.x * b;
+ res.y = a.y * b;
+ res.z = a.z * b;
+ res.w = a.w * b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(Float4 value) {
+ x /= value.x;
+ y /= value.y;
+ z /= value.z;
+ w /= value.w;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(float value) {
+ x /= value;
+ y /= value;
+ z /= value;
+ w /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float4 div(Float4 a, float b) {
+ Float4 res = new Float4();
+ res.x = a.x / b;
+ res.y = a.y / b;
+ res.z = a.z / b;
+ res.w = a.w / b;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Float4 div(Float4 a, Float4 b) {
+ Float4 res = new Float4();
+ res.x = a.x / b.x;
+ res.y = a.y / b.y;
+ res.z = a.z / b.z;
+ res.w = a.w / b.w;
+
+ return res;
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public float dotProduct(Float4 a) {
+ return (x * a.x) + (y * a.y) + (z * a.z) + (w * a.w);
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static float dotProduct(Float4 a, Float4 b) {
+ return (b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w);
+ }
+
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Float4 a, float factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ z += a.z * factor;
+ w += a.w * factor;
+ }
+
+ /** @hide
+ * set vector value by float4
+ *
+ * @param a
+ */
+ public void set(Float4 a) {
+ this.x = a.x;
+ this.y = a.y;
+ this.z = a.z;
+ this.w = a.w;
+ }
+
+ /** @hide
+ * set vector negate
+ */
+ public void negate() {
+ x = -x;
+ y = -y;
+ z = -z;
+ w = -w;
+ }
+ /** @hide
+ * get vector length
+ *
+ * @return
+ */
+ public int length() {
+ return 4;
+ }
+
+ /** @hide
+ * return the element sum of vector
+ *
+ * @return
+ */
+ public float elementSum() {
+ return x + y + z + w;
+ }
+
+ /** @hide
+ * get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public float get(int i) {
+ switch (i) {
+ case 0:
+ return x;
+ case 1:
+ return y;
+ case 2:
+ return z;
+ case 3:
+ return w;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, float value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ case 2:
+ z = value;
+ return;
+ case 3:
+ w = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, float value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ case 2:
+ z += value;
+ return;
+ case 3:
+ w += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value
+ *
+ * @param x
+ * @param y
+ * @param z
+ * @param w
+ */
+ public void setValues(float x, float y, float z, float w) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
+ }
+
+ /** @hide
+ * copy the vector to float array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(float[] data, int offset) {
+ data[offset] = x;
+ data[offset + 1] = y;
+ data[offset + 2] = z;
+ data[offset + 3] = w;
+ }
+}
diff --git a/graphics/java/android/renderscript/Int2.java b/graphics/java/android/renderscript/Int2.java
index 71b5dd5..120957b 100644
--- a/graphics/java/android/renderscript/Int2.java
+++ b/graphics/java/android/renderscript/Int2.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,27 +16,425 @@
package android.renderscript;
-import java.lang.Math;
-import android.util.Log;
-
-
/**
- * Class for exposing the native RenderScript int2 type back to the Android system.
- *
- **/
+ * Vector version of the basic int type.
+ * Provides two int fields packed.
+ */
public class Int2 {
+ public int x;
+ public int y;
+
public Int2() {
}
- public Int2(int initX, int initY) {
- x = initX;
- y = initY;
+ /** @hide */
+ public Int2(int i) {
+ this.x = this.y = i;
}
- public int x;
- public int y;
-}
+ public Int2(int x, int y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ /** @hide */
+ public Int2(Int2 source) {
+ this.x = source.x;
+ this.y = source.y;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ */
+ public void add(Int2 a) {
+ this.x += a.x;
+ this.y += a.y;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int2 add(Int2 a, Int2 b) {
+ Int2 result = new Int2();
+ result.x = a.x + b.x;
+ result.y = a.y + b.y;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(int value) {
+ x += value;
+ y += value;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int2 add(Int2 a, int b) {
+ Int2 result = new Int2();
+ result.x = a.x + b;
+ result.y = a.y + b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ */
+ public void sub(Int2 a) {
+ this.x -= a.x;
+ this.y -= a.y;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int2 sub(Int2 a, Int2 b) {
+ Int2 result = new Int2();
+ result.x = a.x - b.x;
+ result.y = a.y - b.y;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(int value) {
+ x -= value;
+ y -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int2 sub(Int2 a, int b) {
+ Int2 result = new Int2();
+ result.x = a.x - b;
+ result.y = a.y - b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ */
+ public void mul(Int2 a) {
+ this.x *= a.x;
+ this.y *= a.y;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int2 mul(Int2 a, Int2 b) {
+ Int2 result = new Int2();
+ result.x = a.x * b.x;
+ result.y = a.y * b.y;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(int value) {
+ x *= value;
+ y *= value;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int2 mul(Int2 a, int b) {
+ Int2 result = new Int2();
+ result.x = a.x * b;
+ result.y = a.y * b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ */
+ public void div(Int2 a) {
+ this.x /= a.x;
+ this.y /= a.y;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int2 div(Int2 a, Int2 b) {
+ Int2 result = new Int2();
+ result.x = a.x / b.x;
+ result.y = a.y / b.y;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(int value) {
+ x /= value;
+ y /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int2 div(Int2 a, int b) {
+ Int2 result = new Int2();
+ result.x = a.x / b;
+ result.y = a.y / b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ */
+ public void mod(Int2 a) {
+ this.x %= a.x;
+ this.y %= a.y;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int2 mod(Int2 a, Int2 b) {
+ Int2 result = new Int2();
+ result.x = a.x % b.x;
+ result.y = a.y % b.y;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param value
+ */
+ public void mod(int value) {
+ x %= value;
+ y %= value;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int2 mod(Int2 a, int b) {
+ Int2 result = new Int2();
+ result.x = a.x % b;
+ result.y = a.y % b;
+
+ return result;
+ }
+ /** @hide
+ * get vector length
+ *
+ * @return
+ */
+ public int length() {
+ return 2;
+ }
+
+ /** @hide
+ * set vector negate
+ */
+ public void negate() {
+ this.x = -x;
+ this.y = -y;
+ }
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public int dotProduct(Int2 a) {
+ return (int)((x * a.x) + (y * a.y));
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static int dotProduct(Int2 a, Int2 b) {
+ return (int)((b.x * a.x) + (b.y * a.y));
+ }
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Int2 a, int factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ }
+
+ /** @hide
+ * set vector value by Int2
+ *
+ * @param a
+ */
+ public void set(Int2 a) {
+ this.x = a.x;
+ this.y = a.y;
+ }
+
+ /** @hide
+ * set the vector field value by Int
+ *
+ * @param a
+ * @param b
+ */
+ public void setValues(int a, int b) {
+ this.x = a;
+ this.y = b;
+ }
+ /** @hide
+ * return the element sum of vector
+ *
+ * @return
+ */
+ public int elementSum() {
+ return (int)(x + y);
+ }
+
+ /** @hide
+ * get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public int get(int i) {
+ switch (i) {
+ case 0:
+ return (int)(x);
+ case 1:
+ return (int)(y);
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, int value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, int value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * copy the vector to int array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(int[] data, int offset) {
+ data[offset] = (int)(x);
+ data[offset + 1] = (int)(y);
+ }
+}
diff --git a/graphics/java/android/renderscript/Int3.java b/graphics/java/android/renderscript/Int3.java
index 719c908..c770395 100644
--- a/graphics/java/android/renderscript/Int3.java
+++ b/graphics/java/android/renderscript/Int3.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,29 +16,462 @@
package android.renderscript;
-import java.lang.Math;
-import android.util.Log;
-
-
/**
- * Class for exposing the native RenderScript int3 type back to the Android system.
- *
- **/
+ * Vector version of the basic int type.
+ * Provides three int fields packed.
+ */
public class Int3 {
+ public int x;
+ public int y;
+ public int z;
+
public Int3() {
}
+
+ /** @hide */
+ public Int3(int i) {
+ this.x = this.y = this.z = i;
+ }
- public Int3(int initX, int initY, int initZ) {
- x = initX;
- y = initY;
- z = initZ;
+ public Int3(int x, int y, int z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
}
- public int x;
- public int y;
- public int z;
-}
+ /** @hide */
+ public Int3(Int3 source) {
+ this.x = source.x;
+ this.y = source.y;
+ this.z = source.z;
+ }
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ */
+ public void add(Int3 a) {
+ this.x += a.x;
+ this.y += a.y;
+ this.z += a.z;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int3 add(Int3 a, Int3 b) {
+ Int3 result = new Int3();
+ result.x = a.x + b.x;
+ result.y = a.y + b.y;
+ result.z = a.z + b.z;
+ return result;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(int value) {
+ x += value;
+ y += value;
+ z += value;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int3 add(Int3 a, int b) {
+ Int3 result = new Int3();
+ result.x = a.x + b;
+ result.y = a.y + b;
+ result.z = a.z + b;
+
+ return result;
+ }
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ */
+ public void sub(Int3 a) {
+ this.x -= a.x;
+ this.y -= a.y;
+ this.z -= a.z;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int3 sub(Int3 a, Int3 b) {
+ Int3 result = new Int3();
+ result.x = a.x - b.x;
+ result.y = a.y - b.y;
+ result.z = a.z - b.z;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(int value) {
+ x -= value;
+ y -= value;
+ z -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int3 sub(Int3 a, int b) {
+ Int3 result = new Int3();
+ result.x = a.x - b;
+ result.y = a.y - b;
+ result.z = a.z - b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ */
+ public void mul(Int3 a) {
+ this.x *= a.x;
+ this.y *= a.y;
+ this.z *= a.z;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int3 mul(Int3 a, Int3 b) {
+ Int3 result = new Int3();
+ result.x = a.x * b.x;
+ result.y = a.y * b.y;
+ result.z = a.z * b.z;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(int value) {
+ x *= value;
+ y *= value;
+ z *= value;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int3 mul(Int3 a, int b) {
+ Int3 result = new Int3();
+ result.x = a.x * b;
+ result.y = a.y * b;
+ result.z = a.z * b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ */
+ public void div(Int3 a) {
+ this.x /= a.x;
+ this.y /= a.y;
+ this.z /= a.z;
+ }
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int3 div(Int3 a, Int3 b) {
+ Int3 result = new Int3();
+ result.x = a.x / b.x;
+ result.y = a.y / b.y;
+ result.z = a.z / b.z;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(int value) {
+ x /= value;
+ y /= value;
+ z /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int3 div(Int3 a, int b) {
+ Int3 result = new Int3();
+ result.x = a.x / b;
+ result.y = a.y / b;
+ result.z = a.z / b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ */
+ public void mod(Int3 a) {
+ this.x %= a.x;
+ this.y %= a.y;
+ this.z %= a.z;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int3 mod(Int3 a, Int3 b) {
+ Int3 result = new Int3();
+ result.x = a.x % b.x;
+ result.y = a.y % b.y;
+ result.z = a.z % b.z;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param value
+ */
+ public void mod(int value) {
+ x %= value;
+ y %= value;
+ z %= value;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int3 mod(Int3 a, int b) {
+ Int3 result = new Int3();
+ result.x = a.x % b;
+ result.y = a.y % b;
+ result.z = a.z % b;
+
+ return result;
+ }
+
+ /** @hide
+ * get vector length
+ *
+ * @return
+ */
+ public int length() {
+ return 3;
+ }
+
+ /** @hide
+ * set vector negate
+ */
+ public void negate() {
+ this.x = -x;
+ this.y = -y;
+ this.z = -z;
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public int dotProduct(Int3 a) {
+ return (int)((x * a.x) + (y * a.y) + (z * a.z));
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static int dotProduct(Int3 a, Int3 b) {
+ return (int)((b.x * a.x) + (b.y * a.y) + (b.z * a.z));
+ }
+
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Int3 a, int factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ z += a.z * factor;
+ }
+
+ /** @hide
+ * set vector value by Int3
+ *
+ * @param a
+ */
+ public void set(Int3 a) {
+ this.x = a.x;
+ this.y = a.y;
+ this.z = a.z;
+ }
+
+ /** @hide
+ * set the vector field value by Int
+ *
+ * @param a
+ * @param b
+ * @param c
+ */
+ public void setValues(int a, int b, int c) {
+ this.x = a;
+ this.y = b;
+ this.z = c;
+ }
+
+ /** @hide
+ * return the element sum of vector
+ *
+ * @return
+ */
+ public int elementSum() {
+ return (int)(x + y + z);
+ }
+
+ /** @hide
+ * get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public int get(int i) {
+ switch (i) {
+ case 0:
+ return (int)(x);
+ case 1:
+ return (int)(y);
+ case 2:
+ return (int)(z);
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, int value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ case 2:
+ z = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, int value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ case 2:
+ z += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * copy the vector to int array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(int[] data, int offset) {
+ data[offset] = (int)(x);
+ data[offset + 1] = (int)(y);
+ data[offset + 2] = (int)(z);
+ }
+}
diff --git a/graphics/java/android/renderscript/Int4.java b/graphics/java/android/renderscript/Int4.java
index eefb349..1c0e2e2 100644
--- a/graphics/java/android/renderscript/Int4.java
+++ b/graphics/java/android/renderscript/Int4.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,30 +16,499 @@
package android.renderscript;
-import java.lang.Math;
-import android.util.Log;
-
-
/**
- * Class for exposing the native RenderScript int4 type back to the Android system.
- *
- **/
+ * Vector version of the basic int type.
+ * Provides four int fields packed.
+ */
public class Int4 {
+ public int x;
+ public int y;
+ public int z;
+ public int w;
+
public Int4() {
}
- public Int4(int initX, int initY, int initZ, int initW) {
- x = initX;
- y = initY;
- z = initZ;
- w = initW;
+ /** @hide */
+ public Int4(int i) {
+ this.x = this.y = this.z = this.w = i;
}
- public int x;
- public int y;
- public int z;
- public int w;
-}
+ public Int4(int x, int y, int z, int w) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
+ }
+ /** @hide */
+ public Int4(Int4 source) {
+ this.x = source.x;
+ this.y = source.y;
+ this.z = source.z;
+ this.w = source.w;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ */
+ public void add(Int4 a) {
+ this.x += a.x;
+ this.y += a.y;
+ this.z += a.z;
+ this.w += a.w;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int4 add(Int4 a, Int4 b) {
+ Int4 result = new Int4();
+ result.x = a.x + b.x;
+ result.y = a.y + b.y;
+ result.z = a.z + b.z;
+ result.w = a.w + b.w;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(int value) {
+ x += value;
+ y += value;
+ z += value;
+ w += value;
+ }
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int4 add(Int4 a, int b) {
+ Int4 result = new Int4();
+ result.x = a.x + b;
+ result.y = a.y + b;
+ result.z = a.z + b;
+ result.w = a.w + b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ */
+ public void sub(Int4 a) {
+ this.x -= a.x;
+ this.y -= a.y;
+ this.z -= a.z;
+ this.w -= a.w;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int4 sub(Int4 a, Int4 b) {
+ Int4 result = new Int4();
+ result.x = a.x - b.x;
+ result.y = a.y - b.y;
+ result.z = a.z - b.z;
+ result.w = a.w - b.w;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(int value) {
+ x -= value;
+ y -= value;
+ z -= value;
+ w -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int4 sub(Int4 a, int b) {
+ Int4 result = new Int4();
+ result.x = a.x - b;
+ result.y = a.y - b;
+ result.z = a.z - b;
+ result.w = a.w - b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ */
+ public void mul(Int4 a) {
+ this.x *= a.x;
+ this.y *= a.y;
+ this.z *= a.z;
+ this.w *= a.w;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int4 mul(Int4 a, Int4 b) {
+ Int4 result = new Int4();
+ result.x = a.x * b.x;
+ result.y = a.y * b.y;
+ result.z = a.z * b.z;
+ result.w = a.w * b.w;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(int value) {
+ x *= value;
+ y *= value;
+ z *= value;
+ w *= value;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int4 mul(Int4 a, int b) {
+ Int4 result = new Int4();
+ result.x = a.x * b;
+ result.y = a.y * b;
+ result.z = a.z * b;
+ result.w = a.w * b;
+
+ return result;
+ }
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ */
+ public void div(Int4 a) {
+ this.x /= a.x;
+ this.y /= a.y;
+ this.z /= a.z;
+ this.w /= a.w;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int4 div(Int4 a, Int4 b) {
+ Int4 result = new Int4();
+ result.x = a.x / b.x;
+ result.y = a.y / b.y;
+ result.z = a.z / b.z;
+ result.w = a.w / b.w;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(int value) {
+ x /= value;
+ y /= value;
+ z /= value;
+ w /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int4 div(Int4 a, int b) {
+ Int4 result = new Int4();
+ result.x = a.x / b;
+ result.y = a.y / b;
+ result.z = a.z / b;
+ result.w = a.w / b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ */
+ public void mod(Int4 a) {
+ this.x %= a.x;
+ this.y %= a.y;
+ this.z %= a.z;
+ this.w %= a.w;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int4 mod(Int4 a, Int4 b) {
+ Int4 result = new Int4();
+ result.x = a.x % b.x;
+ result.y = a.y % b.y;
+ result.z = a.z % b.z;
+ result.w = a.w % b.w;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param value
+ */
+ public void mod(int value) {
+ x %= value;
+ y %= value;
+ z %= value;
+ w %= value;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Int4 mod(Int4 a, int b) {
+ Int4 result = new Int4();
+ result.x = a.x % b;
+ result.y = a.y % b;
+ result.z = a.z % b;
+ result.w = a.w % b;
+
+ return result;
+ }
+
+ /** @hide
+ * get vector length
+ *
+ * @return
+ */
+ public int length() {
+ return 4;
+ }
+
+ /** @hide
+ * set vector negate
+ */
+ public void negate() {
+ this.x = -x;
+ this.y = -y;
+ this.z = -z;
+ this.w = -w;
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public int dotProduct(Int4 a) {
+ return (int)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w));
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static int dotProduct(Int4 a, Int4 b) {
+ return (int)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w));
+ }
+
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Int4 a, int factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ z += a.z * factor;
+ w += a.w * factor;
+ }
+
+ /** @hide
+ * set vector value by Int4
+ *
+ * @param a
+ */
+ public void set(Int4 a) {
+ this.x = a.x;
+ this.y = a.y;
+ this.z = a.z;
+ this.w = a.w;
+ }
+
+ /** @hide
+ * set the vector field value by Int
+ *
+ * @param a
+ * @param b
+ * @param c
+ * @param d
+ */
+ public void setValues(int a, int b, int c, int d) {
+ this.x = a;
+ this.y = b;
+ this.z = c;
+ this.w = d;
+ }
+
+ /** @hide
+ * return the element sum of vector
+ *
+ * @return
+ */
+ public int elementSum() {
+ return (int)(x + y + z + w);
+ }
+
+ /** @hide
+ * get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public int get(int i) {
+ switch (i) {
+ case 0:
+ return (int)(x);
+ case 1:
+ return (int)(y);
+ case 2:
+ return (int)(z);
+ case 3:
+ return (int)(w);
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, int value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ case 2:
+ z = value;
+ return;
+ case 3:
+ w = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, int value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ case 2:
+ z += value;
+ return;
+ case 3:
+ w += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * copy the vector to int array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(int[] data, int offset) {
+ data[offset] = (int)(x);
+ data[offset + 1] = (int)(y);
+ data[offset + 2] = (int)(z);
+ data[offset + 3] = (int)(w);
+ }
+}
diff --git a/graphics/java/android/renderscript/Long2.java b/graphics/java/android/renderscript/Long2.java
index bd8382d..fabf204 100644
--- a/graphics/java/android/renderscript/Long2.java
+++ b/graphics/java/android/renderscript/Long2.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,26 +16,425 @@
package android.renderscript;
-import java.lang.Math;
-import android.util.Log;
-
-
/**
- * Class for exposing the native RenderScript long2 type back to the Android system.
- **/
+ * Vector version of the basic long type.
+ * Provides two long fields packed.
+ */
public class Long2 {
+ public long x;
+ public long y;
+
public Long2() {
}
- public Long2(long initX, long initY) {
- x = initX;
- y = initY;
+ /** @hide */
+ public Long2(long i) {
+ this.x = this.y = i;
}
- public long x;
- public long y;
-}
+ public Long2(long x, long y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ /** @hide */
+ public Long2(Long2 source) {
+ this.x = source.x;
+ this.y = source.y;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ */
+ public void add(Long2 a) {
+ this.x += a.x;
+ this.y += a.y;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long2 add(Long2 a, Long2 b) {
+ Long2 result = new Long2();
+ result.x = a.x + b.x;
+ result.y = a.y + b.y;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(long value) {
+ x += value;
+ y += value;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long2 add(Long2 a, long b) {
+ Long2 result = new Long2();
+ result.x = a.x + b;
+ result.y = a.y + b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ */
+ public void sub(Long2 a) {
+ this.x -= a.x;
+ this.y -= a.y;
+ }
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long2 sub(Long2 a, Long2 b) {
+ Long2 result = new Long2();
+ result.x = a.x - b.x;
+ result.y = a.y - b.y;
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(long value) {
+ x -= value;
+ y -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long2 sub(Long2 a, long b) {
+ Long2 result = new Long2();
+ result.x = a.x - b;
+ result.y = a.y - b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ */
+ public void mul(Long2 a) {
+ this.x *= a.x;
+ this.y *= a.y;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long2 mul(Long2 a, Long2 b) {
+ Long2 result = new Long2();
+ result.x = a.x * b.x;
+ result.y = a.y * b.y;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(long value) {
+ x *= value;
+ y *= value;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long2 mul(Long2 a, long b) {
+ Long2 result = new Long2();
+ result.x = a.x * b;
+ result.y = a.y * b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ */
+ public void div(Long2 a) {
+ this.x /= a.x;
+ this.y /= a.y;
+ }
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long2 div(Long2 a, Long2 b) {
+ Long2 result = new Long2();
+ result.x = a.x / b.x;
+ result.y = a.y / b.y;
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(long value) {
+ x /= value;
+ y /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long2 div(Long2 a, long b) {
+ Long2 result = new Long2();
+ result.x = a.x / b;
+ result.y = a.y / b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ */
+ public void mod(Long2 a) {
+ this.x %= a.x;
+ this.y %= a.y;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long2 mod(Long2 a, Long2 b) {
+ Long2 result = new Long2();
+ result.x = a.x % b.x;
+ result.y = a.y % b.y;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param value
+ */
+ public void mod(long value) {
+ x %= value;
+ y %= value;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long2 mod(Long2 a, long b) {
+ Long2 result = new Long2();
+ result.x = a.x % b;
+ result.y = a.y % b;
+
+ return result;
+ }
+
+ /** @hide
+ * get vector length
+ *
+ * @return
+ */
+ public long length() {
+ return 2;
+ }
+
+ /** @hide
+ * set vector negate
+ */
+ public void negate() {
+ this.x = -x;
+ this.y = -y;
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public long dotProduct(Long2 a) {
+ return (long)((x * a.x) + (y * a.y));
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static long dotProduct(Long2 a, Long2 b) {
+ return (long)((b.x * a.x) + (b.y * a.y));
+ }
+
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Long2 a, long factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ }
+
+ /** @hide
+ * set vector value by Long2
+ *
+ * @param a
+ */
+ public void set(Long2 a) {
+ this.x = a.x;
+ this.y = a.y;
+ }
+
+ /** @hide
+ * set the vector field value by Long
+ *
+ * @param a
+ * @param b
+ */
+ public void setValues(long a, long b) {
+ this.x = a;
+ this.y = b;
+ }
+
+ /** @hide
+ * return the element sum of vector
+ *
+ * @return
+ */
+ public long elementSum() {
+ return (long)(x + y);
+ }
+
+ /** @hide
+ * get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public long get(int i) {
+ switch (i) {
+ case 0:
+ return (long)(x);
+ case 1:
+ return (long)(y);
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, long value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, long value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * copy the vector to long array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(long[] data, int offset) {
+ data[offset] = (long)(x);
+ data[offset + 1] = (long)(y);
+ }
+}
diff --git a/graphics/java/android/renderscript/Long3.java b/graphics/java/android/renderscript/Long3.java
index 3e94942..88ff855 100644
--- a/graphics/java/android/renderscript/Long3.java
+++ b/graphics/java/android/renderscript/Long3.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,28 +16,462 @@
package android.renderscript;
-import java.lang.Math;
-import android.util.Log;
-
-
/**
- * Class for exposing the native RenderScript long3 type back to the Android system.
- **/
+ * Vector version of the basic long type.
+ * Provides three long fields packed.
+ */
public class Long3 {
+ public long x;
+ public long y;
+ public long z;
+
public Long3() {
}
+
+ /** @hide */
+ public Long3(long i) {
+ this.x = this.y = this.z = i;
+ }
- public Long3(long initX, long initY, long initZ) {
- x = initX;
- y = initY;
- z = initZ;
+ public Long3(long x, long y, long z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
}
- public long x;
- public long y;
- public long z;
-}
+ /** @hide */
+ public Long3(Long3 source) {
+ this.x = source.x;
+ this.y = source.y;
+ this.z = source.z;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ */
+ public void add(Long3 a) {
+ this.x += a.x;
+ this.y += a.y;
+ this.z += a.z;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long3 add(Long3 a, Long3 b) {
+ Long3 result = new Long3();
+ result.x = a.x + b.x;
+ result.y = a.y + b.y;
+ result.z = a.z + b.z;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(long value) {
+ x += value;
+ y += value;
+ z += value;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long3 add(Long3 a, long b) {
+ Long3 result = new Long3();
+ result.x = a.x + b;
+ result.y = a.y + b;
+ result.z = a.z + b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ */
+ public void sub(Long3 a) {
+ this.x -= a.x;
+ this.y -= a.y;
+ this.z -= a.z;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long3 sub(Long3 a, Long3 b) {
+ Long3 result = new Long3();
+ result.x = a.x - b.x;
+ result.y = a.y - b.y;
+ result.z = a.z - b.z;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(long value) {
+ x -= value;
+ y -= value;
+ z -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long3 sub(Long3 a, long b) {
+ Long3 result = new Long3();
+ result.x = a.x - b;
+ result.y = a.y - b;
+ result.z = a.z - b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ */
+ public void mul(Long3 a) {
+ this.x *= a.x;
+ this.y *= a.y;
+ this.z *= a.z;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long3 mul(Long3 a, Long3 b) {
+ Long3 result = new Long3();
+ result.x = a.x * b.x;
+ result.y = a.y * b.y;
+ result.z = a.z * b.z;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(long value) {
+ x *= value;
+ y *= value;
+ z *= value;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long3 mul(Long3 a, long b) {
+ Long3 result = new Long3();
+ result.x = a.x * b;
+ result.y = a.y * b;
+ result.z = a.z * b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ */
+ public void div(Long3 a) {
+ this.x /= a.x;
+ this.y /= a.y;
+ this.z /= a.z;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long3 div(Long3 a, Long3 b) {
+ Long3 result = new Long3();
+ result.x = a.x / b.x;
+ result.y = a.y / b.y;
+ result.z = a.z / b.z;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(long value) {
+ x /= value;
+ y /= value;
+ z /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long3 div(Long3 a, long b) {
+ Long3 result = new Long3();
+ result.x = a.x / b;
+ result.y = a.y / b;
+ result.z = a.z / b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ */
+ public void mod(Long3 a) {
+ this.x %= a.x;
+ this.y %= a.y;
+ this.z %= a.z;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long3 mod(Long3 a, Long3 b) {
+ Long3 result = new Long3();
+ result.x = a.x % b.x;
+ result.y = a.y % b.y;
+ result.z = a.z % b.z;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param value
+ */
+ public void mod(long value) {
+ x %= value;
+ y %= value;
+ z %= value;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long3 mod(Long3 a, long b) {
+ Long3 result = new Long3();
+ result.x = a.x % b;
+ result.y = a.y % b;
+ result.z = a.z % b;
+
+ return result;
+ }
+ /** @hide
+ * get vector length
+ *
+ * @return
+ */
+ public long length() {
+ return 3;
+ }
+
+ /** @hide
+ * set vector negate
+ */
+ public void negate() {
+ this.x = -x;
+ this.y = -y;
+ this.z = -z;
+ }
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public long dotProduct(Long3 a) {
+ return (long)((x * a.x) + (y * a.y) + (z * a.z));
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static long dotProduct(Long3 a, Long3 b) {
+ return (long)((b.x * a.x) + (b.y * a.y) + (b.z * a.z));
+ }
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Long3 a, long factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ z += a.z * factor;
+ }
+
+ /** @hide
+ * set vector value by Long3
+ *
+ * @param a
+ */
+ public void set(Long3 a) {
+ this.x = a.x;
+ this.y = a.y;
+ this.z = a.z;
+ }
+
+ /** @hide
+ * set the vector field value by Long
+ *
+ * @param a
+ * @param b
+ * @param c
+ */
+ public void setValues(long a, long b, long c) {
+ this.x = a;
+ this.y = b;
+ this.z = c;
+ }
+ /** @hide
+ * return the element sum of vector
+ *
+ * @return
+ */
+ public long elementSum() {
+ return (long)(x + y + z);
+ }
+
+ /** @hide
+ * get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public long get(int i) {
+ switch (i) {
+ case 0:
+ return (long)(x);
+ case 1:
+ return (long)(y);
+ case 2:
+ return (long)(z);
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, long value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ case 2:
+ z = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, long value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ case 2:
+ z += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * copy the vector to long array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(long[] data, int offset) {
+ data[offset] = (long)(x);
+ data[offset + 1] = (long)(y);
+ data[offset + 2] = (long)(z);
+ }
+}
diff --git a/graphics/java/android/renderscript/Long4.java b/graphics/java/android/renderscript/Long4.java
index 00fb7e6..757b910 100644
--- a/graphics/java/android/renderscript/Long4.java
+++ b/graphics/java/android/renderscript/Long4.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,29 +16,499 @@
package android.renderscript;
-import java.lang.Math;
-import android.util.Log;
-
-
/**
- * Class for exposing the native RenderScript long4 type back to the Android system.
- **/
+ * Vector version of the basic long type.
+ * Provides four long fields packed.
+ */
public class Long4 {
+ public long x;
+ public long y;
+ public long z;
+ public long w;
+
public Long4() {
}
- public Long4(long initX, long initY, long initZ, long initW) {
- x = initX;
- y = initY;
- z = initZ;
- w = initW;
+ /** @hide */
+ public Long4(long i) {
+ this.x = this.y = this.z = this.w = i;
}
- public long x;
- public long y;
- public long z;
- public long w;
-}
+ public Long4(long x, long y, long z, long w) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
+ }
+
+ /** @hide */
+ public Long4(Long4 source) {
+ this.x = source.x;
+ this.y = source.y;
+ this.z = source.z;
+ this.w = source.w;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ */
+ public void add(Long4 a) {
+ this.x += a.x;
+ this.y += a.y;
+ this.z += a.z;
+ this.w += a.w;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long4 add(Long4 a, Long4 b) {
+ Long4 result = new Long4();
+ result.x = a.x + b.x;
+ result.y = a.y + b.y;
+ result.z = a.z + b.z;
+ result.w = a.w + b.w;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(long value) {
+ x += value;
+ y += value;
+ z += value;
+ w += value;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long4 add(Long4 a, long b) {
+ Long4 result = new Long4();
+ result.x = a.x + b;
+ result.y = a.y + b;
+ result.z = a.z + b;
+ result.w = a.w + b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ */
+ public void sub(Long4 a) {
+ this.x -= a.x;
+ this.y -= a.y;
+ this.z -= a.z;
+ this.w -= a.w;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long4 sub(Long4 a, Long4 b) {
+ Long4 result = new Long4();
+ result.x = a.x - b.x;
+ result.y = a.y - b.y;
+ result.z = a.z - b.z;
+ result.w = a.w - b.w;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(long value) {
+ x -= value;
+ y -= value;
+ z -= value;
+ w -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long4 sub(Long4 a, long b) {
+ Long4 result = new Long4();
+ result.x = a.x - b;
+ result.y = a.y - b;
+ result.z = a.z - b;
+ result.w = a.w - b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ */
+ public void mul(Long4 a) {
+ this.x *= a.x;
+ this.y *= a.y;
+ this.z *= a.z;
+ this.w *= a.w;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long4 mul(Long4 a, Long4 b) {
+ Long4 result = new Long4();
+ result.x = a.x * b.x;
+ result.y = a.y * b.y;
+ result.z = a.z * b.z;
+ result.w = a.w * b.w;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(long value) {
+ x *= value;
+ y *= value;
+ z *= value;
+ w *= value;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long4 mul(Long4 a, long b) {
+ Long4 result = new Long4();
+ result.x = a.x * b;
+ result.y = a.y * b;
+ result.z = a.z * b;
+ result.w = a.w * b;
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ */
+ public void div(Long4 a) {
+ this.x /= a.x;
+ this.y /= a.y;
+ this.z /= a.z;
+ this.w /= a.w;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long4 div(Long4 a, Long4 b) {
+ Long4 result = new Long4();
+ result.x = a.x / b.x;
+ result.y = a.y / b.y;
+ result.z = a.z / b.z;
+ result.w = a.w / b.w;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(long value) {
+ x /= value;
+ y /= value;
+ z /= value;
+ w /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long4 div(Long4 a, long b) {
+ Long4 result = new Long4();
+ result.x = a.x / b;
+ result.y = a.y / b;
+ result.z = a.z / b;
+ result.w = a.w / b;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ */
+ public void mod(Long4 a) {
+ this.x %= a.x;
+ this.y %= a.y;
+ this.z %= a.z;
+ this.w %= a.w;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long4 mod(Long4 a, Long4 b) {
+ Long4 result = new Long4();
+ result.x = a.x % b.x;
+ result.y = a.y % b.y;
+ result.z = a.z % b.z;
+ result.w = a.w % b.w;
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param value
+ */
+ public void mod(long value) {
+ x %= value;
+ y %= value;
+ z %= value;
+ w %= value;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Long4 mod(Long4 a, long b) {
+ Long4 result = new Long4();
+ result.x = a.x % b;
+ result.y = a.y % b;
+ result.z = a.z % b;
+ result.w = a.w % b;
+
+ return result;
+ }
+
+ /** @hide
+ * get vector length
+ *
+ * @return
+ */
+ public long length() {
+ return 4;
+ }
+
+ /** @hide
+ * set vector negate
+ */
+ public void negate() {
+ this.x = -x;
+ this.y = -y;
+ this.z = -z;
+ this.w = -w;
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public long dotProduct(Long4 a) {
+ return (long)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w));
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static long dotProduct(Long4 a, Long4 b) {
+ return (long)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w));
+ }
+
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Long4 a, long factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ z += a.z * factor;
+ w += a.w * factor;
+ }
+
+ /** @hide
+ * set vector value by Long4
+ *
+ * @param a
+ */
+ public void set(Long4 a) {
+ this.x = a.x;
+ this.y = a.y;
+ this.z = a.z;
+ this.w = a.w;
+ }
+ /** @hide
+ * set the vector field value by Long
+ *
+ * @param a
+ * @param b
+ * @param c
+ * @param d
+ */
+ public void setValues(long a, long b, long c, long d) {
+ this.x = a;
+ this.y = b;
+ this.z = c;
+ this.w = d;
+ }
+
+ /** @hide
+ * return the element sum of vector
+ *
+ * @return
+ */
+ public long elementSum() {
+ return (long)(x + y + z + w);
+ }
+ /** @hide
+ * get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public long get(int i) {
+ switch (i) {
+ case 0:
+ return (long)(x);
+ case 1:
+ return (long)(y);
+ case 2:
+ return (long)(z);
+ case 3:
+ return (long)(w);
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, long value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ case 2:
+ z = value;
+ return;
+ case 3:
+ w = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, long value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ case 2:
+ z += value;
+ return;
+ case 3:
+ w += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * copy the vector to long array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(Long[] data, int offset) {
+ data[offset] = (long)(x);
+ data[offset + 1] = (long)(y);
+ data[offset + 2] = (long)(z);
+ data[offset + 3] = (long)(w);
+ }
+}
diff --git a/graphics/java/android/renderscript/Short2.java b/graphics/java/android/renderscript/Short2.java
index 7c6027f..070d608 100644
--- a/graphics/java/android/renderscript/Short2.java
+++ b/graphics/java/android/renderscript/Short2.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,27 +16,425 @@
package android.renderscript;
-import java.lang.Math;
-import android.util.Log;
-
-
-/**
- * Class for exposing the native RenderScript Short2 type back to the Android system.
- *
- **/
+/**
+ * Vector version of the basic short type.
+ * Provides two short fields packed.
+ */
public class Short2 {
+ public short x;
+ public short y;
+
public Short2() {
}
- public Short2(short initX, short initY) {
- x = initX;
- y = initY;
+ /** @hide */
+ public Short2(short i) {
+ this.x = this.y = i;
}
- public short x;
- public short y;
-}
+ public Short2(short x, short y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ /** @hide */
+ public Short2(Short2 source) {
+ this.x = source.x;
+ this.y = source.y;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ */
+ public void add(Short2 a) {
+ this.x += a.x;
+ this.y += a.y;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short2 add(Short2 a, Short2 b) {
+ Short2 result = new Short2();
+ result.x = (short)(a.x + b.x);
+ result.y = (short)(a.y + b.y);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(short value) {
+ x += value;
+ y += value;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short2 add(Short2 a, short b) {
+ Short2 result = new Short2();
+ result.x = (short)(a.x + b);
+ result.y = (short)(a.y + b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ */
+ public void sub(Short2 a) {
+ this.x -= a.x;
+ this.y -= a.y;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short2 sub(Short2 a, Short2 b) {
+ Short2 result = new Short2();
+ result.x = (short)(a.x - b.x);
+ result.y = (short)(a.y - b.y);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(short value) {
+ x -= value;
+ y -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short2 sub(Short2 a, short b) {
+ Short2 result = new Short2();
+ result.x = (short)(a.x - b);
+ result.y = (short)(a.y - b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ */
+ public void mul(Short2 a) {
+ this.x *= a.x;
+ this.y *= a.y;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short2 mul(Short2 a, Short2 b) {
+ Short2 result = new Short2();
+ result.x = (short)(a.x * b.x);
+ result.y = (short)(a.y * b.y);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(short value) {
+ x *= value;
+ y *= value;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short2 mul(Short2 a, short b) {
+ Short2 result = new Short2();
+ result.x = (short)(a.x * b);
+ result.y = (short)(a.y * b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ */
+ public void div(Short2 a) {
+ this.x /= a.x;
+ this.y /= a.y;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short2 div(Short2 a, Short2 b) {
+ Short2 result = new Short2();
+ result.x = (short)(a.x / b.x);
+ result.y = (short)(a.y / b.y);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(short value) {
+ x /= value;
+ y /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short2 div(Short2 a, short b) {
+ Short2 result = new Short2();
+ result.x = (short)(a.x / b);
+ result.y = (short)(a.y / b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ */
+ public void mod(Short2 a) {
+ this.x %= a.x;
+ this.y %= a.y;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short2 mod(Short2 a, Short2 b) {
+ Short2 result = new Short2();
+ result.x = (short)(a.x % b.x);
+ result.y = (short)(a.y % b.y);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param value
+ */
+ public void mod(short value) {
+ x %= value;
+ y %= value;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short2 mod(Short2 a, short b) {
+ Short2 result = new Short2();
+ result.x = (short)(a.x % b);
+ result.y = (short)(a.y % b);
+
+ return result;
+ }
+ /** @hide
+ * get vector length
+ *
+ * @return
+ */
+ public short length() {
+ return 2;
+ }
+
+ /** @hide
+ * set vector negate
+ */
+ public void negate() {
+ this.x = (short)(-x);
+ this.y = (short)(-y);
+ }
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public short dotProduct(Short2 a) {
+ return (short)((x * a.x) + (y * a.y));
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static short dotProduct(Short2 a, Short2 b) {
+ return (short)((b.x * a.x) + (b.y * a.y));
+ }
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Short2 a, short factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ }
+
+ /** @hide
+ * set vector value by Short2
+ *
+ * @param a
+ */
+ public void set(Short2 a) {
+ this.x = a.x;
+ this.y = a.y;
+ }
+
+ /** @hide
+ * set the vector field value by Short
+ *
+ * @param a
+ * @param b
+ */
+ public void setValues(short a, short b) {
+ this.x = a;
+ this.y = b;
+ }
+ /** @hide
+ * return the element sum of vector
+ *
+ * @return
+ */
+ public short elementSum() {
+ return (short)(x + y);
+ }
+
+ /** @hide
+ * get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public short get(int i) {
+ switch (i) {
+ case 0:
+ return (short)(x);
+ case 1:
+ return (short)(y);
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, short value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, short value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * copy the vector to short array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(short[] data, int offset) {
+ data[offset] = (short)(x);
+ data[offset + 1] = (short)(y);
+ }
+}
diff --git a/graphics/java/android/renderscript/Short3.java b/graphics/java/android/renderscript/Short3.java
index 49de05e..661db0a 100644
--- a/graphics/java/android/renderscript/Short3.java
+++ b/graphics/java/android/renderscript/Short3.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,29 +16,462 @@
package android.renderscript;
-import java.lang.Math;
-import android.util.Log;
-
-
/**
- * Class for exposing the native RenderScript short3 type back to the Android system.
- *
- **/
+ * Vector version of the basic short type.
+ * Provides three short fields packed.
+ */
public class Short3 {
+ public short x;
+ public short y;
+ public short z;
+
public Short3() {
}
- public Short3(short initX, short initY, short initZ) {
- x = initX;
- y = initY;
- z = initZ;
+ /** @hide */
+ public Short3(short i) {
+ this.x = this.y = this.z = i;
}
- public short x;
- public short y;
- public short z;
-}
+ public Short3(short x, short y, short z) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ }
+
+ /** @hide */
+ public Short3(Short3 source) {
+ this.x = source.x;
+ this.y = source.y;
+ this.z = source.z;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ */
+ public void add(Short3 a) {
+ this.x += a.x;
+ this.y += a.y;
+ this.z += a.z;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short3 add(Short3 a, Short3 b) {
+ Short3 result = new Short3();
+ result.x = (short)(a.x + b.x);
+ result.y = (short)(a.y + b.y);
+ result.z = (short)(a.z + b.z);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(short value) {
+ x += value;
+ y += value;
+ z += value;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short3 add(Short3 a, short b) {
+ Short3 result = new Short3();
+ result.x = (short)(a.x + b);
+ result.y = (short)(a.y + b);
+ result.z = (short)(a.z + b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ */
+ public void sub(Short3 a) {
+ this.x -= a.x;
+ this.y -= a.y;
+ this.z -= a.z;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short3 sub(Short3 a, Short3 b) {
+ Short3 result = new Short3();
+ result.x = (short)(a.x - b.x);
+ result.y = (short)(a.y - b.y);
+ result.z = (short)(a.z - b.z);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(short value) {
+ x -= value;
+ y -= value;
+ z -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short3 sub(Short3 a, short b) {
+ Short3 result = new Short3();
+ result.x = (short)(a.x - b);
+ result.y = (short)(a.y - b);
+ result.z = (short)(a.z - b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ */
+ public void mul(Short3 a) {
+ this.x *= a.x;
+ this.y *= a.y;
+ this.z *= a.z;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short3 mul(Short3 a, Short3 b) {
+ Short3 result = new Short3();
+ result.x = (short)(a.x * b.x);
+ result.y = (short)(a.y * b.y);
+ result.z = (short)(a.z * b.z);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(short value) {
+ x *= value;
+ y *= value;
+ z *= value;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short3 mul(Short3 a, short b) {
+ Short3 result = new Short3();
+ result.x = (short)(a.x * b);
+ result.y = (short)(a.y * b);
+ result.z = (short)(a.z * b);
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ */
+ public void div(Short3 a) {
+ this.x /= a.x;
+ this.y /= a.y;
+ this.z /= a.z;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short3 div(Short3 a, Short3 b) {
+ Short3 result = new Short3();
+ result.x = (short)(a.x / b.x);
+ result.y = (short)(a.y / b.y);
+ result.z = (short)(a.z / b.z);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(short value) {
+ x /= value;
+ y /= value;
+ z /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short3 div(Short3 a, short b) {
+ Short3 result = new Short3();
+ result.x = (short)(a.x / b);
+ result.y = (short)(a.y / b);
+ result.z = (short)(a.z / b);
+
+ return result;
+ }
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ */
+ public void mod(Short3 a) {
+ this.x %= a.x;
+ this.y %= a.y;
+ this.z %= a.z;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short3 mod(Short3 a, Short3 b) {
+ Short3 result = new Short3();
+ result.x = (short)(a.x % b.x);
+ result.y = (short)(a.y % b.y);
+ result.z = (short)(a.z % b.z);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param value
+ */
+ public void mod(short value) {
+ x %= value;
+ y %= value;
+ z %= value;
+ }
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short3 mod(Short3 a, short b) {
+ Short3 result = new Short3();
+ result.x = (short)(a.x % b);
+ result.y = (short)(a.y % b);
+ result.z = (short)(a.z % b);
+ return result;
+ }
+
+ /** @hide
+ * get vector length
+ *
+ * @return
+ */
+ public short length() {
+ return 3;
+ }
+
+ /** @hide
+ * set vector negate
+ */
+ public void negate() {
+ this.x = (short)(-x);
+ this.y = (short)(-y);
+ this.z = (short)(-z);
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public short dotProduct(Short3 a) {
+ return (short)((x * a.x) + (y * a.y) + (z * a.z));
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static short dotProduct(Short3 a, Short3 b) {
+ return (short)((b.x * a.x) + (b.y * a.y) + (b.z * a.z));
+ }
+
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Short3 a, short factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ z += a.z * factor;
+ }
+
+ /** @hide
+ * set vector value by Short3
+ *
+ * @param a
+ */
+ public void set(Short3 a) {
+ this.x = a.x;
+ this.y = a.y;
+ this.z = a.z;
+ }
+
+ /** @hide
+ * set the vector field value by Short
+ *
+ * @param a
+ * @param b
+ * @param c
+ */
+ public void setValues(short a, short b, short c) {
+ this.x = a;
+ this.y = b;
+ this.z = c;
+ }
+
+ /** @hide
+ * return the element sum of vector
+ *
+ * @return
+ */
+ public short elementSum() {
+ return (short)(x + y + z);
+ }
+
+ /** @hide
+ * get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public short get(int i) {
+ switch (i) {
+ case 0:
+ return (short)(x);
+ case 1:
+ return (short)(y);
+ case 2:
+ return (short)(z);
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, short value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ case 2:
+ z = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, short value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ case 2:
+ z += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * copy the vector to short array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(short[] data, int offset) {
+ data[offset] = (short)(x);
+ data[offset + 1] = (short)(y);
+ data[offset + 2] = (short)(z);
+ }
+}
diff --git a/graphics/java/android/renderscript/Short4.java b/graphics/java/android/renderscript/Short4.java
index a7807a4..a2d74f2 100644
--- a/graphics/java/android/renderscript/Short4.java
+++ b/graphics/java/android/renderscript/Short4.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 The Android Open Source Project
+ * Copyright (C) 2013 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,30 +16,499 @@
package android.renderscript;
-import java.lang.Math;
-import android.util.Log;
-
-
/**
- * Class for exposing the native RenderScript short4 type back to the Android system.
- *
- **/
+ * Vector version of the basic short type.
+ * Provides four short fields packed.
+ */
public class Short4 {
+ public short x;
+ public short y;
+ public short z;
+ public short w;
+
public Short4() {
}
- public Short4(short initX, short initY, short initZ, short initW) {
- x = initX;
- y = initY;
- z = initZ;
- w = initW;
+ /** @hide */
+ public Short4(short i) {
+ this.x = this.y = this.z = this.w = i;
}
- public short x;
- public short y;
- public short z;
- public short w;
-}
+ public Short4(short x, short y, short z, short w) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = w;
+ }
+ /** @hide */
+ public Short4(Short4 source) {
+ this.x = source.x;
+ this.y = source.y;
+ this.z = source.z;
+ this.w = source.w;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ */
+ public void add(Short4 a) {
+ this.x += a.x;
+ this.y += a.y;
+ this.z += a.z;
+ this.w += a.w;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short4 add(Short4 a, Short4 b) {
+ Short4 result = new Short4();
+ result.x = (short)(a.x + b.x);
+ result.y = (short)(a.y + b.y);
+ result.z = (short)(a.z + b.z);
+ result.w = (short)(a.w + b.w);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector add
+ *
+ * @param value
+ */
+ public void add(short value) {
+ x += value;
+ y += value;
+ z += value;
+ w += value;
+ }
+ /** @hide
+ * Vector add
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short4 add(Short4 a, short b) {
+ Short4 result = new Short4();
+ result.x = (short)(a.x + b);
+ result.y = (short)(a.y + b);
+ result.z = (short)(a.z + b);
+ result.w = (short)(a.w + b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ */
+ public void sub(Short4 a) {
+ this.x -= a.x;
+ this.y -= a.y;
+ this.z -= a.z;
+ this.w -= a.w;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short4 sub(Short4 a, Short4 b) {
+ Short4 result = new Short4();
+ result.x = (short)(a.x - b.x);
+ result.y = (short)(a.y - b.y);
+ result.z = (short)(a.z - b.z);
+ result.w = (short)(a.w - b.w);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param value
+ */
+ public void sub(short value) {
+ x -= value;
+ y -= value;
+ z -= value;
+ w -= value;
+ }
+
+ /** @hide
+ * Vector subtraction
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short4 sub(Short4 a, short b) {
+ Short4 result = new Short4();
+ result.x = (short)(a.x - b);
+ result.y = (short)(a.y - b);
+ result.z = (short)(a.z - b);
+ result.w = (short)(a.w - b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ */
+ public void mul(Short4 a) {
+ this.x *= a.x;
+ this.y *= a.y;
+ this.z *= a.z;
+ this.w *= a.w;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short4 mul(Short4 a, Short4 b) {
+ Short4 result = new Short4();
+ result.x = (short)(a.x * b.x);
+ result.y = (short)(a.y * b.y);
+ result.z = (short)(a.z * b.z);
+ result.w = (short)(a.w * b.w);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param value
+ */
+ public void mul(short value) {
+ x *= value;
+ y *= value;
+ z *= value;
+ w *= value;
+ }
+
+ /** @hide
+ * Vector multiplication
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short4 mul(Short4 a, short b) {
+ Short4 result = new Short4();
+ result.x = (short)(a.x * b);
+ result.y = (short)(a.y * b);
+ result.z = (short)(a.z * b);
+ result.w = (short)(a.w * b);
+
+ return result;
+ }
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ */
+ public void div(Short4 a) {
+ this.x /= a.x;
+ this.y /= a.y;
+ this.z /= a.z;
+ this.w /= a.w;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short4 div(Short4 a, Short4 b) {
+ Short4 result = new Short4();
+ result.x = (short)(a.x / b.x);
+ result.y = (short)(a.y / b.y);
+ result.z = (short)(a.z / b.z);
+ result.w = (short)(a.w / b.w);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param value
+ */
+ public void div(short value) {
+ x /= value;
+ y /= value;
+ z /= value;
+ w /= value;
+ }
+
+ /** @hide
+ * Vector division
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short4 div(Short4 a, short b) {
+ Short4 result = new Short4();
+ result.x = (short)(a.x / b);
+ result.y = (short)(a.y / b);
+ result.z = (short)(a.z / b);
+ result.w = (short)(a.w / b);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ */
+ public void mod(Short4 a) {
+ this.x %= a.x;
+ this.y %= a.y;
+ this.z %= a.z;
+ this.w %= a.w;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short4 mod(Short4 a, Short4 b) {
+ Short4 result = new Short4();
+ result.x = (short)(a.x % b.x);
+ result.y = (short)(a.y % b.y);
+ result.z = (short)(a.z % b.z);
+ result.w = (short)(a.w % b.w);
+
+ return result;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param value
+ */
+ public void mod(short value) {
+ x %= value;
+ y %= value;
+ z %= value;
+ w %= value;
+ }
+
+ /** @hide
+ * Vector Modulo
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static Short4 mod(Short4 a, short b) {
+ Short4 result = new Short4();
+ result.x = (short)(a.x % b);
+ result.y = (short)(a.y % b);
+ result.z = (short)(a.z % b);
+ result.w = (short)(a.w % b);
+
+ return result;
+ }
+
+ /** @hide
+ * get vector length
+ *
+ * @return
+ */
+ public short length() {
+ return 4;
+ }
+
+ /** @hide
+ * set vector negate
+ */
+ public void negate() {
+ this.x = (short)(-x);
+ this.y = (short)(-y);
+ this.z = (short)(-z);
+ this.w = (short)(-w);
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @return
+ */
+ public short dotProduct(Short4 a) {
+ return (short)((x * a.x) + (y * a.y) + (z * a.z) + (w * a.w));
+ }
+
+ /** @hide
+ * Vector dot Product
+ *
+ * @param a
+ * @param b
+ * @return
+ */
+ public static short dotProduct(Short4 a, Short4 b) {
+ return (short)((b.x * a.x) + (b.y * a.y) + (b.z * a.z) + (b.w * a.w));
+ }
+
+ /** @hide
+ * Vector add Multiple
+ *
+ * @param a
+ * @param factor
+ */
+ public void addMultiple(Short4 a, short factor) {
+ x += a.x * factor;
+ y += a.y * factor;
+ z += a.z * factor;
+ w += a.w * factor;
+ }
+
+ /** @hide
+ * set vector value by Short4
+ *
+ * @param a
+ */
+ public void set(Short4 a) {
+ this.x = a.x;
+ this.y = a.y;
+ this.z = a.z;
+ this.w = a.w;
+ }
+
+ /** @hide
+ * set the vector field value by Short
+ *
+ * @param a
+ * @param b
+ * @param c
+ * @param d
+ */
+ public void setValues(short a, short b, short c, short d) {
+ this.x = a;
+ this.y = b;
+ this.z = c;
+ this.w = d;
+ }
+
+ /** @hide
+ * return the element sum of vector
+ *
+ * @return
+ */
+ public short elementSum() {
+ return (short)(x + y + z + w);
+ }
+
+ /** @hide
+ * get the vector field value by index
+ *
+ * @param i
+ * @return
+ */
+ public short get(int i) {
+ switch (i) {
+ case 0:
+ return (short)(x);
+ case 1:
+ return (short)(y);
+ case 2:
+ return (short)(z);
+ case 3:
+ return (short)(w);
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * set the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void setAt(int i, short value) {
+ switch (i) {
+ case 0:
+ x = value;
+ return;
+ case 1:
+ y = value;
+ return;
+ case 2:
+ z = value;
+ return;
+ case 3:
+ w = value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * add the vector field value by index
+ *
+ * @param i
+ * @param value
+ */
+ public void addAt(int i, short value) {
+ switch (i) {
+ case 0:
+ x += value;
+ return;
+ case 1:
+ y += value;
+ return;
+ case 2:
+ z += value;
+ return;
+ case 3:
+ w += value;
+ return;
+ default:
+ throw new IndexOutOfBoundsException("Index: i");
+ }
+ }
+
+ /** @hide
+ * copy the vector to short array
+ *
+ * @param data
+ * @param offset
+ */
+ public void copyTo(short[] data, int offset) {
+ data[offset] = (short)(x);
+ data[offset + 1] = (short)(y);
+ data[offset + 2] = (short)(z);
+ data[offset + 3] = (short)(w);
+ }
+}