summaryrefslogtreecommitdiff
path: root/graphics/java/android/renderscript/Allocation.java
diff options
context:
space:
mode:
authorJason Sams <rjsams@android.com>2009-08-09 17:01:55 -0700
committerJason Sams <rjsams@android.com>2009-08-09 17:05:13 -0700
commit1bada8cd6e4f340de93cff4a2439835fc3b1456c (patch)
treebdc1ed59f9b9ef531bca7220550a025a89ca4173 /graphics/java/android/renderscript/Allocation.java
parent467f3df13dc9324b35c139bd6d291265015ba4d3 (diff)
Begin implementing SimpleMesh and fix some bugs with refcounting and java object destruction tracking.
Diffstat (limited to 'graphics/java/android/renderscript/Allocation.java')
-rw-r--r--graphics/java/android/renderscript/Allocation.java19
1 files changed, 16 insertions, 3 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index 3b6571aaf043..ede475fabff3 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -43,8 +43,11 @@ public class Allocation extends BaseObj {
}
public void destroy() {
+ if(mDestroyed) {
+ throw new IllegalStateException("Object already destroyed.");
+ }
+ mDestroyed = true;
mRS.nAllocationDestroy(mID);
- mID = 0;
}
public void data(int[] d) {
@@ -160,17 +163,27 @@ public class Allocation extends BaseObj {
mBitmapOptions.inScaled = false;
}
- static public Allocation createTyped(RenderScript rs, Type type) {
+ static public Allocation createTyped(RenderScript rs, Type type)
+ throws IllegalArgumentException {
+
+ if(type.mID == 0) {
+ throw new IllegalStateException("Bad Type");
+ }
int id = rs.nAllocationCreateTyped(type.mID);
return new Allocation(id, rs);
}
- static public Allocation createSized(RenderScript rs, Element e, int count) {
+ static public Allocation createSized(RenderScript rs, Element e, int count)
+ throws IllegalArgumentException {
+
int id;
if(e.mIsPredefined) {
id = rs.nAllocationCreatePredefSized(e.mPredefinedID, count);
} else {
id = rs.nAllocationCreateSized(e.mID, count);
+ if(id == 0) {
+ throw new IllegalStateException("Bad element.");
+ }
}
return new Allocation(id, rs);
}