Merge commit 'bac61807d3bcfff957b358cb9ad77850bd373689' into HEAD
Change-Id: I29374270c8e0c2f2859efaf1d55af9f73da0f8d7
diff --git a/Android.mk b/Android.mk
index d2b0d99..3d52f44 100644
--- a/Android.mk
+++ b/Android.mk
@@ -462,8 +462,8 @@
# Common sources for doc check and api check
common_src_files := \
$(call find-other-html-files, $(html_dirs)) \
- $(addprefix ../../libcore/, $(call libcore_to_document, $(LOCAL_PATH)/../../libcore)) \
- $(addprefix ../../external/junit/, $(call junit_to_document, $(LOCAL_PATH)/../../external/junit))
+ $(addprefix ../../libcore/, $(libcore_to_document)) \
+ $(addprefix ../../external/junit/, $(junit_to_document))
# These are relative to frameworks/base
framework_docs_LOCAL_SRC_FILES := \
diff --git a/core/java/android/net/EthernetDataTracker.java b/core/java/android/net/EthernetDataTracker.java
index 501484c..cc8c771 100644
--- a/core/java/android/net/EthernetDataTracker.java
+++ b/core/java/android/net/EthernetDataTracker.java
@@ -402,7 +402,7 @@
* for this network.
*/
public String getTcpBufferSizesPropName() {
- return "net.tcp.buffersize.wifi";
+ return "net.tcp.buffersize.ethernet";
}
public void setDependencyMet(boolean met) {
diff --git a/core/java/android/net/INetworkManagementEventObserver.aidl b/core/java/android/net/INetworkManagementEventObserver.aidl
index b76e4c2..405a897 100644
--- a/core/java/android/net/INetworkManagementEventObserver.aidl
+++ b/core/java/android/net/INetworkManagementEventObserver.aidl
@@ -16,6 +16,8 @@
package android.net;
+import android.net.LinkAddress;
+
/**
* Callback class for receiving events from an INetworkManagementService
*
@@ -62,7 +64,7 @@
* @param flags The address flags.
* @param scope The address scope.
*/
- void addressUpdated(String address, String iface, int flags, int scope);
+ void addressUpdated(in LinkAddress address, String iface, int flags, int scope);
/**
* An interface address has been removed
@@ -72,7 +74,7 @@
* @param flags The address flags.
* @param scope The address scope.
*/
- void addressRemoved(String address, String iface, int flags, int scope);
+ void addressRemoved(in LinkAddress address, String iface, int flags, int scope);
/**
* A networking quota limit has been reached. The quota might not
@@ -90,4 +92,13 @@
* @param active True if the interface is actively transmitting data, false if it is idle.
*/
void interfaceClassDataActivityChanged(String label, boolean active);
+
+ /**
+ * Information about available DNS servers has been received.
+ *
+ * @param iface The interface on which the information was received.
+ * @param lifetime The time in seconds for which the DNS servers may be used.
+ * @param servers The IP addresses of the DNS servers.
+ */
+ void interfaceDnsServerInfo(String iface, long lifetime, in String[] servers);
}
diff --git a/core/java/android/net/LinkAddress.java b/core/java/android/net/LinkAddress.java
index a390add..570b6fe 100644
--- a/core/java/android/net/LinkAddress.java
+++ b/core/java/android/net/LinkAddress.java
@@ -25,7 +25,7 @@
import java.net.UnknownHostException;
/**
- * Identifies an address of a network link
+ * Identifies an IP address on a network link.
* @hide
*/
public class LinkAddress implements Parcelable {
@@ -35,7 +35,7 @@
private InetAddress address;
/**
- * Network prefix length
+ * Prefix length.
*/
private int prefixLength;
@@ -50,10 +50,19 @@
this.prefixLength = prefixLength;
}
+ /**
+ * Constructs a new {@code LinkAddress} from an {@code InetAddress} and a prefix length.
+ * @param address The IP address.
+ * @param prefixLength The prefix length.
+ */
public LinkAddress(InetAddress address, int prefixLength) {
init(address, prefixLength);
}
+ /**
+ * Constructs a new {@code LinkAddress} from an {@code InterfaceAddress}.
+ * @param interfaceAddress The interface address.
+ */
public LinkAddress(InterfaceAddress interfaceAddress) {
init(interfaceAddress.getAddress(),
interfaceAddress.getNetworkPrefixLength());
@@ -86,13 +95,13 @@
@Override
public String toString() {
- return (address == null ? "" : (address.getHostAddress() + "/" + prefixLength));
+ return address.getHostAddress() + "/" + prefixLength;
}
/**
* Compares this {@code LinkAddress} instance against the specified address
* in {@code obj}. Two addresses are equal if their InetAddress and prefixLength
- * are equal
+ * are equal.
*
* @param obj the object to be tested for equality.
* @return {@code true} if both objects are equal, {@code false} otherwise.
@@ -107,30 +116,30 @@
this.prefixLength == linkAddress.prefixLength;
}
- @Override
- /*
- * generate hashcode based on significant fields
+ /**
+ * Returns a hashcode for this address.
*/
+ @Override
public int hashCode() {
- return ((null == address) ? 0 : address.hashCode()) + prefixLength;
+ return address.hashCode() + 11 * prefixLength;
}
/**
- * Returns the InetAddress for this address.
+ * Returns the InetAddress of this address.
*/
public InetAddress getAddress() {
return address;
}
/**
- * Get network prefix length
+ * Returns the prefix length of this address.
*/
public int getNetworkPrefixLength() {
return prefixLength;
}
/**
- * Implement the Parcelable interface
+ * Implement the Parcelable interface.
* @hide
*/
public int describeContents() {
@@ -142,13 +151,8 @@
* @hide
*/
public void writeToParcel(Parcel dest, int flags) {
- if (address != null) {
- dest.writeByte((byte)1);
- dest.writeByteArray(address.getAddress());
- dest.writeInt(prefixLength);
- } else {
- dest.writeByte((byte)0);
- }
+ dest.writeByteArray(address.getAddress());
+ dest.writeInt(prefixLength);
}
/**
@@ -159,13 +163,14 @@
new Creator<LinkAddress>() {
public LinkAddress createFromParcel(Parcel in) {
InetAddress address = null;
- int prefixLength = 0;
- if (in.readByte() == 1) {
- try {
- address = InetAddress.getByAddress(in.createByteArray());
- prefixLength = in.readInt();
- } catch (UnknownHostException e) { }
+ try {
+ address = InetAddress.getByAddress(in.createByteArray());
+ } catch (UnknownHostException e) {
+ // Nothing we can do here. When we call the constructor, we'll throw an
+ // IllegalArgumentException, because a LinkAddress can't have a null
+ // InetAddress.
}
+ int prefixLength = in.readInt();
return new LinkAddress(address, prefixLength);
}
diff --git a/core/java/com/android/server/net/BaseNetworkObserver.java b/core/java/com/android/server/net/BaseNetworkObserver.java
index fa54c5f..1e80a21 100644
--- a/core/java/com/android/server/net/BaseNetworkObserver.java
+++ b/core/java/com/android/server/net/BaseNetworkObserver.java
@@ -17,6 +17,7 @@
package com.android.server.net;
import android.net.INetworkManagementEventObserver;
+import android.net.LinkAddress;
/**
* Base {@link INetworkManagementEventObserver} that provides no-op
@@ -36,12 +37,12 @@
}
@Override
- public void addressUpdated(String address, String iface, int flags, int scope) {
+ public void addressUpdated(LinkAddress address, String iface, int flags, int scope) {
// default no-op
}
@Override
- public void addressRemoved(String address, String iface, int flags, int scope) {
+ public void addressRemoved(LinkAddress address, String iface, int flags, int scope) {
// default no-op
}
@@ -64,4 +65,9 @@
public void limitReached(String limitName, String iface) {
// default no-op
}
+
+ @Override
+ public void interfaceDnsServerInfo(String iface, long lifetime, String[] servers) {
+ // default no-op
+ }
}
diff --git a/core/jni/Android.mk b/core/jni/Android.mk
index 5983120..1958584 100644
--- a/core/jni/Android.mk
+++ b/core/jni/Android.mk
@@ -206,7 +206,6 @@
libicuuc \
libicui18n \
libmedia \
- libwpa_client \
libjpeg \
libusbhost \
libharfbuzz_ng \
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index 09577da..97ea5e6 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -447,6 +447,7 @@
char heapgrowthlimitOptsBuf[sizeof("-XX:HeapGrowthLimit=")-1 + PROPERTY_VALUE_MAX];
char heapminfreeOptsBuf[sizeof("-XX:HeapMinFree=")-1 + PROPERTY_VALUE_MAX];
char heapmaxfreeOptsBuf[sizeof("-XX:HeapMaxFree=")-1 + PROPERTY_VALUE_MAX];
+ char gctypeOptsBuf[sizeof("-Xgc:")-1 + PROPERTY_VALUE_MAX];
char heaptargetutilizationOptsBuf[sizeof("-XX:HeapTargetUtilization=")-1 + PROPERTY_VALUE_MAX];
char jitcodecachesizeOptsBuf[sizeof("-Xjitcodecachesize:")-1 + PROPERTY_VALUE_MAX];
char extraOptsBuf[PROPERTY_VALUE_MAX];
@@ -582,6 +583,13 @@
mOptions.add(opt);
}
+ strcpy(gctypeOptsBuf, "-Xgc:");
+ property_get("dalvik.vm.gctype", gctypeOptsBuf+5, "");
+ if (gctypeOptsBuf[5] != '\0') {
+ opt.optionString = gctypeOptsBuf;
+ mOptions.add(opt);
+ }
+
/*
* Enable or disable dexopt features, such as bytecode verification and
* calculation of register maps for precise GC.
diff --git a/core/jni/android/graphics/Graphics.cpp b/core/jni/android/graphics/Graphics.cpp
index 0a8eeab..38a9ba3 100644
--- a/core/jni/android/graphics/Graphics.cpp
+++ b/core/jni/android/graphics/Graphics.cpp
@@ -547,16 +547,20 @@
jbyteArray arrayObj = (jbyteArray) env->CallObjectMethod(gVMRuntime,
gVMRuntime_newNonMovableArray,
gByte_class, size);
- if (arrayObj) {
- jbyte* addr = (jbyte*) env->CallLongMethod(gVMRuntime, gVMRuntime_addressOf, arrayObj);
- if (addr) {
- SkPixelRef* pr = new AndroidPixelRef(env, (void*) addr, size, arrayObj, ctable);
- bitmap->setPixelRef(pr)->unref();
- // since we're already allocated, we lockPixels right away
- // HeapAllocator behaves this way too
- bitmap->lockPixels();
- }
+ if (env->ExceptionCheck() != 0) {
+ return NULL;
}
+ SkASSERT(arrayObj);
+ jbyte* addr = (jbyte*) env->CallLongMethod(gVMRuntime, gVMRuntime_addressOf, arrayObj);
+ if (env->ExceptionCheck() != 0) {
+ return NULL;
+ }
+ SkASSERT(addr);
+ SkPixelRef* pr = new AndroidPixelRef(env, (void*) addr, size, arrayObj, ctable);
+ bitmap->setPixelRef(pr)->unref();
+ // since we're already allocated, we lockPixels right away
+ // HeapAllocator behaves this way too
+ bitmap->lockPixels();
return arrayObj;
}
diff --git a/core/tests/coretests/src/android/net/LinkAddressTest.java b/core/tests/coretests/src/android/net/LinkAddressTest.java
new file mode 100644
index 0000000..389ff4d
--- /dev/null
+++ b/core/tests/coretests/src/android/net/LinkAddressTest.java
@@ -0,0 +1,213 @@
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.net;
+
+import java.net.Inet4Address;
+import java.net.Inet6Address;
+import java.net.InetAddress;
+import java.net.InterfaceAddress;
+import java.net.NetworkInterface;
+import java.net.SocketException;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import android.net.LinkAddress;
+import android.os.Parcel;
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+/**
+ * Tests for {@link LinkAddress}.
+ */
+public class LinkAddressTest extends AndroidTestCase {
+
+ private static final String V4 = "192.0.2.1";
+ private static final String V6 = "2001:db8::1";
+ private static final InetAddress V4_ADDRESS = NetworkUtils.numericToInetAddress(V4);
+ private static final InetAddress V6_ADDRESS = NetworkUtils.numericToInetAddress(V6);
+
+ public void testConstructors() throws SocketException {
+ LinkAddress address;
+
+ // Valid addresses work as expected.
+ address = new LinkAddress(V4_ADDRESS, 25);
+ assertEquals(V4_ADDRESS, address.getAddress());
+ assertEquals(25, address.getNetworkPrefixLength());
+
+ address = new LinkAddress(V6_ADDRESS, 127);
+ assertEquals(V6_ADDRESS, address.getAddress());
+ assertEquals(127, address.getNetworkPrefixLength());
+
+ address = new LinkAddress(V6 + "/64");
+ assertEquals(V6_ADDRESS, address.getAddress());
+ assertEquals(64, address.getNetworkPrefixLength());
+
+ address = new LinkAddress(V4 + "/23");
+ assertEquals(V4_ADDRESS, address.getAddress());
+ assertEquals(23, address.getNetworkPrefixLength());
+
+ // InterfaceAddress doesn't have a constructor. Fetch some from an interface.
+ List<InterfaceAddress> addrs = NetworkInterface.getByName("lo").getInterfaceAddresses();
+
+ // We expect to find 127.0.0.1/8 and ::1/128, in any order.
+ LinkAddress ipv4Loopback, ipv6Loopback;
+ assertEquals(2, addrs.size());
+ if (addrs.get(0).getAddress() instanceof Inet4Address) {
+ ipv4Loopback = new LinkAddress(addrs.get(0));
+ ipv6Loopback = new LinkAddress(addrs.get(1));
+ } else {
+ ipv4Loopback = new LinkAddress(addrs.get(1));
+ ipv6Loopback = new LinkAddress(addrs.get(0));
+ }
+
+ assertEquals(NetworkUtils.numericToInetAddress("127.0.0.1"), ipv4Loopback.getAddress());
+ assertEquals(8, ipv4Loopback.getNetworkPrefixLength());
+
+ assertEquals(NetworkUtils.numericToInetAddress("::1"), ipv6Loopback.getAddress());
+ assertEquals(128, ipv6Loopback.getNetworkPrefixLength());
+
+ // Null addresses are rejected.
+ try {
+ address = new LinkAddress(null, 24);
+ fail("Null InetAddress should cause IllegalArgumentException");
+ } catch(IllegalArgumentException expected) {}
+
+ try {
+ address = new LinkAddress((String) null);
+ fail("Null string should cause IllegalArgumentException");
+ } catch(IllegalArgumentException expected) {}
+
+ try {
+ address = new LinkAddress((InterfaceAddress) null);
+ fail("Null string should cause NullPointerException");
+ } catch(NullPointerException expected) {}
+
+ // Invalid prefix lengths are rejected.
+ try {
+ address = new LinkAddress(V4 + "/-1");
+ fail("Negative IPv4 prefix length should cause IllegalArgumentException");
+ } catch(IllegalArgumentException expected) {}
+
+ try {
+ address = new LinkAddress(V6 + "/-1");
+ fail("Negative IPv6 prefix length should cause IllegalArgumentException");
+ } catch(IllegalArgumentException expected) {}
+
+ try {
+ address = new LinkAddress(V4 + "/33");
+ fail("/35 IPv4 prefix length should cause IllegalArgumentException");
+ } catch(IllegalArgumentException expected) {}
+
+ try {
+ address = new LinkAddress(V6 + "/129");
+ fail("/129 IPv6 prefix length should cause IllegalArgumentException");
+ } catch(IllegalArgumentException expected) {}
+ }
+
+ private void assertLinkAddressesEqual(LinkAddress l1, LinkAddress l2) {
+ assertTrue(l1 + " unexpectedly not equal to " + l2, l1.equals(l2));
+ assertTrue(l2 + " unexpectedly not equal to " + l1, l2.equals(l1));
+ assertEquals(l1.hashCode(), l2.hashCode());
+ }
+
+ private void assertLinkAddressesNotEqual(LinkAddress l1, LinkAddress l2) {
+ assertFalse(l1 + " unexpectedly equal to " + l2, l1.equals(l2));
+ assertFalse(l2 + " unexpectedly equal to " + l1, l2.equals(l1));
+ }
+
+ public void testEquals() {
+ LinkAddress l1, l2;
+
+ l1 = new LinkAddress("2001:db8::1/64");
+ l2 = new LinkAddress("2001:db8::1/64");
+ assertLinkAddressesEqual(l1, l2);
+
+ l2 = new LinkAddress("2001:db8::1/65");
+ assertLinkAddressesNotEqual(l1, l2);
+ l2 = new LinkAddress("2001:db8::2/64");
+ assertLinkAddressesNotEqual(l1, l2);
+
+ l1 = new LinkAddress("192.0.2.1/24");
+ l2 = new LinkAddress("192.0.2.1/24");
+ assertLinkAddressesEqual(l1, l2);
+
+ l2 = new LinkAddress("192.0.2.1/23");
+ assertLinkAddressesNotEqual(l1, l2);
+ l2 = new LinkAddress("192.0.2.2/24");
+ assertLinkAddressesNotEqual(l1, l2);
+
+ // Addresses with the same start or end bytes aren't equal between families.
+ l1 = new LinkAddress("255.255.255.255/24");
+ l2 = new LinkAddress("ffff:ffff::/24");
+ assertLinkAddressesNotEqual(l1, l2);
+ l2 = new LinkAddress("::ffff:ffff/24");
+ assertLinkAddressesNotEqual(l1, l2);
+
+ // Because we use InetAddress, an IPv4 address is equal to its IPv4-mapped address.
+ // TODO: Investigate fixing this.
+ String addressString = V4 + "/24";
+ l1 = new LinkAddress(addressString);
+ l2 = new LinkAddress("::ffff:" + addressString);
+ assertLinkAddressesEqual(l1, l2);
+ }
+
+ public void testHashCode() {
+ LinkAddress l;
+
+ l = new LinkAddress(V4_ADDRESS, 23);
+ assertEquals(-982787, l.hashCode());
+
+ l = new LinkAddress(V4_ADDRESS, 27);
+ assertEquals(-982743, l.hashCode());
+
+ l = new LinkAddress(V6_ADDRESS, 64);
+ assertEquals(1076522926, l.hashCode());
+
+ l = new LinkAddress(V6_ADDRESS, 128);
+ assertEquals(1076523630, l.hashCode());
+ }
+
+ private LinkAddress passThroughParcel(LinkAddress l) {
+ Parcel p = Parcel.obtain();
+ LinkAddress l2 = null;
+ try {
+ l.writeToParcel(p, 0);
+ p.setDataPosition(0);
+ l2 = LinkAddress.CREATOR.createFromParcel(p);
+ } finally {
+ p.recycle();
+ }
+ assertNotNull(l2);
+ return l2;
+ }
+
+ private void assertParcelingIsLossless(LinkAddress l) {
+ LinkAddress l2 = passThroughParcel(l);
+ assertEquals(l, l2);
+ }
+
+ public void testParceling() {
+ LinkAddress l;
+
+ l = new LinkAddress(V6_ADDRESS, 64);
+ assertParcelingIsLossless(l);
+
+ l = new LinkAddress(V4 + "/28");
+ assertParcelingIsLossless(l);
+ }
+}
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 @@
*
**/
public class Byte2 {
+ public byte x;
+ public byte y;
+
public Byte2() {
}
@@ -33,8 +36,357 @@
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 @@
*
**/
public class Byte3 {
+ public byte x;
+ public byte y;
+ public byte z;
+
public Byte3() {
}
@@ -34,9 +38,387 @@
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 @@
*
**/
public class Byte4 {
+ public byte x;
+ public byte y;
+ public byte z;
+ public byte w;
+
public Byte4() {
}
@@ -34,11 +39,418 @@
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 Double3() {
- }
-
- public Double3(double initX, double initY, double initZ) {
- x = initX;
- y = initY;
- z = initZ;
- }
-
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 x, double y, double z) {
+ this.x = x;
+ this.y = y;
+ this.z = 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 Double4() {
- }
-
- public Double4(double initX, double initY, double initZ, double initW) {
- x = initX;
- y = initY;
- z = initZ;
- w = initW;
- }
-
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 x, double y, double z, double w) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = 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 {
- public Float2() {
- }
-
- public Float2(float initX, float initY) {
- x = initX;
- y = initY;
- }
-
+ * 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 x, float y) {
+ this.x = x;
+ this.y = 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 Float3() {
- }
- public Float3(float initX, float initY, float initZ) {
- x = initX;
- y = initY;
- z = initZ;
- }
-
public float x;
public float y;
public float z;
+
+ public Float3() {
+ }
+ /** @hide */
+ public Float3(Float3 data) {
+ this.x = data.x;
+ this.y = data.y;
+ this.z = data.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 Float4() {
- }
-
- public Float4(float initX, float initY, float initZ, float initW) {
- x = initX;
- y = initY;
- z = initZ;
- w = initW;
- }
-
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 x, float y, float z, float w) {
+ this.x = x;
+ this.y = y;
+ this.z = z;
+ this.w = 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 Int3() {
- }
-
- public Int3(int initX, int initY, int initZ) {
- x = initX;
- y = initY;
- z = initZ;
- }
-
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 x, int y, int z) {
+ this.x = x;
+ this.y = y;
+ this.z = 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 Int4() {
- }
-
- public Int4(int initX, int initY, int initZ, int initW) {
- x = initX;
- y = initY;
- z = initZ;
- w = initW;
- }
-
public int x;
public int y;
public int z;
public int w;
+
+ public Int4() {
+ }
+
+ /** @hide */
+ public Int4(int i) {
+ this.x = this.y = this.z = this.w = i;
+ }
+
+ 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 Long3() {
- }
-
- public Long3(long initX, long initY, long initZ) {
- x = initX;
- y = initY;
- z = initZ;
- }
-
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 x, long y, long z) {
+ this.x = x;
+ this.y = y;
+ this.z = 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 Long4() {
- }
-
- public Long4(long initX, long initY, long initZ, long initW) {
- x = initX;
- y = initY;
- z = initZ;
- w = initW;
- }
-
public long x;
public long y;
public long z;
public long w;
+
+ public Long4() {
+ }
+
+ /** @hide */
+ public Long4(long i) {
+ this.x = this.y = this.z = this.w = i;
+ }
+
+ 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 Short3() {
- }
-
- public Short3(short initX, short initY, short initZ) {
- x = initX;
- y = initY;
- z = initZ;
- }
-
public short x;
public short y;
public short z;
+
+ public Short3() {
+ }
+
+ /** @hide */
+ public Short3(short i) {
+ this.x = this.y = this.z = i;
+ }
+
+ 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 Short4() {
- }
-
- public Short4(short initX, short initY, short initZ, short initW) {
- x = initX;
- y = initY;
- z = initZ;
- w = initW;
- }
-
public short x;
public short y;
public short z;
public short w;
+
+ public Short4() {
+ }
+
+ /** @hide */
+ public Short4(short i) {
+ this.x = this.y = this.z = this.w = i;
+ }
+
+ 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);
+ }
}
-
-
-
diff --git a/packages/SystemUI/proguard.flags b/packages/SystemUI/proguard.flags
index ab45d99..1ff93d2 100644
--- a/packages/SystemUI/proguard.flags
+++ b/packages/SystemUI/proguard.flags
@@ -7,4 +7,5 @@
public void setGlowScale(float);
}
+-keep class com.android.systemui.statusbar.phone.PhoneStatusBar
-keep class com.android.systemui.statusbar.tv.TvStatusBar
diff --git a/services/java/com/android/server/NetworkManagementService.java b/services/java/com/android/server/NetworkManagementService.java
index 92f99c2..40ea49e 100644
--- a/services/java/com/android/server/NetworkManagementService.java
+++ b/services/java/com/android/server/NetworkManagementService.java
@@ -136,6 +136,7 @@
public static final int BandwidthControl = 601;
public static final int InterfaceClassActivity = 613;
public static final int InterfaceAddressChange = 614;
+ public static final int InterfaceDnsServerInfo = 615;
}
/**
@@ -404,7 +405,7 @@
/**
* Notify our observers of a new or updated interface address.
*/
- private void notifyAddressUpdated(String address, String iface, int flags, int scope) {
+ private void notifyAddressUpdated(LinkAddress address, String iface, int flags, int scope) {
final int length = mObservers.beginBroadcast();
for (int i = 0; i < length; i++) {
try {
@@ -419,7 +420,7 @@
/**
* Notify our observers of a deleted interface address.
*/
- private void notifyAddressRemoved(String address, String iface, int flags, int scope) {
+ private void notifyAddressRemoved(LinkAddress address, String iface, int flags, int scope) {
final int length = mObservers.beginBroadcast();
for (int i = 0; i < length; i++) {
try {
@@ -431,6 +432,21 @@
mObservers.finishBroadcast();
}
+ /**
+ * Notify our observers of DNS server information received.
+ */
+ private void notifyInterfaceDnsServerInfo(String iface, long lifetime, String[] addresses) {
+ final int length = mObservers.beginBroadcast();
+ for (int i = 0; i < length; i++) {
+ try {
+ mObservers.getBroadcastItem(i).interfaceDnsServerInfo(iface, lifetime, addresses);
+ } catch (RemoteException e) {
+ } catch (RuntimeException e) {
+ }
+ }
+ mObservers.finishBroadcast();
+ }
+
//
// Netd Callback handling
//
@@ -455,6 +471,7 @@
@Override
public boolean onEvent(int code, String raw, String[] cooked) {
+ String errorMessage = String.format("Invalid event from daemon (%s)", raw);
switch (code) {
case NetdResponseCode.InterfaceChange:
/*
@@ -465,8 +482,7 @@
* "NNN Iface linkstatus <name> <up/down>"
*/
if (cooked.length < 4 || !cooked[1].equals("Iface")) {
- throw new IllegalStateException(
- String.format("Invalid event from daemon (%s)", raw));
+ throw new IllegalStateException(errorMessage);
}
if (cooked[2].equals("added")) {
notifyInterfaceAdded(cooked[3]);
@@ -481,8 +497,7 @@
notifyInterfaceLinkStateChanged(cooked[3], cooked[4].equals("up"));
return true;
}
- throw new IllegalStateException(
- String.format("Invalid event from daemon (%s)", raw));
+ throw new IllegalStateException(errorMessage);
// break;
case NetdResponseCode.BandwidthControl:
/*
@@ -490,15 +505,13 @@
* Format: "NNN limit alert <alertName> <ifaceName>"
*/
if (cooked.length < 5 || !cooked[1].equals("limit")) {
- throw new IllegalStateException(
- String.format("Invalid event from daemon (%s)", raw));
+ throw new IllegalStateException(errorMessage);
}
if (cooked[2].equals("alert")) {
notifyLimitReached(cooked[3], cooked[4]);
return true;
}
- throw new IllegalStateException(
- String.format("Invalid event from daemon (%s)", raw));
+ throw new IllegalStateException(errorMessage);
// break;
case NetdResponseCode.InterfaceClassActivity:
/*
@@ -506,8 +519,7 @@
* Format: "NNN IfaceClass <active/idle> <label>"
*/
if (cooked.length < 4 || !cooked[1].equals("IfaceClass")) {
- throw new IllegalStateException(
- String.format("Invalid event from daemon (%s)", raw));
+ throw new IllegalStateException(errorMessage);
}
boolean isActive = cooked[2].equals("active");
notifyInterfaceClassActivity(cooked[3], isActive);
@@ -519,24 +531,47 @@
* Format: "NNN Address updated <addr> <iface> <flags> <scope>"
* "NNN Address removed <addr> <iface> <flags> <scope>"
*/
- String msg = String.format("Invalid event from daemon (%s)", raw);
- if (cooked.length < 6 || !cooked[1].equals("Address")) {
- throw new IllegalStateException(msg);
+ if (cooked.length < 7 || !cooked[1].equals("Address")) {
+ throw new IllegalStateException(errorMessage);
}
int flags;
int scope;
+ LinkAddress address;
try {
flags = Integer.parseInt(cooked[5]);
scope = Integer.parseInt(cooked[6]);
- } catch(NumberFormatException e) {
- throw new IllegalStateException(msg);
+ address = new LinkAddress(cooked[3]);
+ } catch(NumberFormatException e) { // Non-numeric lifetime or scope.
+ throw new IllegalStateException(errorMessage, e);
+ } catch(IllegalArgumentException e) { // Malformed IP address.
+ throw new IllegalStateException(errorMessage, e);
}
if (cooked[2].equals("updated")) {
- notifyAddressUpdated(cooked[3], cooked[4], flags, scope);
+ notifyAddressUpdated(address, cooked[4], flags, scope);
} else {
- notifyAddressRemoved(cooked[3], cooked[4], flags, scope);
+ notifyAddressRemoved(address, cooked[4], flags, scope);
+ }
+ return true;
+ // break;
+ case NetdResponseCode.InterfaceDnsServerInfo:
+ /*
+ * Information about available DNS servers has been received.
+ * Format: "NNN DnsInfo servers <interface> <lifetime> <servers>"
+ */
+ long lifetime; // Actually a 32-bit unsigned integer.
+
+ if (cooked.length == 6 &&
+ cooked[1].equals("DnsInfo") &&
+ cooked[2].equals("servers")) {
+ try {
+ lifetime = Long.parseLong(cooked[4]);
+ } catch (NumberFormatException e) {
+ throw new IllegalStateException(errorMessage);
+ }
+ String[] servers = cooked[5].split(",");
+ notifyInterfaceDnsServerInfo(cooked[3], lifetime, servers);
}
return true;
// break;
diff --git a/services/java/com/android/server/connectivity/Tethering.java b/services/java/com/android/server/connectivity/Tethering.java
index 231a40a..adf1dfc 100644
--- a/services/java/com/android/server/connectivity/Tethering.java
+++ b/services/java/com/android/server/connectivity/Tethering.java
@@ -51,6 +51,7 @@
import com.android.internal.util.State;
import com.android.internal.util.StateMachine;
import com.android.server.IoThread;
+import com.android.server.net.BaseNetworkObserver;
import com.google.android.collect.Lists;
import java.io.FileDescriptor;
@@ -70,7 +71,7 @@
*
* TODO - look for parent classes and code sharing
*/
-public class Tethering extends INetworkManagementEventObserver.Stub {
+public class Tethering extends BaseNetworkObserver {
private Context mContext;
private final static String TAG = "Tethering";
@@ -315,14 +316,6 @@
}
}
- public void addressUpdated(String address, String iface, int flags, int scope) {}
-
- public void addressRemoved(String address, String iface, int flags, int scope) {}
-
- public void limitReached(String limitName, String iface) {}
-
- public void interfaceClassDataActivityChanged(String label, boolean active) {}
-
public int tether(String iface) {
if (DBG) Log.d(TAG, "Tethering " + iface);
TetherInterfaceSM sm = null;
diff --git a/services/java/com/android/server/updates/SELinuxPolicyInstallReceiver.java b/services/java/com/android/server/updates/SELinuxPolicyInstallReceiver.java
index 5dd30f1..e430814 100644
--- a/services/java/com/android/server/updates/SELinuxPolicyInstallReceiver.java
+++ b/services/java/com/android/server/updates/SELinuxPolicyInstallReceiver.java
@@ -125,25 +125,11 @@
SystemProperties.set("selinux.reload_policy", "1");
}
- private void setEnforcingMode(Context context) {
- String mode = Settings.Global.getString(context.getContentResolver(),
- Settings.Global.SELINUX_STATUS);
- if ("1".equals(mode)) {
- Slog.i(TAG, "Setting enforcing mode");
- SystemProperties.set("persist.selinux.enforcing", mode);
- } else if ("0".equals(mode)) {
- Slog.i(TAG, "Tried to set permissive mode, ignoring");
- } else {
- Slog.e(TAG, "Got invalid enforcing mode: " + mode);
- }
- }
-
@Override
protected void postInstall(Context context, Intent intent) {
try {
unpackBundle();
applyUpdate();
- setEnforcingMode(context);
} catch (IllegalArgumentException e) {
Slog.e(TAG, "SELinux policy update malformed: ", e);
} catch (IOException e) {
diff --git a/services/java/com/android/server/wm/WindowManagerService.java b/services/java/com/android/server/wm/WindowManagerService.java
index 060e09c..6d47fcf 100644
--- a/services/java/com/android/server/wm/WindowManagerService.java
+++ b/services/java/com/android/server/wm/WindowManagerService.java
@@ -5594,8 +5594,7 @@
// We keep on including windows until we go past a full-screen
// window.
- boolean fullscreen = ws.isFullscreen(dw, dh);
- including = !ws.mIsImWindow && !fullscreen;
+ including = !ws.mIsImWindow && !ws.isFullscreen(dw, dh);
final WindowStateAnimator winAnim = ws.mWinAnimator;
if (maxLayer < winAnim.mSurfaceLayer) {
@@ -5621,11 +5620,6 @@
ws.isDisplayedLw()) {
screenshotReady = true;
}
-
- if (fullscreen) {
- // No point in continuing down through windows.
- break;
- }
}
if (appToken != null && appWin == null) {
diff --git a/services/tests/servicestests/src/com/android/server/NetworkManagementServiceTest.java b/services/tests/servicestests/src/com/android/server/NetworkManagementServiceTest.java
index 56dd7c4..a78e7b6 100644
--- a/services/tests/servicestests/src/com/android/server/NetworkManagementServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/NetworkManagementServiceTest.java
@@ -17,6 +17,7 @@
package com.android.server;
import android.content.Context;
+import android.net.LinkAddress;
import android.net.LocalSocket;
import android.net.LocalServerSocket;
import android.os.Binder;
@@ -157,18 +158,64 @@
* IP address changes.
*/
sendMessage("614 Address updated fe80::1/64 wlan0 128 253");
- expectSoon(observer).addressUpdated("fe80::1/64", "wlan0", 128, 253);
+ expectSoon(observer).addressUpdated(
+ new LinkAddress("fe80::1/64"), "wlan0", 128, 253);
- // There is no "added".
+ // There is no "added", so we take this as "removed".
sendMessage("614 Address added fe80::1/64 wlan0 128 253");
- expectSoon(observer).addressRemoved("fe80::1/64", "wlan0", 128, 253);
+ expectSoon(observer).addressRemoved(
+ new LinkAddress("fe80::1/64"), "wlan0", 128, 253);
sendMessage("614 Address removed 2001:db8::1/64 wlan0 1 0");
- expectSoon(observer).addressRemoved("2001:db8::1/64", "wlan0", 1, 0);
+ expectSoon(observer).addressRemoved(
+ new LinkAddress("2001:db8::1/64"), "wlan0", 1, 0);
- sendMessage("666 Address added 2001:db8::1/64 wlan0 1 0");
+ sendMessage("614 Address removed 2001:db8::1/64 wlan0 1");
+ // Not enough arguments.
+
+ sendMessage("666 Address removed 2001:db8::1/64 wlan0 1 0");
// Invalid code.
+
+ /**
+ * DNS information broadcasts.
+ */
+ sendMessage("615 DnsInfo servers rmnet_usb0 3600 2001:db8::1");
+ expectSoon(observer).interfaceDnsServerInfo("rmnet_usb0", 3600,
+ new String[]{"2001:db8::1"});
+
+ sendMessage("615 DnsInfo servers wlan0 14400 2001:db8::1,2001:db8::2");
+ expectSoon(observer).interfaceDnsServerInfo("wlan0", 14400,
+ new String[]{"2001:db8::1", "2001:db8::2"});
+
+ // We don't check for negative lifetimes, only for parse errors.
+ sendMessage("615 DnsInfo servers wlan0 -3600 ::1");
+ expectSoon(observer).interfaceDnsServerInfo("wlan0", -3600,
+ new String[]{"::1"});
+
+ sendMessage("615 DnsInfo servers wlan0 SIXHUNDRED ::1");
+ // Non-numeric lifetime.
+
+ sendMessage("615 DnsInfo servers wlan0 2001:db8::1");
+ // Missing lifetime.
+
+ sendMessage("615 DnsInfo servers wlan0 3600");
+ // No servers.
+
+ sendMessage("615 DnsInfo servers 3600 wlan0 2001:db8::1,2001:db8::2");
+ // Non-numeric lifetime.
+
+ sendMessage("615 DnsInfo wlan0 7200 2001:db8::1,2001:db8::2");
+ // Invalid tokens.
+
+ sendMessage("666 DnsInfo servers wlan0 5400 2001:db8::1");
+ // Invalid code.
+
+ // No syntax checking on the addresses.
+ sendMessage("615 DnsInfo servers wlan0 600 ,::,,foo,::1,");
+ expectSoon(observer).interfaceDnsServerInfo("wlan0", 600,
+ new String[]{"", "::", "", "foo", "::1"});
+
// Make sure nothing else was called.
verifyNoMoreInteractions(observer);
}
diff --git a/telephony/java/com/android/internal/telephony/RILConstants.java b/telephony/java/com/android/internal/telephony/RILConstants.java
index 821a11c..8e445d9 100644
--- a/telephony/java/com/android/internal/telephony/RILConstants.java
+++ b/telephony/java/com/android/internal/telephony/RILConstants.java
@@ -55,6 +55,8 @@
int ILLEGAL_SIM_OR_ME = 15; /* network selection failure due
to wrong SIM/ME and no
retries needed */
+ int MISSING_RESOURCE = 16; /* no logical channel available */
+ int NO_SUCH_ELEMENT = 17; /* application not found on SIM */
/* NETWORK_MODE_* See ril.h RIL_REQUEST_SET_PREFERRED_NETWORK_TYPE */
int NETWORK_MODE_WCDMA_PREF = 0; /* GSM/WCDMA (WCDMA preferred) */
@@ -265,6 +267,10 @@
int RIL_REQUEST_SET_INITIAL_ATTACH_APN = 111;
int RIL_REQUEST_IMS_REGISTRATION_STATE = 112;
int RIL_REQUEST_IMS_SEND_SMS = 113;
+ int RIL_REQUEST_SIM_TRANSMIT_APDU_BASIC = 114;
+ int RIL_REQUEST_SIM_OPEN_CHANNEL = 115;
+ int RIL_REQUEST_SIM_CLOSE_CHANNEL = 116;
+ int RIL_REQUEST_SIM_TRANSMIT_APDU_CHANNEL = 117;
int RIL_UNSOL_RESPONSE_BASE = 1000;
int RIL_UNSOL_RESPONSE_RADIO_STATE_CHANGED = 1000;
int RIL_UNSOL_RESPONSE_CALL_STATE_CHANGED = 1001;
diff --git a/tests/TileBenchmark/Android.mk b/tests/TileBenchmark/Android.mk
index 5851113..9a057af 100644
--- a/tests/TileBenchmark/Android.mk
+++ b/tests/TileBenchmark/Android.mk
@@ -17,7 +17,7 @@
LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
+LOCAL_SRC_FILES :=
LOCAL_PACKAGE_NAME := TileBenchmark
@@ -25,4 +25,4 @@
LOCAL_JAVA_LIBRARIES := android.test.runner
-include $(BUILD_PACKAGE)
\ No newline at end of file
+include $(BUILD_PACKAGE)
diff --git a/wifi/java/android/net/wifi/WifiStateMachine.java b/wifi/java/android/net/wifi/WifiStateMachine.java
index eedd66f..d8ca6b0 100644
--- a/wifi/java/android/net/wifi/WifiStateMachine.java
+++ b/wifi/java/android/net/wifi/WifiStateMachine.java
@@ -242,24 +242,24 @@
}
@Override
- public void addressUpdated(String address, String iface, int flags, int scope) {
+ public void addressUpdated(LinkAddress address, String iface, int flags, int scope) {
if (mWifiStateMachine.mInterfaceName.equals(iface)) {
if (DBG) {
log("addressUpdated: " + address + " on " + iface +
" flags " + flags + " scope " + scope);
}
- mWifiStateMachine.sendMessage(CMD_IP_ADDRESS_UPDATED, new LinkAddress(address));
+ mWifiStateMachine.sendMessage(CMD_IP_ADDRESS_UPDATED, address);
}
}
@Override
- public void addressRemoved(String address, String iface, int flags, int scope) {
+ public void addressRemoved(LinkAddress address, String iface, int flags, int scope) {
if (mWifiStateMachine.mInterfaceName.equals(iface)) {
if (DBG) {
log("addressRemoved: " + address + " on " + iface +
" flags " + flags + " scope " + scope);
}
- mWifiStateMachine.sendMessage(CMD_IP_ADDRESS_REMOVED, new LinkAddress(address));
+ mWifiStateMachine.sendMessage(CMD_IP_ADDRESS_REMOVED, address);
}
}
}