Start passing element/dim information along with FieldPacker.
BUG=6009244 Change-Id: I3c82c8b40c899b875831f53cf0ad82ea36c1a043
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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.
|
||||
@@ -162,6 +162,18 @@ public class Script extends BaseObj {
|
||||
mRS.nScriptSetVarV(getID(mRS), index, v.getData());
|
||||
}
|
||||
|
||||
/** @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) {
|
||||
|
||||
@@ -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 },
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user