summaryrefslogtreecommitdiff
path: root/rs/jni/android_renderscript_RenderScript.cpp
diff options
context:
space:
mode:
authorYang Ni <yangni@google.com>2015-11-10 13:27:04 -0800
committerYang Ni <yangni@google.com>2015-11-13 10:00:12 -0800
commit263cc90345784c3f60bf57c0de91afc4d6c3d5db (patch)
treec4182272f7c18eaa2c6f8efc89db9830862aaf18 /rs/jni/android_renderscript_RenderScript.cpp
parentd1c469e8769822c48584034076861331fd792a7c (diff)
Various fixes in setting globals in a script group
Bug: 25602504 1) Passing floating point values into a script group was broken, since they were casted to long values. Fixed that in the frameworks implementation by taking the raw bits instead. 2) Passing 64-bit values into a script group was broken on 32-bit platforms, since they were casted to pointer-sized integers (uintptr_t) in the JNI code. Fixed that by casting to int64_t instead. 3) Setting global variables of Allocation type in a script group was broken. The special size value -1 was used to indicate the value is an Allocation. However, size was casted to size_t in the JNI code. Fixed that by using signed integers. Change-Id: Ifff099a76be7707df7b67c388395f5a00f9cae66
Diffstat (limited to 'rs/jni/android_renderscript_RenderScript.cpp')
-rw-r--r--rs/jni/android_renderscript_RenderScript.cpp30
1 files changed, 6 insertions, 24 deletions
diff --git a/rs/jni/android_renderscript_RenderScript.cpp b/rs/jni/android_renderscript_RenderScript.cpp
index be7071e05044..113241da4572 100644
--- a/rs/jni/android_renderscript_RenderScript.cpp
+++ b/rs/jni/android_renderscript_RenderScript.cpp
@@ -393,7 +393,6 @@ nClosureCreate(JNIEnv *_env, jobject _this, jlong con, jlong kernelID,
size_t numValues, numDependencies;
RsScriptFieldID* fieldIDs;
- uintptr_t* values;
RsClosure* depClosures;
RsScriptFieldID* depFieldIDs;
@@ -430,15 +429,6 @@ nClosureCreate(JNIEnv *_env, jobject _this, jlong con, jlong kernelID,
fieldIDs[i] = (RsScriptFieldID)jFieldIDs[i];
}
- values = (uintptr_t*)alloca(sizeof(uintptr_t) * numValues);
- if (values == nullptr) {
- goto exit;
- }
-
- for (size_t i = 0; i < numValues; i++) {
- values[i] = (uintptr_t)jValues[i];
- }
-
depClosures = (RsClosure*)alloca(sizeof(RsClosure) * numDependencies);
if (depClosures == nullptr) {
goto exit;
@@ -459,7 +449,7 @@ nClosureCreate(JNIEnv *_env, jobject _this, jlong con, jlong kernelID,
ret = (jlong)(uintptr_t)rsClosureCreate(
(RsContext)con, (RsScriptKernelID)kernelID, (RsAllocation)returnValue,
- fieldIDs, numValues, values, numValues,
+ fieldIDs, numValues, jValues, numValues,
(int*)jSizes, numValues,
depClosures, numDependencies,
depFieldIDs, numDependencies);
@@ -511,7 +501,6 @@ nInvokeClosureCreate(JNIEnv *_env, jobject _this, jlong con, jlong invokeID,
size_t numValues;
RsScriptFieldID* fieldIDs;
- uintptr_t* values;
if (fieldIDs_length != values_length || values_length != sizes_length) {
ALOGE("Unmatched field IDs, values, and sizes in closure creation.");
@@ -534,18 +523,9 @@ nInvokeClosureCreate(JNIEnv *_env, jobject _this, jlong con, jlong invokeID,
fieldIDs[i] = (RsScriptFieldID)jFieldIDs[i];
}
- values = (uintptr_t*)alloca(sizeof(uintptr_t) * numValues);
- if (values == nullptr) {
- goto exit;
- }
-
- for (size_t i = 0; i < numValues; i++) {
- values[i] = (uintptr_t)jValues[i];
- }
-
ret = (jlong)(uintptr_t)rsInvokeClosureCreate(
(RsContext)con, (RsScriptInvokeID)invokeID, jParams, jParamLength,
- fieldIDs, numValues, values, numValues,
+ fieldIDs, numValues, jValues, numValues,
(int*)jSizes, numValues);
exit:
@@ -561,15 +541,17 @@ exit:
static void
nClosureSetArg(JNIEnv *_env, jobject _this, jlong con, jlong closureID,
jint index, jlong value, jint size) {
+ // Size is signed with -1 indicating the value is an Allocation
rsClosureSetArg((RsContext)con, (RsClosure)closureID, (uint32_t)index,
- (uintptr_t)value, (size_t)size);
+ (uintptr_t)value, size);
}
static void
nClosureSetGlobal(JNIEnv *_env, jobject _this, jlong con, jlong closureID,
jlong fieldID, jlong value, jint size) {
+ // Size is signed with -1 indicating the value is an Allocation
rsClosureSetGlobal((RsContext)con, (RsClosure)closureID,
- (RsScriptFieldID)fieldID, (uintptr_t)value, (size_t)size);
+ (RsScriptFieldID)fieldID, (int64_t)value, size);
}
static long