From 946e0b59847de43d3dd51080abe7b9703d431e5f Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Fri, 18 Oct 2013 07:55:37 -0700 Subject: jogl: replce more unneeded String() construction Signed-off-by: Harvey Harrison --- .../classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java | 2 +- .../classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java | 9 ++++----- .../classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java | 6 +++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java b/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java index 4903e6acd..44fbf1c6d 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java +++ b/src/jogl/classes/com/jogamp/opengl/util/glsl/sdk/CompileShader.java @@ -137,7 +137,7 @@ public abstract class CompileShader { } String dirname; if (lastSlash < 0) { - dirname = new String(); + dirname = ""; } else { dirname = path.substring(0, lastSlash + 1); } diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java index 24198703a..05a94def8 100644 --- a/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java +++ b/src/jogl/classes/jogamp/opengl/util/av/impl/OMXGLMediaPlayer.java @@ -183,16 +183,15 @@ public class OMXGLMediaPlayer extends EGLMediaPlayerImpl { } private String replaceAll(String orig, String search, String repl) { - String dest=null; + StringBuilder dest = new StringBuilder(); // In case replaceAll / java.util.regex.* is not supported (-> CVM) int i=0,j; - dest = new String(); while((j=orig.indexOf(search, i))>=0) { - dest=dest.concat(orig.substring(i, j)); - dest=dest.concat(repl); + dest.append(orig.substring(i, j)); + dest.append(repl); i=j+1; } - return dest.concat(orig.substring(i, orig.length())); + return dest.append(orig.substring(i, orig.length())).toString(); } private void errorCheckEGL(String s) { diff --git a/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java b/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java index c02fc0a04..eeec66376 100644 --- a/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java +++ b/src/nativewindow/classes/com/jogamp/nativewindow/awt/DirectDataBufferInt.java @@ -70,9 +70,9 @@ public final class DirectDataBufferInt extends DataBuffer { @Override public String toString() { - return new String("BufferedImageInt@"+Integer.toHexString(hashCode()) - +": custom/internal type = "+customImageType+"/"+getType() - +" "+getColorModel()+" "+getRaster()); + return "BufferedImageInt@"+Integer.toHexString(hashCode()) + +": custom/internal type = "+customImageType+"/"+getType() + +" "+getColorModel()+" "+getRaster(); } } -- cgit v1.2.3 From 2e13993b57061e897889a3a6f4a1d44a19c32d11 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Fri, 18 Oct 2013 08:06:46 -0700 Subject: jogl: remove clone() method that only throws Exceptions commit: a4e3f241cfba55e407c68eba91ffcc4beb0758b5 (Analysis of glXMakeCurrent freeze on ATI fglrx 8.78.6; Misc ..) Removed 'implements Clonable' from NamedDisplay, which means Object.clone() will always throw CloneNotSupportedException. Kill clone(). Signed-off-by: Harvey Harrison --- src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java index 2576c7db1..02e43791c 100644 --- a/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java +++ b/src/nativewindow/classes/jogamp/nativewindow/x11/X11Util.java @@ -325,11 +325,6 @@ public class X11Util implements ToolkitProperties { public final boolean isUncloseable() { return unCloseable; } public final Throwable getCreationStack() { return creationStack; } - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } - @Override public String toString() { return "NamedX11Display["+name+", 0x"+Long.toHexString(handle)+", refCount "+refCount+", unCloseable "+unCloseable+"]"; -- cgit v1.2.3 From 873a34debe0870c4ecd7aa646f92a18b2efc7ce8 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Fri, 18 Oct 2013 08:13:03 -0700 Subject: jogl: remove clone() version that can only ever fail commit: d75835796900cac602f7e5789601ffba0a27efe2 (Graph: More std. functionality (equals, clone) / Better in-place transformation (cubic -> quadratic)) Added a clone method, but did not implement Cloneable, meaning Object.clone() will always throw CloneNotSupportedException. This method never returns anythng but null. Signed-off-by: Harvey Harrison --- .../classes/com/jogamp/graph/curve/OutlineShape.java | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java index 60d5199eb..226e57f07 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java +++ b/src/jogl/classes/com/jogamp/graph/curve/OutlineShape.java @@ -612,21 +612,4 @@ public class OutlineShape implements Comparable { } return true; } - - /** - * @return deep clone of this OutlineShape w/o Region - */ - @Override - public OutlineShape clone() { - OutlineShape o; - try { - o = (OutlineShape) super.clone(); - } catch (CloneNotSupportedException e) { throw new InternalError(); } - o.bbox = bbox.clone(); - o.outlines = new ArrayList(outlines.size()); - for(int i=0; i Date: Fri, 18 Oct 2013 08:35:23 -0700 Subject: jogl: enable generics annotations on TextRenderer These were already here, enable them. Signed-off-by: Harvey Harrison --- .../com/jogamp/opengl/util/awt/TextRenderer.java | 29 ++++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java index 73d06cae0..3662223f4 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java +++ b/src/jogl/classes/com/jogamp/opengl/util/awt/TextRenderer.java @@ -171,7 +171,7 @@ public class TextRenderer { private TextureRenderer cachedBackingStore; private Graphics2D cachedGraphics; private FontRenderContext cachedFontRenderContext; - private Map /**/ stringLocations = new HashMap /**/(); + private Map stringLocations = new HashMap(); private GlyphProducer mGlyphProducer; private int numRenderCycles; @@ -335,9 +335,9 @@ public class TextRenderer { is made to ensure an accurate bound. */ public Rectangle2D getBounds(CharSequence str) { // FIXME: this should be more optimized and use the glyph cache - Rect r = null; + Rect r = stringLocations.get(str); - if ((r = (Rect) stringLocations.get(str)) != null) { + if (r != null) { TextData data = (TextData) r.getUserData(); // Reconstitute the Java 2D results based on the cached values @@ -750,7 +750,7 @@ public class TextRenderer { } private void clearUnusedEntries() { - final java.util.List deadRects = new ArrayList /**/(); + final java.util.List deadRects = new ArrayList(); // Iterate through the contents of the backing store, removing // text strings that haven't been used recently @@ -767,8 +767,7 @@ public class TextRenderer { } }); - for (Iterator iter = deadRects.iterator(); iter.hasNext();) { - Rect r = (Rect) iter.next(); + for (Rect r : deadRects) { packer.remove(r); stringLocations.remove(((TextData) r.getUserData()).string()); @@ -807,9 +806,7 @@ public class TextRenderer { private void internal_draw3D(CharSequence str, float x, float y, float z, float scaleFactor) { - List/**/ glyphs = mGlyphProducer.getGlyphs(str); - for (Iterator iter = glyphs.iterator(); iter.hasNext(); ) { - Glyph glyph = (Glyph) iter.next(); + for (Glyph glyph : mGlyphProducer.getGlyphs(str)) { float advance = glyph.draw3D(x, y, z, scaleFactor); x += advance * scaleFactor; } @@ -831,7 +828,7 @@ public class TextRenderer { } // Look up the string on the backing store - Rect rect = (Rect) stringLocations.get(curStr); + Rect rect = stringLocations.get(curStr); if (rect == null) { // Rasterize this string and place it on the backing store @@ -1588,9 +1585,9 @@ public class TextRenderer { class GlyphProducer { final int undefined = -2; FontRenderContext fontRenderContext; - List/**/ glyphsOutput = new ArrayList/**/(); - HashMap/**/fullGlyphVectorCache = new HashMap/**/(); - HashMap/**/glyphMetricsCache = new HashMap/**/(); + List glyphsOutput = new ArrayList(); + HashMap fullGlyphVectorCache = new HashMap(); + HashMap glyphMetricsCache = new HashMap(); // The mapping from unicode character to font-specific glyph ID int[] unicodes2Glyphs; // The mapping from glyph ID to Glyph @@ -1604,10 +1601,10 @@ public class TextRenderer { clearAllCacheEntries(); } - public List/**/ getGlyphs(CharSequence inString) { + public List getGlyphs(CharSequence inString) { glyphsOutput.clear(); GlyphVector fullRunGlyphVector; - fullRunGlyphVector = (GlyphVector) fullGlyphVectorCache.get(inString.toString()); + fullRunGlyphVector = fullGlyphVectorCache.get(inString.toString()); if (fullRunGlyphVector == null) { iter.initFromCharSequence(inString); fullRunGlyphVector = font.createGlyphVector(getFontRenderContext(), iter); @@ -1624,7 +1621,7 @@ public class TextRenderer { int i = 0; while (i < lengthInGlyphs) { Character letter = CharacterCache.valueOf(inString.charAt(i)); - GlyphMetrics metrics = (GlyphMetrics) glyphMetricsCache.get(letter); + GlyphMetrics metrics = glyphMetricsCache.get(letter); if (metrics == null) { metrics = fullRunGlyphVector.getGlyphMetrics(i); glyphMetricsCache.put(letter, metrics); -- cgit v1.2.3 From aba59607bc738361dd81c5cd5362ad0ec322b441 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Mon, 21 Oct 2013 00:02:17 -0700 Subject: jogl: adapt code generator to output @Override annotations in various places This adds the @Override to methods in the GL implementations (debug, trace, etc) for methods implementing a GL Profile. It also adds @Override for the toString() method. Signed-off-by: Harvey Harrison --- .../classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index 5f358a6d3..73ccabfbd 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -456,8 +456,8 @@ public class BuildComposablePipeline { } protected void emitSignature(PrintWriter output, Method m) { + output.println(" @Override"); output.print(" public "); - output.print(' '); output.print(JavaType.createForClass(m.getReturnType()).getName()); output.print(' '); output.print(m.getName()); @@ -589,6 +589,7 @@ public class BuildComposablePipeline { * closing parenthesis of the class is emitted. */ protected void postMethodEmissionHook(PrintWriter output) { + output.println(" @Override"); output.println(" public String toString() {"); output.println(" StringBuilder sb = new StringBuilder();"); output.println(" sb.append(\"" + getOutputName() + " [ implementing " + baseInterfaceClass.getName() + ",\\n\\t\");"); -- cgit v1.2.3 From 27f6fce2e629e421793eaeb0e09cb6c10d9c0aa1 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Mon, 21 Oct 2013 00:43:46 -0700 Subject: jogl: use .format() to build the method signature when generating pipeline code Signed-off-by: Harvey Harrison --- .../com/jogamp/gluegen/opengl/BuildComposablePipeline.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index 73ccabfbd..082ecfe5e 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -456,14 +456,10 @@ public class BuildComposablePipeline { } protected void emitSignature(PrintWriter output, Method m) { - output.println(" @Override"); - output.print(" public "); - output.print(JavaType.createForClass(m.getReturnType()).getName()); - output.print(' '); - output.print(m.getName()); - output.print('('); - output.print(getArgListAsString(m, true, true)); - output.println(")"); + output.format(" @Override%n public %s %s(%s)%n", + JavaType.createForClass(m.getReturnType()).getName(), + m.getName(), + getArgListAsString(m, true, true)); } protected void emitBody(PrintWriter output, Method m, boolean runHooks) { -- cgit v1.2.3 From c1bb679c5d6d36e91c146d5e075e093bc83a07f1 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Tue, 22 Oct 2013 00:12:44 -0700 Subject: jogl: change code generation for Debug pipelines to avoid building large strings - split the check for a GL error from the output of the error string - only build the caller String when there is an error to report - wrap String building in an if() block rather than using an early return as we don't know the return type in the postDownstreamCallHook Signed-off-by: Harvey Harrison --- .../gluegen/opengl/BuildComposablePipeline.java | 26 +++++++++------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index 082ecfe5e..d7196f77e 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -925,23 +925,16 @@ public class BuildComposablePipeline { @Override protected void postMethodEmissionHook(PrintWriter output) { super.postMethodEmissionHook(output); - output.println(" private void checkGLGetError(String caller)"); - output.println(" {"); + output.println(" private int checkGLError() {"); if (hasImmediateMode) { - output.println(" if (insideBeginEndPair) {"); - output.println(" return;"); - output.println(" }"); + output.println(" if (insideBeginEndPair) return GL_NO_ERROR;"); output.println(); } - output.println(" // Debug code to make sure the pipeline is working; leave commented out unless testing this class"); - output.println(" //System.err.println(\"Checking for GL errors " - + "after call to \" + caller);"); - output.println(); - output.println(" int err = " - + getDownstreamObjectName() - + ".glGetError();"); - output.println(" if (err == GL_NO_ERROR) { return; }"); - output.println(); + output.format(" return %s.glGetError();%n", getDownstreamObjectName()); + output.println(" }"); + + output.println(" private void writeGLError(int err, String caller)"); + output.println(" {"); output.println(" StringBuilder buf = new StringBuilder(Thread.currentThread()+"); output.println(" \" glGetError() returned the following error codes after a call to \" + caller + \": \");"); output.println(); @@ -1027,6 +1020,8 @@ public class BuildComposablePipeline { output.println(" insideBeginEndPair = false;"); } + output.println(" int err = checkGLError();"); + output.println(" if (err != GL_NO_ERROR) {"); output.println(" String txt = new String(\"" + m.getName() + "(\" +"); Class[] params = m.getParameterTypes(); for (int i = 0; params != null && i < params.length; i++) { @@ -1044,7 +1039,8 @@ public class BuildComposablePipeline { } output.println(" \")\");"); // calls to glGetError() are only allowed outside of glBegin/glEnd pairs - output.println(" checkGLGetError( txt );"); + output.println(" writeGLError( err, txt );"); + output.println(" }"); } } } // end class DebugPipeline -- cgit v1.2.3 From cf0d18c7b82801f41f6fe30f5d09b6a0a9546893 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Tue, 22 Oct 2013 00:20:06 -0700 Subject: jogl: do not generate an extra String for the Debug pipeline wrappers Build the caller string directly and don't wrap it in an extra constructor. Update the indentation level for the newly added if-block from the previous commit. Signed-off-by: Harvey Harrison --- .../com/jogamp/gluegen/opengl/BuildComposablePipeline.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index d7196f77e..1d34ccfd7 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -1022,10 +1022,10 @@ public class BuildComposablePipeline { output.println(" int err = checkGLError();"); output.println(" if (err != GL_NO_ERROR) {"); - output.println(" String txt = new String(\"" + m.getName() + "(\" +"); + output.println(" String txt = \"" + m.getName() + "(\" +"); Class[] params = m.getParameterTypes(); for (int i = 0; params != null && i < params.length; i++) { - output.print(" \"<" + params[i].getName() + ">"); + output.print(" \"<" + params[i].getName() + ">"); if (params[i].isArray()) { output.print("\" +"); } else if (params[i].equals(int.class)) { @@ -1037,9 +1037,9 @@ public class BuildComposablePipeline { output.println(" \", \" +"); } } - output.println(" \")\");"); + output.println(" \")\";"); // calls to glGetError() are only allowed outside of glBegin/glEnd pairs - output.println(" writeGLError( err, txt );"); + output.println(" writeGLError( err, txt );"); output.println(" }"); } } -- cgit v1.2.3 From 7fd9174afe73ae2a61af9a6d101afb7f21bb608b Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Tue, 22 Oct 2013 22:23:53 -0700 Subject: jogl: save on class size in the Debug pipelines Using a format String and arg list produces smaller class files for the Debug classes as many of the format strings are identical and shared. Signed-off-by: Harvey Harrison --- .../gluegen/opengl/BuildComposablePipeline.java | 33 ++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index 1d34ccfd7..a84869756 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -932,7 +932,7 @@ public class BuildComposablePipeline { } output.format(" return %s.glGetError();%n", getDownstreamObjectName()); output.println(" }"); - + output.println(" private void writeGLError(int err, String caller)"); output.println(" {"); output.println(" StringBuilder buf = new StringBuilder(Thread.currentThread()+"); @@ -1022,22 +1022,33 @@ public class BuildComposablePipeline { output.println(" int err = checkGLError();"); output.println(" if (err != GL_NO_ERROR) {"); - output.println(" String txt = \"" + m.getName() + "(\" +"); + + StringBuilder fmtsb = new StringBuilder(); + StringBuilder argsb = new StringBuilder(); + + fmtsb.append(" String txt = String.format(\"%s("); + argsb.append(" \"").append(m.getName()).append("\""); Class[] params = m.getParameterTypes(); - for (int i = 0; params != null && i < params.length; i++) { - output.print(" \"<" + params[i].getName() + ">"); + for (int i = 0; i < params.length; i++) { + if (i > 0) { + fmtsb.append(", "); + } + fmtsb.append("<").append(params[i].getName()).append(">"); if (params[i].isArray()) { - output.print("\" +"); + //nothing } else if (params[i].equals(int.class)) { - output.print(" 0x\"+Integer.toHexString(arg" + i + ").toUpperCase() +"); + fmtsb.append(" 0x%X"); + argsb.append(", arg").append(i); } else { - output.print(" \"+arg" + i + " +"); - } - if (i < params.length - 1) { - output.println(" \", \" +"); + fmtsb.append(" %s"); + argsb.append(", arg").append(i); } } - output.println(" \")\";"); + fmtsb.append(")\","); + argsb.append(");"); + + output.println(fmtsb.toString()); + output.println(argsb.toString()); // calls to glGetError() are only allowed outside of glBegin/glEnd pairs output.println(" writeGLError( err, txt );"); output.println(" }"); -- cgit v1.2.3 From fa865a86033f64309b777dec7f557376f7f0eb46 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Tue, 22 Oct 2013 22:50:42 -0700 Subject: jogl: pass format and arguments directly to the printGLError function This saves us a bit more code size as the String.format is now in the common helper rather than in every GL wrapper function. Signed-off-by: Harvey Harrison --- .../jogamp/gluegen/opengl/BuildComposablePipeline.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index a84869756..a51151b82 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -933,10 +933,13 @@ public class BuildComposablePipeline { output.format(" return %s.glGetError();%n", getDownstreamObjectName()); output.println(" }"); - output.println(" private void writeGLError(int err, String caller)"); + output.println(" private void writeGLError(int err, String fmt, Object... args)"); output.println(" {"); - output.println(" StringBuilder buf = new StringBuilder(Thread.currentThread()+"); - output.println(" \" glGetError() returned the following error codes after a call to \" + caller + \": \");"); + output.println(" StringBuilder buf = new StringBuilder();"); + output.println(" buf.append(Thread.currentThread().toString());"); + output.println(" buf.append(\" glGetError() returned the following error codes after a call to \");"); + output.println(" buf.append(String.format(fmt, args));"); + output.println(" buf.append(\": \");"); output.println(); output.println(" // Loop repeatedly to allow for distributed GL implementations,"); output.println(" // as detailed in the glGetError() specification"); @@ -1026,8 +1029,8 @@ public class BuildComposablePipeline { StringBuilder fmtsb = new StringBuilder(); StringBuilder argsb = new StringBuilder(); - fmtsb.append(" String txt = String.format(\"%s("); - argsb.append(" \"").append(m.getName()).append("\""); + fmtsb.append("\"%s("); + argsb.append("\"").append(m.getName()).append("\""); Class[] params = m.getParameterTypes(); for (int i = 0; i < params.length; i++) { if (i > 0) { @@ -1047,10 +1050,11 @@ public class BuildComposablePipeline { fmtsb.append(")\","); argsb.append(");"); + // calls to glGetError() are only allowed outside of glBegin/glEnd pairs + output.print(" writeGLError(err, "); output.println(fmtsb.toString()); + output.print(" "); output.println(argsb.toString()); - // calls to glGetError() are only allowed outside of glBegin/glEnd pairs - output.println(" writeGLError( err, txt );"); output.println(" }"); } } -- cgit v1.2.3 From 0e79445985e23f0ff8c600137052cc446af421be Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Wed, 23 Oct 2013 10:25:17 -0700 Subject: jogl: add final to Debug wrapper error code and fix indentation Make the indentation consistent in each function wrapper. Signed-off-by: Harvey Harrison --- .../com/jogamp/gluegen/opengl/BuildComposablePipeline.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index a51151b82..59ec9d35a 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -464,7 +464,6 @@ public class BuildComposablePipeline { protected void emitBody(PrintWriter output, Method m, boolean runHooks) { output.println(" {"); - output.print(" "); Class retType = m.getReturnType(); boolean callPreDownstreamHook = runHooks && hasPreDownstreamCallHook(m); @@ -510,6 +509,9 @@ public class BuildComposablePipeline { output.print(" return "); } } + else { + output.print(" "); + } output.print(getDownstreamObjectName()); output.print('.'); output.print(m.getName()); @@ -1023,7 +1025,7 @@ public class BuildComposablePipeline { output.println(" insideBeginEndPair = false;"); } - output.println(" int err = checkGLError();"); + output.println(" final int err = checkGLError();"); output.println(" if (err != GL_NO_ERROR) {"); StringBuilder fmtsb = new StringBuilder(); @@ -1172,10 +1174,10 @@ public class BuildComposablePipeline { @Override protected void preDownstreamCallHook(PrintWriter output, Method m) { if (m.getName().equals("glEnd") || m.getName().equals("glEndList")) { - output.println("indent-=2;"); + output.println(" indent-=2;"); output.println(" printIndent();"); } else { - output.println("printIndent();"); + output.println(" printIndent();"); } output.print(" print("); -- cgit v1.2.3 From b77bd2e9de054124ef81413aa338c635dbdc5a54 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Wed, 23 Oct 2013 13:25:59 -0700 Subject: jogl: indent trace statements in the Trace pipelines when we hit glBegin The indent was being reduced on glEnd/glEndList but was never being incremented. The intent appeared to be to indent all statements between glBEgin/glEnd pairs to show the nested context of those calls. Add the increment after printing the glBegin trace statement. Signed-off-by: Harvey Harrison --- .../classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java index 59ec9d35a..703f832c3 100644 --- a/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java +++ b/src/jogl/classes/com/jogamp/gluegen/opengl/BuildComposablePipeline.java @@ -1198,6 +1198,9 @@ public class BuildComposablePipeline { } else { output.println(" println(\"\");"); } + + if (m.getName().equals("glBegin")) + output.println(" indent+=2;"); } private String getOutputStreamName() { -- cgit v1.2.3 From ee9d26c28589a25329ebd26ee6f714db0eedd092 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Wed, 23 Oct 2013 00:01:48 -0700 Subject: jogl: add generic annotations to the packed rectangle utility package Signed-off-by: Harvey Harrison --- .../com/jogamp/opengl/util/packrect/Level.java | 44 +++++++++++----------- .../com/jogamp/opengl/util/packrect/LevelSet.java | 24 ++++++------ .../opengl/util/packrect/RectanglePacker.java | 30 +++++++-------- 3 files changed, 47 insertions(+), 51 deletions(-) diff --git a/src/jogl/classes/com/jogamp/opengl/util/packrect/Level.java b/src/jogl/classes/com/jogamp/opengl/util/packrect/Level.java index 661e104b6..9aadfba93 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/packrect/Level.java +++ b/src/jogl/classes/com/jogamp/opengl/util/packrect/Level.java @@ -47,15 +47,13 @@ public class Level { private int yPos; private LevelSet holder; - private List/**/ rects = new ArrayList/**/(); - private List/**/ freeList; + private List rects = new ArrayList(); + private List freeList; private int nextAddX; - static class RectXComparator implements Comparator { + static class RectXComparator implements Comparator { @Override - public int compare(Object o1, Object o2) { - Rect r1 = (Rect) o1; - Rect r2 = (Rect) o2; + public int compare(Rect r1, Rect r2) { return r1.x() - r2.x(); } @@ -64,7 +62,7 @@ public class Level { return this == obj; } } - private static final Comparator rectXComparator = new RectXComparator(); + private static final Comparator rectXComparator = new RectXComparator(); public Level(int width, int height, int yPos, LevelSet holder) { this.width = width; @@ -110,8 +108,8 @@ public class Level { // See whether we can add from the free list if (freeList != null) { Rect candidate = null; - for (Iterator iter = freeList.iterator(); iter.hasNext(); ) { - Rect cur = (Rect) iter.next(); + for (Iterator iter = freeList.iterator(); iter.hasNext(); ) { + Rect cur = iter.next(); if (cur.canContain(rect)) { candidate = cur; break; @@ -151,7 +149,7 @@ public class Level { nextAddX -= rect.w(); } else { if (freeList == null) { - freeList = new ArrayList/**/(); + freeList = new ArrayList(); } freeList.add(new Rect(rect.x(), rect.y(), rect.w(), height, null)); coalesceFreeList(); @@ -173,8 +171,8 @@ public class Level { if (freeList == null) return false; int freeListWidth = 0; - for (Iterator iter = freeList.iterator(); iter.hasNext(); ) { - Rect cur = (Rect) iter.next(); + for (Iterator iter = freeList.iterator(); iter.hasNext(); ) { + Rect cur = iter.next(); freeListWidth += cur.w(); } // Add on the remaining space at the end @@ -186,8 +184,8 @@ public class Level { Collections.sort(rects, rectXComparator); int nextCompactionDest = 0; manager.beginMovement(backingStore, backingStore); - for (Iterator iter = rects.iterator(); iter.hasNext(); ) { - Rect cur = (Rect) iter.next(); + for (Iterator iter = rects.iterator(); iter.hasNext(); ) { + Rect cur = iter.next(); if (cur.x() != nextCompactionDest) { manager.move(backingStore, cur, backingStore, new Rect(nextCompactionDest, cur.y(), cur.w(), cur.h(), null)); @@ -200,14 +198,14 @@ public class Level { manager.endMovement(backingStore, backingStore); } - public Iterator iterator() { + public Iterator iterator() { return rects.iterator(); } /** Visits all Rects contained in this Level. */ public void visit(RectVisitor visitor) { - for (Iterator iter = rects.iterator(); iter.hasNext(); ) { - Rect rect = (Rect) iter.next(); + for (Iterator iter = rects.iterator(); iter.hasNext(); ) { + Rect rect = iter.next(); visitor.visit(rect); } } @@ -218,7 +216,7 @@ public class Level { original Rects. */ public void updateRectangleReferences() { for (int i = 0; i < rects.size(); i++) { - Rect cur = (Rect) rects.get(i); + Rect cur = rects.get(i); Rect next = cur.getNextLocation(); next.setPosition(cur.x(), cur.y()); if (cur.w() != next.w() || cur.h() != next.h()) @@ -237,8 +235,8 @@ public class Level { Collections.sort(freeList, rectXComparator); int i = 0; while (i < freeList.size() - 1) { - Rect r1 = (Rect) freeList.get(i); - Rect r2 = (Rect) freeList.get(i+1); + Rect r1 = freeList.get(i); + Rect r2 = freeList.get(i+1); if (r1.maxX() + 1 == r2.x()) { // Coalesce r1 and r2 into one block freeList.remove(i+1); @@ -248,7 +246,7 @@ public class Level { } } // See whether the last block bumps up against the addition point - Rect last = (Rect) freeList.get(freeList.size() - 1); + Rect last = freeList.get(freeList.size() - 1); if (last.maxX() + 1 == nextAddX) { nextAddX -= last.w(); freeList.remove(freeList.size() - 1); @@ -264,8 +262,8 @@ public class Level { public void dumpFreeSpace() { int freeListWidth = 0; - for (Iterator iter = freeList.iterator(); iter.hasNext(); ) { - Rect cur = (Rect) iter.next(); + for (Iterator iter = freeList.iterator(); iter.hasNext(); ) { + Rect cur = iter.next(); System.err.println(" Free rectangle at " + cur); freeListWidth += cur.w(); } diff --git a/src/jogl/classes/com/jogamp/opengl/util/packrect/LevelSet.java b/src/jogl/classes/com/jogamp/opengl/util/packrect/LevelSet.java index e14eef5ba..433421f1a 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/packrect/LevelSet.java +++ b/src/jogl/classes/com/jogamp/opengl/util/packrect/LevelSet.java @@ -47,7 +47,7 @@ import java.util.*; public class LevelSet { // Maintained in sorted order by increasing Y coordinate - private List/**/ levels = new ArrayList/**/(); + private List levels = new ArrayList(); private int nextAddY; private int w; private int h; @@ -73,7 +73,7 @@ public class LevelSet { // Go in reverse order through the levels seeing whether we can // trivially satisfy the allocation request for (int i = levels.size() - 1; i >= 0; --i) { - Level level = (Level) levels.get(i); + Level level = levels.get(i); if (level.add(rect)) return true; } @@ -82,7 +82,7 @@ public class LevelSet { // increases the computational complexity of the addition process, // but prevents us from expanding unnecessarily. for (int i = levels.size() - 1; i >= 0; --i) { - Level level = (Level) levels.get(i); + Level level = levels.get(i); if (level.couldAllocateIfCompacted(rect)) return false; } @@ -104,7 +104,7 @@ public class LevelSet { /** Removes the given Rect from this LevelSet. */ public boolean remove(Rect rect) { for (int i = levels.size() - 1; i >= 0; --i) { - Level level = (Level) levels.get(i); + Level level = levels.get(i); if (level.remove(rect)) return true; } @@ -120,7 +120,7 @@ public class LevelSet { Object backingStore, BackingStoreManager manager) { for (int i = levels.size() - 1; i >= 0; --i) { - Level level = (Level) levels.get(i); + Level level = levels.get(i); if (level.couldAllocateIfCompacted(rect)) { level.compact(backingStore, manager); boolean res = level.add(rect); @@ -173,8 +173,8 @@ public class LevelSet { int usedHeight = getUsedHeight(); if (usedHeight == 0) return 0.0f; - for (Iterator iter = iterator(); iter.hasNext(); ) { - Level level = (Level) iter.next(); + for (Iterator iter = iterator(); iter.hasNext(); ) { + Level level = iter.next(); if (level.isEmpty()) { freeHeight += level.h(); } @@ -182,14 +182,14 @@ public class LevelSet { return (float) freeHeight / (float) usedHeight; } - public Iterator iterator() { + public Iterator iterator() { return levels.iterator(); } /** Visits all Rects contained in this LevelSet. */ public void visit(RectVisitor visitor) { - for (Iterator iter = levels.iterator(); iter.hasNext(); ) { - Level level = (Level) iter.next(); + for (Iterator iter = levels.iterator(); iter.hasNext(); ) { + Level level = iter.next(); level.visit(visitor); } } @@ -199,8 +199,8 @@ public class LevelSet { update the new Rects in a newly laid-out LevelSet with the original Rects. */ public void updateRectangleReferences() { - for (Iterator iter = levels.iterator(); iter.hasNext(); ) { - Level level = (Level) iter.next(); + for (Iterator iter = levels.iterator(); iter.hasNext(); ) { + Level level = iter.next(); level.updateRectangleReferences(); } } diff --git a/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java b/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java index 2ee6a79b3..44faa44b0 100644 --- a/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java +++ b/src/jogl/classes/com/jogamp/opengl/util/packrect/RectanglePacker.java @@ -60,11 +60,9 @@ public class RectanglePacker { private int maxWidth = -1; private int maxHeight = -1; - static class RectHComparator implements Comparator { + static class RectHComparator implements Comparator { @Override - public int compare(Object o1, Object o2) { - Rect r1 = (Rect) o1; - Rect r2 = (Rect) o2; + public int compare(Rect r1, Rect r2) { return r2.h() - r1.h(); } @@ -73,7 +71,7 @@ public class RectanglePacker { return this == obj; } } - private static final Comparator rectHComparator = new RectHComparator(); + private static final Comparator rectHComparator = new RectHComparator(); public RectanglePacker(BackingStoreManager manager, int initialWidth, @@ -207,11 +205,11 @@ public class RectanglePacker { nextLevelSet = new LevelSet(newWidth, newHeight); // Make copies of all existing rectangles - List/**/ newRects = new ArrayList/**/(); - for (Iterator i1 = levels.iterator(); i1.hasNext(); ) { - Level level = (Level) i1.next(); - for (Iterator i2 = level.iterator(); i2.hasNext(); ) { - Rect cur = (Rect) i2.next(); + List newRects = new ArrayList(); + for (Iterator i1 = levels.iterator(); i1.hasNext(); ) { + Level level = i1.next(); + for (Iterator i2 = level.iterator(); i2.hasNext(); ) { + Rect cur = i2.next(); Rect newRect = new Rect(0, 0, cur.w(), cur.h(), null); cur.setNextLocation(newRect); // Hook up the reverse mapping too for easier replacement @@ -224,8 +222,8 @@ public class RectanglePacker { Collections.sort(newRects, rectHComparator); // Try putting all of these rectangles into the new level set done = true; - for (Iterator iter = newRects.iterator(); iter.hasNext(); ) { - if (!nextLevelSet.add((Rect) iter.next())) { + for (Iterator iter = newRects.iterator(); iter.hasNext(); ) { + if (!nextLevelSet.add(iter.next())) { done = false; break; } @@ -273,10 +271,10 @@ public class RectanglePacker { Object newBackingStore = manager.allocateBackingStore(nextLevelSet.w(), nextLevelSet.h()); manager.beginMovement(backingStore, newBackingStore); - for (Iterator i1 = levels.iterator(); i1.hasNext(); ) { - Level level = (Level) i1.next(); - for (Iterator i2 = level.iterator(); i2.hasNext(); ) { - Rect cur = (Rect) i2.next(); + for (Iterator i1 = levels.iterator(); i1.hasNext(); ) { + Level level = i1.next(); + for (Iterator i2 = level.iterator(); i2.hasNext(); ) { + Rect cur = i2.next(); manager.move(backingStore, cur, newBackingStore, cur.getNextLocation()); } -- cgit v1.2.3 From 445e6117edb0ce3545d01065a067fb7a751db030 Mon Sep 17 00:00:00 2001 From: Harvey Harrison Date: Wed, 23 Oct 2013 00:33:24 -0700 Subject: jogl: add generics annotations to lists in the waveout code Signed-off-by: Harvey Harrison --- .../com/jogamp/audio/windows/waveout/Mixer.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/jogl/classes/com/jogamp/audio/windows/waveout/Mixer.java b/src/jogl/classes/com/jogamp/audio/windows/waveout/Mixer.java index 3b76d2ebf..b36fd2637 100644 --- a/src/jogl/classes/com/jogamp/audio/windows/waveout/Mixer.java +++ b/src/jogl/classes/com/jogamp/audio/windows/waveout/Mixer.java @@ -50,7 +50,7 @@ public class Mixer { // Windows Event object private long event; - private volatile ArrayList/**/ tracks = new ArrayList(); + private volatile ArrayList tracks = new ArrayList(); private Vec3f leftSpeakerPosition = new Vec3f(-1, 0, 0); private Vec3f rightSpeakerPosition = new Vec3f( 1, 0, 0); @@ -74,13 +74,13 @@ public class Mixer { } synchronized void add(Track track) { - ArrayList/**/ newTracks = (ArrayList) tracks.clone(); + ArrayList newTracks = new ArrayList(tracks); newTracks.add(track); tracks = newTracks; } synchronized void remove(Track track) { - ArrayList/**/ newTracks = (ArrayList) tracks.clone(); + ArrayList newTracks = new ArrayList(tracks); newTracks.remove(track); tracks = newTracks; } @@ -132,10 +132,10 @@ public class Mixer { @Override public void run() { while (!shutdown) { - List/**/ curTracks = tracks; + List curTracks = tracks; - for (Iterator iter = curTracks.iterator(); iter.hasNext(); ) { - Track track = (Track) iter.next(); + for (Iterator iter = curTracks.iterator(); iter.hasNext(); ) { + Track track = iter.next(); try { track.fill(); } catch (IOException e) { @@ -209,10 +209,10 @@ public class Mixer { } // Run down all of the registered tracks mixing them in - List/**/ curTracks = tracks; + List curTracks = tracks; - for (Iterator iter = curTracks.iterator(); iter.hasNext(); ) { - Track track = (Track) iter.next(); + for (Iterator iter = curTracks.iterator(); iter.hasNext(); ) { + Track track = iter.next(); // Consider only playing tracks if (track.isPlaying()) { // First recompute its gain -- cgit v1.2.3