From 263cc90345784c3f60bf57c0de91afc4d6c3d5db Mon Sep 17 00:00:00 2001 From: Yang Ni Date: Tue, 10 Nov 2015 13:27:04 -0800 Subject: 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 --- rs/java/android/renderscript/ScriptGroup.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'rs/java/android/renderscript/ScriptGroup.java') diff --git a/rs/java/android/renderscript/ScriptGroup.java b/rs/java/android/renderscript/ScriptGroup.java index 54180f447c36..9bbacbc0d84c 100644 --- a/rs/java/android/renderscript/ScriptGroup.java +++ b/rs/java/android/renderscript/ScriptGroup.java @@ -278,6 +278,8 @@ public final class ScriptGroup extends BaseObj { public ValueAndSize(RenderScript rs, Object obj) { if (obj instanceof Allocation) { value = ((Allocation)obj).getID(rs); + // Special value for size to tell the runtime and driver that + // the value is an Allocation size = -1; } else if (obj instanceof Boolean) { value = ((Boolean)obj).booleanValue() ? 1 : 0; @@ -289,10 +291,10 @@ public final class ScriptGroup extends BaseObj { value = ((Long)obj).longValue(); size = 8; } else if (obj instanceof Float) { - value = ((Float)obj).longValue(); + value = Float.floatToRawIntBits(((Float)obj).floatValue()); size = 4; } else if (obj instanceof Double) { - value = ((Double)obj).longValue(); + value = Double.doubleToRawLongBits(((Double)obj).doubleValue()); size = 8; } } -- cgit v1.2.3