diff options
author | Jason Sams <rjsams@android.com> | 2009-08-18 14:14:24 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2009-08-18 14:20:07 -0700 |
commit | 7ce033d797e5df5e2131e2ed459fba181eaf4658 (patch) | |
tree | c4bf9fd7d74260b800b75786a2adbca04d2f71be /graphics/java/android | |
parent | 48134b78d53eca2a0a71799b0901aba5997f2eba (diff) | |
download | frameworks_base-7ce033d797e5df5e2131e2ed459fba181eaf4658.zip frameworks_base-7ce033d797e5df5e2131e2ed459fba181eaf4658.tar.gz frameworks_base-7ce033d797e5df5e2131e2ed459fba181eaf4658.tar.bz2 |
Cleanup of object destruction. No need to have a per-class destruction function. This was a legacy of the distant past when the classes did not have a common base.
Diffstat (limited to 'graphics/java/android')
12 files changed, 13 insertions, 107 deletions
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java index 50d39b7..81848b9 100644 --- a/graphics/java/android/renderscript/Allocation.java +++ b/graphics/java/android/renderscript/Allocation.java @@ -47,14 +47,6 @@ public class Allocation extends BaseObj { mRS.nAllocationUploadToTexture(mID, baseMipLevel); } - public void destroy() { - if(mDestroyed) { - throw new IllegalStateException("Object already destroyed."); - } - mDestroyed = true; - mRS.nAllocationDestroy(mID); - } - public void data(int[] d) { mRS.nAllocationData(mID, d); } @@ -98,11 +90,6 @@ public class Allocation extends BaseObj { mID = id; } - public void destroy() { - mRS.nAdapter1DDestroy(mID); - mID = 0; - } - public void setConstraint(Dimension dim, int value) { mRS.nAdapter1DSetConstraint(mID, dim.mID, value); } @@ -139,11 +126,6 @@ public class Allocation extends BaseObj { mID = id; } - public void destroy() { - mRS.nAdapter2DDestroy(mID); - mID = 0; - } - public void setConstraint(Dimension dim, int value) { mRS.nAdapter2DSetConstraint(mID, dim.mID, value); } @@ -251,7 +233,7 @@ public class Allocation extends BaseObj { Allocation alloc = createTyped(rs, t); t.destroy(); return alloc; - } + } */ } diff --git a/graphics/java/android/renderscript/BaseObj.java b/graphics/java/android/renderscript/BaseObj.java index f760035..eaeb401 100644 --- a/graphics/java/android/renderscript/BaseObj.java +++ b/graphics/java/android/renderscript/BaseObj.java @@ -61,9 +61,18 @@ class BaseObj { { if (!mDestroyed) { Log.v(RenderScript.LOG_TAG, - "Element finalized without having released the RS reference."); + getClass() + " finalized without having released the RS reference."); } super.finalize(); } + + public void destroy() { + if(mDestroyed) { + throw new IllegalStateException("Object already destroyed."); + } + mDestroyed = true; + mRS.nObjDestroy(mID); + } + } diff --git a/graphics/java/android/renderscript/Element.java b/graphics/java/android/renderscript/Element.java index cf181b7..3f75069 100644 --- a/graphics/java/android/renderscript/Element.java +++ b/graphics/java/android/renderscript/Element.java @@ -138,11 +138,7 @@ public class Element extends BaseObj { if(mIsPredefined) { throw new IllegalStateException("Attempting to destroy a predefined Element."); } - if(mDestroyed) { - throw new IllegalStateException("Object already destroyed."); - } - mDestroyed = true; - mRS.nElementDestroy(mID); + super.destroy(); } public static Element createFromClass(RenderScript rs, Class c) { diff --git a/graphics/java/android/renderscript/Light.java b/graphics/java/android/renderscript/Light.java index 8067f19..115ae03 100644 --- a/graphics/java/android/renderscript/Light.java +++ b/graphics/java/android/renderscript/Light.java @@ -29,11 +29,6 @@ public class Light extends BaseObj { mID = id; } - public void destroy() { - mRS.nLightDestroy(mID); - mID = 0; - } - public void setColor(float r, float g, float b) { mRS.nLightSetColor(mID, r, g, b); } diff --git a/graphics/java/android/renderscript/ProgramFragment.java b/graphics/java/android/renderscript/ProgramFragment.java index 09c4d9a..aad09f6 100644 --- a/graphics/java/android/renderscript/ProgramFragment.java +++ b/graphics/java/android/renderscript/ProgramFragment.java @@ -45,14 +45,6 @@ public class ProgramFragment extends BaseObj { mID = id; } - public void destroy() { - if(mDestroyed) { - throw new IllegalStateException("Object already destroyed."); - } - mDestroyed = true; - mRS.nProgramFragmentStoreDestroy(mID); - } - public void bindTexture(Allocation va, int slot) throws IllegalArgumentException { if((slot < 0) || (slot >= MAX_SLOT)) { diff --git a/graphics/java/android/renderscript/ProgramStore.java b/graphics/java/android/renderscript/ProgramStore.java index f8b59bd..b7d987e 100644 --- a/graphics/java/android/renderscript/ProgramStore.java +++ b/graphics/java/android/renderscript/ProgramStore.java @@ -80,14 +80,6 @@ public class ProgramStore extends BaseObj { mID = id; } - public void destroy() { - if(mDestroyed) { - throw new IllegalStateException("Object already destroyed."); - } - mDestroyed = true; - mRS.nProgramFragmentStoreDestroy(mID); - } - public static class Builder { diff --git a/graphics/java/android/renderscript/ProgramVertex.java b/graphics/java/android/renderscript/ProgramVertex.java index 74c005f..2a11bfb 100644 --- a/graphics/java/android/renderscript/ProgramVertex.java +++ b/graphics/java/android/renderscript/ProgramVertex.java @@ -33,14 +33,6 @@ public class ProgramVertex extends BaseObj { mID = id; } - public void destroy() { - if(mDestroyed) { - throw new IllegalStateException("Object already destroyed."); - } - mDestroyed = true; - mRS.nProgramVertexDestroy(mID); - } - public void bindAllocation(MatrixAllocation va) { mRS.nProgramVertexBindAllocation(mID, va.mAlloc.mID); } diff --git a/graphics/java/android/renderscript/RenderScript.java b/graphics/java/android/renderscript/RenderScript.java index ab263ed..08418c6 100644 --- a/graphics/java/android/renderscript/RenderScript.java +++ b/graphics/java/android/renderscript/RenderScript.java @@ -74,6 +74,7 @@ public class RenderScript { native void nContextAddDefineF(String name, float value); native void nAssignName(int obj, byte[] name); + native void nObjDestroy(int id); native int nFileOpen(byte[] name); native void nElementBegin(); @@ -81,12 +82,10 @@ public class RenderScript { native void nElementAdd(int kind, int type, int norm, int bits, String s); native int nElementCreate(); native int nElementGetPredefined(int predef); - native void nElementDestroy(int obj); native void nTypeBegin(int elementID); native void nTypeAdd(int dim, int val); native int nTypeCreate(); - native void nTypeDestroy(int id); native void nTypeFinalDestroy(Type t); native void nTypeSetupFields(Type t, int[] types, int[] bits, Field[] IDs); @@ -97,7 +96,6 @@ public class RenderScript { native int nAllocationCreateFromBitmapBoxed(int dstFmt, boolean genMips, Bitmap bmp); native void nAllocationUploadToTexture(int alloc, int baseMioLevel); - native void nAllocationDestroy(int alloc); native void nAllocationData(int id, int[] d); native void nAllocationData(int id, float[] d); native void nAllocationSubData1D(int id, int off, int count, int[] d); @@ -108,7 +106,6 @@ public class RenderScript { native void nAllocationRead(int id, float[] d); native void nAllocationDataFromObject(int id, Type t, Object o); - native void nTriangleMeshDestroy(int id); native void nTriangleMeshBegin(int vertex, int index); native void nTriangleMeshAddVertex_XY (float x, float y); native void nTriangleMeshAddVertex_XYZ (float x, float y, float z); @@ -118,7 +115,6 @@ public class RenderScript { native void nTriangleMeshAddTriangle(int i1, int i2, int i3); native int nTriangleMeshCreate(); - native void nAdapter1DDestroy(int id); native void nAdapter1DBindAllocation(int ad, int alloc); native void nAdapter1DSetConstraint(int ad, int dim, int value); native void nAdapter1DData(int ad, int[] d); @@ -127,7 +123,6 @@ public class RenderScript { native void nAdapter1DSubData(int ad, int off, int count, float[] d); native int nAdapter1DCreate(); - native void nAdapter2DDestroy(int id); native void nAdapter2DBindAllocation(int ad, int alloc); native void nAdapter2DSetConstraint(int ad, int dim, int value); native void nAdapter2DData(int ad, int[] d); @@ -136,7 +131,6 @@ public class RenderScript { native void nAdapter2DSubData(int ad, int xoff, int yoff, int w, int h, float[] d); native int nAdapter2DCreate(); - native void nScriptDestroy(int script); native void nScriptBindAllocation(int script, int alloc, int slot); native void nScriptSetClearColor(int script, float r, float g, float b, float a); native void nScriptSetClearDepth(int script, float depth); @@ -151,7 +145,6 @@ public class RenderScript { native void nScriptCAddDefineI32(String name, int value); native void nScriptCAddDefineF(String name, float value); - native void nSamplerDestroy(int sampler); native void nSamplerBegin(); native void nSamplerSet(int param, int value); native int nSamplerCreate(); @@ -163,7 +156,6 @@ public class RenderScript { native void nProgramFragmentStoreBlendFunc(int src, int dst); native void nProgramFragmentStoreDither(boolean enable); native int nProgramFragmentStoreCreate(); - native void nProgramFragmentStoreDestroy(int pgm); native void nProgramFragmentBegin(int in, int out); native void nProgramFragmentBindTexture(int vpf, int slot, int a); @@ -172,9 +164,7 @@ public class RenderScript { native void nProgramFragmentSetEnvMode(int slot, int env); native void nProgramFragmentSetTexEnable(int slot, boolean enable); native int nProgramFragmentCreate(); - native void nProgramFragmentDestroy(int pgm); - native void nProgramVertexDestroy(int pv); native void nProgramVertexBindAllocation(int pv, int mID); native void nProgramVertexBegin(int inID, int outID); native void nProgramVertexSetTextureMatrixEnable(boolean enable); @@ -185,16 +175,13 @@ public class RenderScript { native void nLightSetIsMono(boolean isMono); native void nLightSetIsLocal(boolean isLocal); native int nLightCreate(); - native void nLightDestroy(int l); native void nLightSetColor(int l, float r, float g, float b); native void nLightSetPosition(int l, float x, float y, float z); - native void nSimpleMeshDestroy(int id); native int nSimpleMeshCreate(int batchID, int idxID, int[] vtxID, int prim); native void nSimpleMeshBindVertex(int id, int alloc, int slot); native void nSimpleMeshBindIndex(int id, int alloc); - native void nAnimationDestroy(int id); native void nAnimationBegin(int attribCount, int keyframeCount); native void nAnimationAdd(float time, float[] attribs); native int nAnimationCreate(); @@ -229,11 +216,6 @@ public class RenderScript { super(RenderScript.this); mID = id; } - - public void destroy() { - nTriangleMeshDestroy(mID); - mID = 0; - } } public void triangleMeshBegin(Element vertex, Element index) { @@ -278,11 +260,6 @@ public class RenderScript { super(RenderScript.this); mID = id; } - - public void destroy() { - //nLightDestroy(mID); - mID = 0; - } } public File fileOpen(String s) throws IllegalStateException, IllegalArgumentException diff --git a/graphics/java/android/renderscript/Sampler.java b/graphics/java/android/renderscript/Sampler.java index dfeac81..5e0b110 100644 --- a/graphics/java/android/renderscript/Sampler.java +++ b/graphics/java/android/renderscript/Sampler.java @@ -51,11 +51,6 @@ public class Sampler extends BaseObj { mID = id; } - public void destroy() { - mRS.nSamplerDestroy(mID); - mID = 0; - } - public static class Builder { RenderScript mRS; Value mMin; diff --git a/graphics/java/android/renderscript/Script.java b/graphics/java/android/renderscript/Script.java index 5b9eb55..a402471 100644 --- a/graphics/java/android/renderscript/Script.java +++ b/graphics/java/android/renderscript/Script.java @@ -31,14 +31,6 @@ public class Script extends BaseObj { mID = id; } - public void destroy() { - if(mDestroyed) { - throw new IllegalStateException("Object already destroyed."); - } - mDestroyed = true; - mRS.nScriptDestroy(mID); - } - public void bindAllocation(Allocation va, int slot) { mRS.nScriptBindAllocation(mID, va.mID, slot); } diff --git a/graphics/java/android/renderscript/SimpleMesh.java b/graphics/java/android/renderscript/SimpleMesh.java index 484849b..d80551e 100644 --- a/graphics/java/android/renderscript/SimpleMesh.java +++ b/graphics/java/android/renderscript/SimpleMesh.java @@ -34,14 +34,6 @@ public class SimpleMesh extends BaseObj { mID = id; } - public void destroy() { - if(mDestroyed) { - throw new IllegalStateException("Object already destroyed."); - } - mDestroyed = true; - mRS.nSimpleMeshDestroy(mID); - } - public void bindVertexAllocation(Allocation a, int slot) { mRS.nSimpleMeshBindVertex(mID, a.mID, slot); } diff --git a/graphics/java/android/renderscript/Type.java b/graphics/java/android/renderscript/Type.java index afb0e60..30b952d 100644 --- a/graphics/java/android/renderscript/Type.java +++ b/graphics/java/android/renderscript/Type.java @@ -48,14 +48,6 @@ public class Type extends BaseObj { super.finalize(); } - public void destroy() { - if(mDestroyed) { - throw new IllegalStateException("Object already destroyed."); - } - mDestroyed = true; - mRS.nTypeDestroy(mID); - } - public static Type createFromClass(RenderScript rs, Class c, int size) { Element e = Element.createFromClass(rs, c); Builder b = new Builder(rs, e); |