Loading rs/java/android/renderscript/Allocation.java +2 −0 Original line number Diff line number Diff line Loading @@ -380,6 +380,7 @@ public class Allocation extends BaseObj { Log.e(RenderScript.LOG_TAG, "Couldn't invoke registerNativeAllocation:" + e); throw new RSRuntimeException("Couldn't invoke registerNativeAllocation:" + e); } guard.open("destroy"); } Allocation(long id, RenderScript rs, Type t, int usage, MipmapControl mips) { Loading Loading @@ -1915,6 +1916,7 @@ public class Allocation extends BaseObj { if (type.getID(rs) == 0) { throw new RSInvalidStateException("Bad Type"); } // TODO: What if there is an exception after this? The native allocation would leak. long id = rs.nAllocationCreateTyped(type.getID(rs), mips.mID, usage, 0); if (id == 0) { throw new RSRuntimeException("Allocation creation failed."); Loading rs/java/android/renderscript/BaseObj.java +11 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.renderscript; import dalvik.system.CloseGuard; import java.util.concurrent.locks.ReentrantReadWriteLock; /** Loading Loading @@ -69,6 +70,7 @@ public class BaseObj { } private long mID; final CloseGuard guard = CloseGuard.get(); private boolean mDestroyed; private String mName; RenderScript mRS; Loading Loading @@ -119,6 +121,7 @@ public class BaseObj { } if (shouldDestroy) { guard.close(); // must include nObjDestroy in the critical section ReentrantReadWriteLock.ReadLock rlock = mRS.mRWLock.readLock(); rlock.lock(); Loading @@ -133,9 +136,15 @@ public class BaseObj { } protected void finalize() throws Throwable { try { if (guard != null) { guard.warnIfOpen(); } helpDestroy(); } finally { super.finalize(); } } /** * Frees any native resources associated with this object. The Loading rs/java/android/renderscript/Element.java +2 −0 Original line number Diff line number Diff line Loading @@ -808,6 +808,7 @@ public class Element extends BaseObj { mSize += mElements[ct].mSize * mArraySizes[ct]; } updateVisibleSubElements(); guard.open("destroy"); } Element(long id, RenderScript rs, DataType dt, DataKind dk, boolean norm, int size) { Loading @@ -827,6 +828,7 @@ public class Element extends BaseObj { mKind = dk; mNormalized = norm; mVectorSize = size; guard.open("destroy"); } Element(long id, RenderScript rs) { Loading rs/java/android/renderscript/FileA3D.java +1 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,7 @@ public class FileA3D extends BaseObj { FileA3D(long id, RenderScript rs, InputStream stream) { super(id, rs); mInputStream = stream; guard.open("destroy"); } private void initEntries() { Loading rs/java/android/renderscript/Font.java +1 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,7 @@ public class Font extends BaseObj { Font(long id, RenderScript rs) { super(id, rs); guard.open("destroy"); } /** Loading Loading
rs/java/android/renderscript/Allocation.java +2 −0 Original line number Diff line number Diff line Loading @@ -380,6 +380,7 @@ public class Allocation extends BaseObj { Log.e(RenderScript.LOG_TAG, "Couldn't invoke registerNativeAllocation:" + e); throw new RSRuntimeException("Couldn't invoke registerNativeAllocation:" + e); } guard.open("destroy"); } Allocation(long id, RenderScript rs, Type t, int usage, MipmapControl mips) { Loading Loading @@ -1915,6 +1916,7 @@ public class Allocation extends BaseObj { if (type.getID(rs) == 0) { throw new RSInvalidStateException("Bad Type"); } // TODO: What if there is an exception after this? The native allocation would leak. long id = rs.nAllocationCreateTyped(type.getID(rs), mips.mID, usage, 0); if (id == 0) { throw new RSRuntimeException("Allocation creation failed."); Loading
rs/java/android/renderscript/BaseObj.java +11 −2 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.renderscript; import dalvik.system.CloseGuard; import java.util.concurrent.locks.ReentrantReadWriteLock; /** Loading Loading @@ -69,6 +70,7 @@ public class BaseObj { } private long mID; final CloseGuard guard = CloseGuard.get(); private boolean mDestroyed; private String mName; RenderScript mRS; Loading Loading @@ -119,6 +121,7 @@ public class BaseObj { } if (shouldDestroy) { guard.close(); // must include nObjDestroy in the critical section ReentrantReadWriteLock.ReadLock rlock = mRS.mRWLock.readLock(); rlock.lock(); Loading @@ -133,9 +136,15 @@ public class BaseObj { } protected void finalize() throws Throwable { try { if (guard != null) { guard.warnIfOpen(); } helpDestroy(); } finally { super.finalize(); } } /** * Frees any native resources associated with this object. The Loading
rs/java/android/renderscript/Element.java +2 −0 Original line number Diff line number Diff line Loading @@ -808,6 +808,7 @@ public class Element extends BaseObj { mSize += mElements[ct].mSize * mArraySizes[ct]; } updateVisibleSubElements(); guard.open("destroy"); } Element(long id, RenderScript rs, DataType dt, DataKind dk, boolean norm, int size) { Loading @@ -827,6 +828,7 @@ public class Element extends BaseObj { mKind = dk; mNormalized = norm; mVectorSize = size; guard.open("destroy"); } Element(long id, RenderScript rs) { Loading
rs/java/android/renderscript/FileA3D.java +1 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,7 @@ public class FileA3D extends BaseObj { FileA3D(long id, RenderScript rs, InputStream stream) { super(id, rs); mInputStream = stream; guard.open("destroy"); } private void initEntries() { Loading
rs/java/android/renderscript/Font.java +1 −0 Original line number Diff line number Diff line Loading @@ -150,6 +150,7 @@ public class Font extends BaseObj { Font(long id, RenderScript rs) { super(id, rs); guard.open("destroy"); } /** Loading