diff options
author | Sven Gothel <[email protected]> | 2014-02-23 14:51:06 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-02-23 14:51:06 +0100 |
commit | 3352601e0860584509adf2b76f993d03893ded4b (patch) | |
tree | 974fccc8c0eb2f5ad9d4ffd741dfc35869ed67b5 /src/jogl/classes/jogamp/opengl/MemoryObject.java | |
parent | f51933f0ebe9ae030c26c066e59a728ce08b8559 (diff) | |
parent | c67de337a8aaf52e36104c3f13e273aa19d21f1f (diff) |
Merge branch 'master' into stash_glyphcache
Conflicts:
make/scripts/tests.sh
src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java
src/jogl/classes/com/jogamp/graph/curve/Region.java
src/jogl/classes/com/jogamp/graph/curve/opengl/GLRegion.java
src/jogl/classes/com/jogamp/graph/curve/opengl/RegionRenderer.java
src/jogl/classes/com/jogamp/graph/curve/opengl/Renderer.java
src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderer.java
src/jogl/classes/com/jogamp/graph/font/Font.java
src/jogl/classes/com/jogamp/opengl/math/VectorUtil.java
src/jogl/classes/jogamp/graph/curve/text/GlyphShape.java
src/jogl/classes/jogamp/graph/curve/text/GlyphString.java
src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
src/jogl/classes/jogamp/graph/font/typecast/TypecastGlyph.java
src/jogl/classes/jogamp/graph/font/typecast/TypecastRenderer.java
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/MemoryObject.java')
-rw-r--r-- | src/jogl/classes/jogamp/opengl/MemoryObject.java | 65 |
1 files changed, 23 insertions, 42 deletions
diff --git a/src/jogl/classes/jogamp/opengl/MemoryObject.java b/src/jogl/classes/jogamp/opengl/MemoryObject.java index 292700701..6ebefc517 100644 --- a/src/jogl/classes/jogamp/opengl/MemoryObject.java +++ b/src/jogl/classes/jogamp/opengl/MemoryObject.java @@ -31,19 +31,22 @@ package jogamp.opengl; import java.nio.ByteBuffer; import java.util.HashMap; +import javax.media.opengl.GLBufferStorage; + +import com.jogamp.common.util.HashUtil; + /** - * + * @deprecated No more used for GL buffer storage tracking, see {@link GLBufferStorage} and {@link GLBufferObjectTracker}. */ public class MemoryObject { - private long addr; - private long size; - private int hash32; + private final long addr; + private final long size; + private final int hash; private ByteBuffer buffer=null; - public MemoryObject(long addr, long size) { this.addr = addr; this.size = size; - this.hash32 = getHash32(addr, size); + this.hash = HashUtil.getAddrSizeHash32_EqualDist(addr, size); } public void setBuffer(ByteBuffer buffer) { @@ -55,68 +58,46 @@ public class MemoryObject { } /** - * @return the 32bit hash value generated via {@link #getHash32(long, long)} + * @return the 32bit hash value generated via {@link HashUtil#getAddrSizeHash32_EqualDist(long, long)}. */ + @Override public int hashCode() { - return hash32; + return hash; + } + + @Override + public String toString() { + return "MemoryObject[addr 0x"+Long.toHexString(addr)+", size 0x"+Long.toHexString(size)+", hash32: 0x"+Integer.toHexString(hash)+"]"; } /** * 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) { - MemoryObject m = (MemoryObject) obj; + final MemoryObject m = (MemoryObject) obj; return addr == m.addr && size == m.size ; } return false; } /** - * Generates a 32bit hash value by <code>addr</code> and <code>size</code>.<br> - * Ignores the optional attached <code>ByteBuffer</code> intentionally.<br> - */ - public static int getHash32(long addr, long size) { - // avoid xor collisions of eg low/high parts - // 31 * x == (x << 5) - x - int hash = 31 + (int) addr ; // lo addr - hash = ((hash << 5) - hash) + (int) ( addr >>> 32 ) ; // hi addr - hash = ((hash << 5) - hash) + (int) size ; // lo size - hash = ((hash << 5) - hash) + (int) ( size >>> 32 ) ; // hi size - - return hash; - } - - /** - * Generates a 64bit hash value by <code>addr</code> and <code>size</code>.<br> - * Ignores the optional attached <code>ByteBuffer</code> intentionally.<br> - */ - public static long getHash64(long addr, long size) { - // 31 * x == (x << 5) - x - final long hash = 31 + addr; - return ((hash << 5) - hash) + size; - } - - public String toString() { - return "MemoryObject[addr 0x"+Long.toHexString(addr)+", size 0x"+Long.toHexString(size)+", hash32: 0x"+Integer.toHexString(hash32)+"]"; - } - - /** * @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 |