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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user