aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2014-01-14 05:22:15 +0100
committerSven Gothel <[email protected]>2014-01-14 05:22:15 +0100
commit6c971f91fbe6a7e3bc45563d80d42a753586d629 (patch)
tree416eb9d25dee8cce265e8ea03d83aefe72f044f6 /src/jogl/classes/jogamp/opengl
parent41be8824318d709459c08669218696d196719c90 (diff)
Bug 938 - MemoryObject.java has no more equals() method
Re-adding 'equals(..)' method erroneously removed with commit 8457bf35fee253d9af29ff1150a9671f6896fc17. 'equals(..)' is important to allow the HashMap<> for glMapBuffer(..) work properly!
Diffstat (limited to 'src/jogl/classes/jogamp/opengl')
-rw-r--r--src/jogl/classes/jogamp/opengl/MemoryObject.java28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/jogl/classes/jogamp/opengl/MemoryObject.java b/src/jogl/classes/jogamp/opengl/MemoryObject.java
index d10747690..ac02e0bca 100644
--- a/src/jogl/classes/jogamp/opengl/MemoryObject.java
+++ b/src/jogl/classes/jogamp/opengl/MemoryObject.java
@@ -37,9 +37,9 @@ import com.jogamp.common.util.HashUtil;
*
*/
public class MemoryObject {
- private long addr;
- private long size;
- private int hash;
+ private final long addr;
+ private final long size;
+ private final int hash;
private ByteBuffer buffer=null;
public MemoryObject(long addr, long size) {
@@ -70,17 +70,33 @@ public class MemoryObject {
}
/**
+ * Ignores the optional attached <code>ByteBuffer</code> intentionally.<br>
+ *
+ * @return true of reference is equal or <code>obj</code> is of type <code>MemoryObject</code>
+ * and <code>addr</code> and <code>size</code> is equal.<br>
+ */
+ public boolean equals(Object obj) {
+ if(this == obj) { return true; }
+ if(obj instanceof MemoryObject) {
+ final MemoryObject m = (MemoryObject) obj;
+ return addr == m.addr && size == m.size ;
+ }
+ return false;
+ }
+
+ /**
* @param map the identity HashMap, MemoryObject to MemoryObject
* @param obj0 the MemoryObject
* @return either the already mapped MemoryObject - not changing the map, or the newly mapped one.
*/
public static MemoryObject getOrAddSafe(HashMap<MemoryObject,MemoryObject> map, MemoryObject obj0) {
- MemoryObject obj1 = map.get(obj0); // get identity (fast)
+ final MemoryObject obj1 = map.get(obj0); // get identity (fast)
if(null == obj1) {
map.put(obj0, obj0);
- obj1 = obj0;
+ return obj0;
+ } else {
+ return obj1;
}
- return obj1;
}
} \ No newline at end of file