summaryrefslogtreecommitdiffstats
path: root/rs
diff options
context:
space:
mode:
authorJason Sams <jsams@google.com>2014-03-06 01:03:09 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-03-06 01:03:09 +0000
commitedf0b79d55df17fddb6b96de32f34ffccc8ec2d4 (patch)
tree84345743580a46d08d5096e1c5f4c205adff21e0 /rs
parent9c9185348ad2487aad043c565fe221b4a56ef0b9 (diff)
parent24ea88a986cfb6de7197b213ad933a6eb6f0e285 (diff)
downloadframeworks_base-edf0b79d55df17fddb6b96de32f34ffccc8ec2d4.zip
frameworks_base-edf0b79d55df17fddb6b96de32f34ffccc8ec2d4.tar.gz
frameworks_base-edf0b79d55df17fddb6b96de32f34ffccc8ec2d4.tar.bz2
am 24ea88a9: am 9a9916b5: am 2383f220: Merge "Validate objects are from the correct context."
* commit '24ea88a986cfb6de7197b213ad933a6eb6f0e285': Validate objects are from the correct context.
Diffstat (limited to 'rs')
-rw-r--r--rs/java/android/renderscript/RenderScript.java8
-rw-r--r--rs/java/android/renderscript/Script.java9
2 files changed, 17 insertions, 0 deletions
diff --git a/rs/java/android/renderscript/RenderScript.java b/rs/java/android/renderscript/RenderScript.java
index 7db331f..eebeaa4 100644
--- a/rs/java/android/renderscript/RenderScript.java
+++ b/rs/java/android/renderscript/RenderScript.java
@@ -1004,6 +1004,14 @@ public class RenderScript {
}
}
+ void validateObject(BaseObj o) {
+ if (o != null) {
+ if (o.mRS != this) {
+ throw new RSIllegalArgumentException("Attempting to use an object across contexts.");
+ }
+ }
+ }
+
void validate() {
if (mContext == 0) {
throw new RSInvalidStateException("Calling RS with no Context active.");
diff --git a/rs/java/android/renderscript/Script.java b/rs/java/android/renderscript/Script.java
index a1f2287..0e46f94 100644
--- a/rs/java/android/renderscript/Script.java
+++ b/rs/java/android/renderscript/Script.java
@@ -128,6 +128,9 @@ public class Script extends BaseObj {
*
*/
protected void forEach(int slot, Allocation ain, Allocation aout, FieldPacker v) {
+ mRS.validate();
+ mRS.validateObject(ain);
+ mRS.validateObject(aout);
if (ain == null && aout == null) {
throw new RSIllegalArgumentException(
"At least one of ain or aout is required to be non-null.");
@@ -152,6 +155,9 @@ public class Script extends BaseObj {
*
*/
protected void forEach(int slot, Allocation ain, Allocation aout, FieldPacker v, LaunchOptions sc) {
+ mRS.validate();
+ mRS.validateObject(ain);
+ mRS.validateObject(aout);
if (ain == null && aout == null) {
throw new RSIllegalArgumentException(
"At least one of ain or aout is required to be non-null.");
@@ -187,6 +193,7 @@ public class Script extends BaseObj {
*/
public void bindAllocation(Allocation va, int slot) {
mRS.validate();
+ mRS.validateObject(va);
if (va != null) {
if (mRS.getApplicationContext().getApplicationInfo().targetSdkVersion >= 20) {
final Type t = va.mType;
@@ -263,6 +270,8 @@ public class Script extends BaseObj {
*
*/
public void setVar(int index, BaseObj o) {
+ mRS.validate();
+ mRS.validateObject(o);
mRS.nScriptSetVarObj(getID(mRS), index, (o == null) ? 0 : o.getID(mRS));
}