diff options
author | Jason Sams <jsams@google.com> | 2013-11-27 15:30:06 -0800 |
---|---|---|
committer | Jason Sams <jsams@google.com> | 2013-11-27 15:30:06 -0800 |
commit | afb02269cfaed56240f695101ba599beae0c5952 (patch) | |
tree | 3c53bbe4eb61525f738207c6d588cf1656b30161 /graphics/java/android/renderscript/Byte2.java | |
parent | 4f0be08f2be70b758d1b1308543f15824e4a0f9f (diff) | |
parent | 1ccc6633bf47c95601cc13a2566c702bb8d986cd (diff) | |
download | frameworks_base-afb02269cfaed56240f695101ba599beae0c5952.zip frameworks_base-afb02269cfaed56240f695101ba599beae0c5952.tar.gz frameworks_base-afb02269cfaed56240f695101ba599beae0c5952.tar.bz2 |
Merge commit '1ccc6633' into manualmerge
Conflicts:
graphics/java/android/renderscript/Double2.java
graphics/java/android/renderscript/Double3.java
graphics/java/android/renderscript/Double4.java
graphics/java/android/renderscript/Float2.java
graphics/java/android/renderscript/Float3.java
graphics/java/android/renderscript/Float4.java
graphics/java/android/renderscript/Int2.java
graphics/java/android/renderscript/Int3.java
graphics/java/android/renderscript/Int4.java
graphics/java/android/renderscript/Long2.java
graphics/java/android/renderscript/Long3.java
graphics/java/android/renderscript/Long4.java
graphics/java/android/renderscript/Short2.java
graphics/java/android/renderscript/Short3.java
graphics/java/android/renderscript/Short4.java
Change-Id: Ib9e940bc7d62764020eea7639d7158af707eb33f
Diffstat (limited to 'graphics/java/android/renderscript/Byte2.java')
-rw-r--r-- | graphics/java/android/renderscript/Byte2.java | 356 |
1 files changed, 354 insertions, 2 deletions
diff --git a/graphics/java/android/renderscript/Byte2.java b/graphics/java/android/renderscript/Byte2.java index ef7c770..3ad79e4 100644 --- a/graphics/java/android/renderscript/Byte2.java +++ b/graphics/java/android/renderscript/Byte2.java @@ -22,6 +22,9 @@ package android.renderscript; * **/ public class Byte2 { + public byte x; + public byte y; + public Byte2() { } @@ -30,8 +33,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; + } + } |