summaryrefslogtreecommitdiffstats
path: root/graphics/java
diff options
context:
space:
mode:
authorStephen Hines <srhines@google.com>2011-06-09 10:11:54 -0700
committerStephen Hines <srhines@google.com>2011-06-09 11:16:59 -0700
commit705d2ea63a4b3c2345af83eec9dabdeea29cfa9f (patch)
tree9f221531a18db9e01493db3007f35d367e9e309f /graphics/java
parent40f4efe712b375cf0421f4651abbc703595d9d47 (diff)
downloadframeworks_base-705d2ea63a4b3c2345af83eec9dabdeea29cfa9f.zip
frameworks_base-705d2ea63a4b3c2345af83eec9dabdeea29cfa9f.tar.gz
frameworks_base-705d2ea63a4b3c2345af83eec9dabdeea29cfa9f.tar.bz2
Override equals()/hashCode() for RS BaseObj.
This will be used by slang reflection to type-check parameters to functions that are of Allocation types (such as what happens with forEach). BUG=4203264 Change-Id: I2ba94531bbf53becf7695b253e1faa3dff099894
Diffstat (limited to 'graphics/java')
-rw-r--r--graphics/java/android/renderscript/BaseObj.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/graphics/java/android/renderscript/BaseObj.java b/graphics/java/android/renderscript/BaseObj.java
index a17e735..63e7dd1 100644
--- a/graphics/java/android/renderscript/BaseObj.java
+++ b/graphics/java/android/renderscript/BaseObj.java
@@ -134,5 +134,35 @@ public 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;
+ }
}