summaryrefslogtreecommitdiffstats
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
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!
-rw-r--r--make/scripts/tests.sh4
-rw-r--r--src/jogl/classes/jogamp/opengl/MemoryObject.java28
2 files changed, 24 insertions, 8 deletions
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index ed8b8b395..3c79e3209 100644
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -389,7 +389,7 @@ function testawtswt() {
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGPUMemSec01NEWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $*
+testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMapBufferRead01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug669RecursiveGLContext02NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestBug692GL3VAONEWT $*
@@ -644,7 +644,7 @@ function testawtswt() {
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01aAWT $*
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01bAWT $*
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01cAWT $*
-testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01dAWT $*
+#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting01dAWT $*
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting02AWT $*
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting03AWT $*
#testawt com.jogamp.opengl.test.junit.newt.parenting.TestParenting04AWT $*
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