Merge "Fix support for 64-bit integers."
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 27c40fa..8ad54c9 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -359,6 +359,10 @@
synchronized void nScriptSetVarI(int id, int slot, int val) {
rsnScriptSetVarI(mContext, id, slot, val);
}
+ native void rsnScriptSetVarJ(int con, int id, int slot, long val);
+ synchronized void nScriptSetVarJ(int id, int slot, long val) {
+ rsnScriptSetVarJ(mContext, id, slot, val);
+ }
native void rsnScriptSetVarF(int con, int id, int slot, float val);
synchronized void nScriptSetVarF(int id, int slot, float val) {
rsnScriptSetVarF(mContext, id, slot, val);
diff --git a/graphics/java/android/renderscript/Script.java b/graphics/java/android/renderscript/Script.java
index 8772c4c..53a33e4 100644
--- a/graphics/java/android/renderscript/Script.java
+++ b/graphics/java/android/renderscript/Script.java
@@ -80,6 +80,10 @@
mRS.nScriptSetVarI(mID, index, v);
}
+ public void setVar(int index, long v) {
+ mRS.nScriptSetVarJ(mID, index, v);
+ }
+
public void setVar(int index, boolean v) {
mRS.nScriptSetVarI(mID, index, v ? 1 : 0);
}
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index 3e52fef..586d7e9 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -780,6 +780,13 @@
}
static void
+nScriptSetVarJ(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jlong val)
+{
+ LOG_API("nScriptSetVarJ, con(%p), s(%p), slot(%i), val(%lli)", con, (void *)script, slot, val);
+ rsScriptSetVarJ(con, (RsScript)script, slot, val);
+}
+
+static void
nScriptSetVarF(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, float val)
{
LOG_API("nScriptSetVarF, con(%p), s(%p), slot(%i), val(%f)", con, (void *)script, slot, val);
@@ -1266,6 +1273,7 @@
{"rsnScriptInvoke", "(III)V", (void*)nScriptInvoke },
{"rsnScriptInvokeV", "(III[B)V", (void*)nScriptInvokeV },
{"rsnScriptSetVarI", "(IIII)V", (void*)nScriptSetVarI },
+{"rsnScriptSetVarJ", "(IIIJ)V", (void*)nScriptSetVarJ },
{"rsnScriptSetVarF", "(IIIF)V", (void*)nScriptSetVarF },
{"rsnScriptSetVarD", "(IIID)V", (void*)nScriptSetVarD },
{"rsnScriptSetVarV", "(III[B)V", (void*)nScriptSetVarV },
diff --git a/libs/rs/java/tests/src/com/android/rs/test/UT_primitives.java b/libs/rs/java/tests/src/com/android/rs/test/UT_primitives.java
index fb355dd..32b55d9 100644
--- a/libs/rs/java/tests/src/com/android/rs/test/UT_primitives.java
+++ b/libs/rs/java/tests/src/com/android/rs/test/UT_primitives.java
@@ -27,13 +27,65 @@
mRes = res;
}
+ private boolean initializeGlobals(ScriptC_primitives s) {
+ float pF = s.get_floatTest();
+ if (pF != 1.99f) {
+ return false;
+ }
+ s.set_floatTest(2.99f);
+
+ double pD = s.get_doubleTest();
+ if (pD != 2.05) {
+ return false;
+ }
+ s.set_doubleTest(3.05);
+
+ byte pC = s.get_charTest();
+ if (pC != -8) {
+ return false;
+ }
+ s.set_charTest((byte)-16);
+
+ short pS = s.get_shortTest();
+ if (pS != -16) {
+ return false;
+ }
+ s.set_shortTest((short)-32);
+
+ int pI = s.get_intTest();
+ if (pI != -32) {
+ return false;
+ }
+ s.set_intTest(-64);
+
+ /*long pL = s.get_longTest();
+ if (pL != 17179869184l) {
+ return false;
+ }
+ s.set_longTest(17179869185l);*/
+
+ long pLL = s.get_longlongTest();
+ if (pLL != 68719476736L) {
+ return false;
+ }
+ s.set_longlongTest(68719476735L);
+ //s.set_longlongTest(0);
+
+ return true;
+ }
+
public void run() {
RenderScript pRS = RenderScript.create();
ScriptC_primitives s = new ScriptC_primitives(pRS, mRes, R.raw.primitives, true);
pRS.mMessageCallback = mRsMessage;
- s.invoke_primitives_test(0, 0);
- pRS.finish();
- waitForMessage();
+ if (!initializeGlobals(s)) {
+ // initializeGlobals failed
+ result = -1;
+ } else {
+ s.invoke_primitives_test(0, 0);
+ pRS.finish();
+ waitForMessage();
+ }
pRS.destroy();
}
}
diff --git a/libs/rs/java/tests/src/com/android/rs/test/UnitTest.java b/libs/rs/java/tests/src/com/android/rs/test/UnitTest.java
index c9d88a6..90bb8a3 100644
--- a/libs/rs/java/tests/src/com/android/rs/test/UnitTest.java
+++ b/libs/rs/java/tests/src/com/android/rs/test/UnitTest.java
@@ -55,16 +55,18 @@
protected RSMessage mRsMessage = new RSMessage() {
public void run() {
- switch (mID) {
- case RS_MSG_TEST_PASSED:
- result = 1;
- break;
- case RS_MSG_TEST_FAILED:
- result = -1;
- break;
- default:
- android.util.Log.v("RenderScript", "Unit test got unexpected message");
- return;
+ if (result == 0) {
+ switch (mID) {
+ case RS_MSG_TEST_PASSED:
+ result = 1;
+ break;
+ case RS_MSG_TEST_FAILED:
+ result = -1;
+ break;
+ default:
+ android.util.Log.v("RenderScript", "Unit test got unexpected message");
+ return;
+ }
}
if (mItem != null) {
diff --git a/libs/rs/java/tests/src/com/android/rs/test/primitives.rs b/libs/rs/java/tests/src/com/android/rs/test/primitives.rs
index ac0dc12..2db82da 100644
--- a/libs/rs/java/tests/src/com/android/rs/test/primitives.rs
+++ b/libs/rs/java/tests/src/com/android/rs/test/primitives.rs
@@ -20,13 +20,13 @@
bool failed = false;
start();
- _RS_ASSERT(floatTest == 1.99f);
- _RS_ASSERT(doubleTest == 2.05);
- _RS_ASSERT(charTest == -8);
- _RS_ASSERT(shortTest == -16);
- _RS_ASSERT(intTest == -32);
+ _RS_ASSERT(floatTest == 2.99f);
+ _RS_ASSERT(doubleTest == 3.05);
+ _RS_ASSERT(charTest == -16);
+ _RS_ASSERT(shortTest == -32);
+ _RS_ASSERT(intTest == -64);
_RS_ASSERT(longTest == 17179869184l);
- _RS_ASSERT(longlongTest == 68719476736l);
+ _RS_ASSERT(longlongTest == 68719476735l);
_RS_ASSERT(ucharTest == 8);
_RS_ASSERT(ushortTest == 16);
diff --git a/libs/rs/rs.spec b/libs/rs/rs.spec
index a1c0671..8a25a97 100644
--- a/libs/rs/rs.spec
+++ b/libs/rs/rs.spec
@@ -338,6 +338,12 @@
param int value
}
+ScriptSetVarJ {
+ param RsScript s
+ param uint32_t slot
+ param int64_t value
+ }
+
ScriptSetVarF {
param RsScript s
param uint32_t slot
diff --git a/libs/rs/rsScript.cpp b/libs/rs/rsScript.cpp
index c2f9689..c5632b5 100644
--- a/libs/rs/rsScript.cpp
+++ b/libs/rs/rsScript.cpp
@@ -115,6 +115,12 @@
s->setVar(slot, &value, sizeof(value));
}
+void rsi_ScriptSetVarJ(Context *rsc, RsScript vs, uint32_t slot, long long value)
+{
+ Script *s = static_cast<Script *>(vs);
+ s->setVar(slot, &value, sizeof(value));
+}
+
void rsi_ScriptSetVarF(Context *rsc, RsScript vs, uint32_t slot, float value)
{
Script *s = static_cast<Script *>(vs);