diff options
Diffstat (limited to 'graphics/java/android/renderscript/BaseObj.java')
-rw-r--r-- | graphics/java/android/renderscript/BaseObj.java | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/graphics/java/android/renderscript/BaseObj.java b/graphics/java/android/renderscript/BaseObj.java index 8ce1d9a..2e55c48 100644 --- a/graphics/java/android/renderscript/BaseObj.java +++ b/graphics/java/android/renderscript/BaseObj.java @@ -24,7 +24,7 @@ import android.util.Log; * disconecting the object from the native allocation for early cleanup. * **/ -class BaseObj { +public class BaseObj { BaseObj(int id, RenderScript rs) { rs.validate(); mRS = rs; @@ -97,6 +97,13 @@ class BaseObj { } } + /** + * @return name of the renderscript object + */ + public String getName() { + return mName; + } + protected void finalize() throws Throwable { if (!mDestroyed) { if(mID != 0 && mRS.isAlive()) { @@ -134,5 +141,35 @@ class BaseObj { mName = mRS.nGetName(getID()); } + /** + * Calculates the hash code value for a BaseObj. + * + * @return int + */ + @Override + public int hashCode() { + return mID; + } + + /** + * Compare the current BaseObj with another BaseObj for equality. + * + * @param obj The object to check equality with. + * + * @return boolean + */ + @Override + public boolean equals(Object obj) { + // Early-out check to see if both BaseObjs are actually the same + if (this == obj) + return true; + + if (getClass() != obj.getClass()) { + return false; + } + + BaseObj b = (BaseObj) obj; + return mID == b.mID; + } } |