summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2012-04-20 14:26:06 -0700
committerStephen Hines <srhines@google.com>2012-05-01 00:29:52 -0700
commitadeb809201fcb77ba2b76a814ae4cdc9dacb326b (patch)
tree2b19e82372eb7c279c0cc19f9e40df9e2d33bc73
parent9da1b5d0301e8d13be8c96cbd12dcda04fcf7118 (diff)
downloadframeworks_base-adeb809201fcb77ba2b76a814ae4cdc9dacb326b.zip
frameworks_base-adeb809201fcb77ba2b76a814ae4cdc9dacb326b.tar.gz
frameworks_base-adeb809201fcb77ba2b76a814ae4cdc9dacb326b.tar.bz2
Start passing element/dim information along with FieldPacker.
BUG=6009244 Change-Id: I3c82c8b40c899b875831f53cf0ad82ea36c1a043
-rw-r--r--api/current.txt1
-rw-r--r--graphics/java/android/renderscript/RenderScript.java7
-rw-r--r--graphics/java/android/renderscript/Script.java14
-rw-r--r--graphics/jni/android_renderscript_RenderScript.cpp15
-rw-r--r--tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java1
-rw-r--r--tests/RenderScriptTests/tests/src/com/android/rs/test/UT_array_alloc.java52
-rw-r--r--tests/RenderScriptTests/tests/src/com/android/rs/test/array_alloc.rs21
7 files changed, 110 insertions, 1 deletions
diff --git a/api/current.txt b/api/current.txt
index 94dcbbd..6aaeff1 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -19239,6 +19239,7 @@ package android.renderscript {
method public deprecated void setVar(int, boolean);
method public deprecated void setVar(int, android.renderscript.BaseObj);
method public deprecated void setVar(int, android.renderscript.FieldPacker);
+ method public deprecated void setVar(int, android.renderscript.FieldPacker, android.renderscript.Element, int[]);
}
public static class Script.Builder {
diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java
index 9a5b349..46ad495 100644
--- a/graphics/java/android/renderscript/RenderScript.java
+++ b/graphics/java/android/renderscript/RenderScript.java
@@ -541,6 +541,13 @@ public class RenderScript {
validate();
rsnScriptSetVarV(mContext, id, slot, val);
}
+ native void rsnScriptSetVarVE(int con, int id, int slot, byte[] val,
+ int e, int[] dims);
+ synchronized void nScriptSetVarVE(int id, int slot, byte[] val,
+ int e, int[] dims) {
+ validate();
+ rsnScriptSetVarVE(mContext, id, slot, val, e, dims);
+ }
native void rsnScriptSetVarObj(int con, int id, int slot, int val);
synchronized void nScriptSetVarObj(int id, int slot, int val) {
validate();
diff --git a/graphics/java/android/renderscript/Script.java b/graphics/java/android/renderscript/Script.java
index 34d33a9..56893ac 100644
--- a/graphics/java/android/renderscript/Script.java
+++ b/graphics/java/android/renderscript/Script.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008 The Android Open Source Project
+ * Copyright (C) 2008-2012 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.
@@ -163,6 +163,18 @@ public class Script extends BaseObj {
}
/** @deprecated renderscript is deprecated in J
+ * Only intended for use by generated reflected code.
+ *
+ * @param index
+ * @param v
+ * @param e
+ * @param dims
+ */
+ public void setVar(int index, FieldPacker v, Element e, int[] dims) {
+ mRS.nScriptSetVarVE(getID(mRS), index, v.getData(), e.getID(mRS), dims);
+ }
+
+ /** @deprecated renderscript is deprecated in J
*/
public void setTimeZone(String timeZone) {
mRS.validate();
diff --git a/graphics/jni/android_renderscript_RenderScript.cpp b/graphics/jni/android_renderscript_RenderScript.cpp
index 1b7ef22..3d5d1a9 100644
--- a/graphics/jni/android_renderscript_RenderScript.cpp
+++ b/graphics/jni/android_renderscript_RenderScript.cpp
@@ -953,6 +953,20 @@ nScriptSetVarV(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slo
_env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
}
+static void
+nScriptSetVarVE(JNIEnv *_env, jobject _this, RsContext con, jint script, jint slot, jbyteArray data, jint elem, jintArray dims)
+{
+ LOG_API("nScriptSetVarVE, con(%p), s(%p), slot(%i)", con, (void *)script, slot);
+ jint len = _env->GetArrayLength(data);
+ jbyte *ptr = _env->GetByteArrayElements(data, NULL);
+ jint dimsLen = _env->GetArrayLength(dims) * sizeof(int);
+ jint *dimsPtr = _env->GetIntArrayElements(dims, NULL);
+ rsScriptSetVarVE(con, (RsScript)script, slot, ptr, len, (RsElement)elem,
+ (const size_t*) dimsPtr, dimsLen);
+ _env->ReleaseByteArrayElements(data, ptr, JNI_ABORT);
+ _env->ReleaseIntArrayElements(dims, dimsPtr, JNI_ABORT);
+}
+
static void
nScriptSetTimeZone(JNIEnv *_env, jobject _this, RsContext con, jint script, jbyteArray timeZone)
@@ -1394,6 +1408,7 @@ static JNINativeMethod methods[] = {
{"rsnScriptSetVarF", "(IIIF)V", (void*)nScriptSetVarF },
{"rsnScriptSetVarD", "(IIID)V", (void*)nScriptSetVarD },
{"rsnScriptSetVarV", "(III[B)V", (void*)nScriptSetVarV },
+{"rsnScriptSetVarVE", "(III[BI[I)V", (void*)nScriptSetVarVE },
{"rsnScriptSetVarObj", "(IIII)V", (void*)nScriptSetVarObj },
{"rsnScriptCCreate", "(ILjava/lang/String;Ljava/lang/String;[BI)I", (void*)nScriptCCreate },
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
index e3d5c60..d2e1527 100644
--- a/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java
@@ -68,6 +68,7 @@ public class RSTestCore {
unitTests.add(new UT_constant(this, mRes, mCtx));
unitTests.add(new UT_vector(this, mRes, mCtx));
unitTests.add(new UT_array_init(this, mRes, mCtx));
+ unitTests.add(new UT_array_alloc(this, mRes, mCtx));
unitTests.add(new UT_convert(this, mRes, mCtx));
unitTests.add(new UT_rsdebug(this, mRes, mCtx));
unitTests.add(new UT_rstime(this, mRes, mCtx));
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_array_alloc.java b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_array_alloc.java
new file mode 100644
index 0000000..befe865
--- /dev/null
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/UT_array_alloc.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2012 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 com.android.rs.test;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.renderscript.*;
+
+public class UT_array_alloc extends UnitTest {
+ private Resources mRes;
+
+ protected UT_array_alloc(RSTestCore rstc, Resources res, Context ctx) {
+ super(rstc, "Array Allocation", ctx);
+ mRes = res;
+ }
+
+ public void run() {
+ RenderScript pRS = RenderScript.create(mCtx);
+ ScriptC_array_alloc s = new ScriptC_array_alloc(pRS, mRes, R.raw.array_alloc);
+ pRS.setMessageHandler(mRsMessage);
+
+ int dimX = s.get_dimX();
+ Allocation[] Arr = new Allocation[dimX];
+ Type.Builder typeBuilder = new Type.Builder(pRS, Element.I32(pRS));
+ Type T = typeBuilder.setX(1).create();
+ for (int i = 0; i < dimX; i++) {
+ Allocation A = Allocation.createTyped(pRS, T);
+ Arr[i] = A;
+ }
+ s.set_a(Arr);
+
+ s.invoke_array_alloc_test();
+ pRS.finish();
+ waitForMessage();
+ pRS.destroy();
+ passTest();
+ }
+}
diff --git a/tests/RenderScriptTests/tests/src/com/android/rs/test/array_alloc.rs b/tests/RenderScriptTests/tests/src/com/android/rs/test/array_alloc.rs
new file mode 100644
index 0000000..74ffdb1
--- /dev/null
+++ b/tests/RenderScriptTests/tests/src/com/android/rs/test/array_alloc.rs
@@ -0,0 +1,21 @@
+#include "shared.rsh"
+
+const int dimX = 20;
+rs_allocation a[dimX];
+
+void array_alloc_test() {
+ bool failed = false;
+
+ for (int i = 0; i < dimX; i++) {
+ rsDebug("i: ", i);
+ _RS_ASSERT(rsAllocationGetDimX(a[i]) == 1);
+ }
+
+ if (failed) {
+ rsSendToClientBlocking(RS_MSG_TEST_FAILED);
+ }
+ else {
+ rsSendToClientBlocking(RS_MSG_TEST_PASSED);
+ }
+}
+