diff options
author | Sven Gothel <[email protected]> | 2014-04-02 19:25:16 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-04-02 19:25:16 +0200 |
commit | abc833631e0ab30a06c7aff47a39a551544fd735 (patch) | |
tree | 1d6e5a94d2149d7b2635de5b5eccb330bc41cd2c /src/test | |
parent | e8a5a1cbb988670ca206ab1ac633e19a91bfa478 (diff) |
Bug 801: Reduce temp. object creation, i.e. GC load
Diffstat (limited to 'src/test')
6 files changed, 34 insertions, 22 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java index 27e5ad90f..f9107ef3e 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TestTextRendererNEWT00.java @@ -136,9 +136,12 @@ public class TestTextRendererNEWT00 extends UITestCase { } static void sleep() { + sleep(Duration); + } + static void sleep(final long d) { try { - System.err.println("** new frame ** (sleep: "+Duration+"ms)"); - Thread.sleep(Duration); + System.err.println("** new frame ** (sleep: "+d+"ms)"); + Thread.sleep(d); } catch (InterruptedException ie) {} } @@ -373,22 +376,23 @@ public class TestTextRendererNEWT00 extends UITestCase { final float pixelSizeAnim = font.getPixelSize(fontSizeAnim, dpiH); final String modeS = Region.getRenderModeString(renderModes); - final String text1 = String.format("%03.1f/%03.1f fps, vsync %d, elapsed %4.1f s, fontSize %2.2f, msaa %d, %s-samples %d", - lfps, tfps, gl.getSwapInterval(), (t1-t0)/1000.0, fontSizeFixed, - drawable.getChosenGLCapabilities().getNumSamples(), modeS, vbaaSampleCount[0]); - final String text1A = String.format("%03.1f/%03.1f fps, vsync %d, elapsed %4.1f s, fontSize %2.2f, msaa %d, %s-samples %d", - lfps, tfps, gl.getSwapInterval(), (t1-t0)/1000.0, fontSizeAnim, - drawable.getChosenGLCapabilities().getNumSamples(), modeS, vbaaSampleCount[0]); if( true ) { // renderString(drawable, font, pixelSize, "I - / H P 7 0", 0, 0, 0, 0, -1000f, true); // renderString(drawable, font, pixelSize, "A M > } ] ", 0, 0, 0, 0, -1000f, true); - renderString(drawable, font, pixelSize, "M", 0, 0, 0, 0, -1000f, true); + // renderString(drawable, font, pixelSize, "M", 0, 0, 0, 0, -1000f, true); // renderString(drawable, font, pixelSize, "0 6 9 a b O Q A M > } ] ", 0, 0, 0, 0, -1000f, true); // renderString(drawable, font, pixelSize, "012345678901234567890123456789", 0, 0, 0, -1000, true); // renderString(drawable, font, pixelSize, textX2, 0, 0, 0, 0, -1000f, true); // renderString(drawable, font, pixelSize, text1, 0, 0, 0, -1000f, regionFPS); // no-cache + final String text1 = lfps+" / "+tfps+" fps, vsync "+gl.getSwapInterval()+", elapsed "+(t1-t0)/1000.0+ + " s, fontSize "+fontSizeFixed+", msaa "+drawable.getChosenGLCapabilities().getNumSamples()+ + ", "+modeS+"-samples "+vbaaSampleCount[0]; + renderString(drawable, font, pixelSize, text1, 0, 0, 0, 0, -1000, regionFPS); // no-cache } else { + final String text1 = String.format("%03.1f/%03.1f fps, vsync %d, elapsed %4.1f s, fontSize %2.2f, msaa %d, %s-samples %d", + lfps, tfps, gl.getSwapInterval(), (t1-t0)/1000.0, fontSizeFixed, + drawable.getChosenGLCapabilities().getNumSamples(), modeS, vbaaSampleCount[0]); renderString(drawable, font, pixelSize, getFontInfo(), 0, 0, 0, 0, -1000, true); renderString(drawable, font, pixelSize, "012345678901234567890123456789", 0, 0, 0, -1000, true); renderString(drawable, font, pixelSize, "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", 0, 0, 0, -1000, true); @@ -399,7 +403,7 @@ public class TestTextRendererNEWT00 extends UITestCase { renderString(drawable, font, pixelSize, textX2, 0, 0, 0, -1000, true); renderString(drawable, font, pixelSize, text1, 0, 0, 0, -1000, regionFPS); // no-cache if( TextAnim ) { - renderString(drawable, font, pixelSizeAnim, text1A, 0, 0, 0, -1000, regionFPSAnim); // no-cache + renderString(drawable, font, pixelSizeAnim, text1, 0, 0, 0, -1000, regionFPSAnim); // no-cache } } } }; diff --git a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java index 05e090886..207904f89 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java @@ -248,7 +248,7 @@ public abstract class TextRendererGLELBase implements GLEventListener { final int height = drawable.getHeight(); dy = height-ty; } - final int newLineCount = text.length() - text.replace("\n", "").length(); + final int newLineCount = TextRegionUtil.getCharCount(text, '\n'); final float lineHeight = font.getLineHeight(pixelSize); dx += pixelScale * font.getAdvanceWidth('X', pixelSize) * column; dy -= pixelScale * lineHeight * ( row + 1 ); @@ -270,9 +270,11 @@ public abstract class TextRendererGLELBase implements GLEventListener { if( cacheRegion ) { textRenderUtil.drawString3D(gl, renderer, font, pixelSize, text, null, vbaaSampleCount); } else if( null != region ) { - TextRegionUtil.drawString3D(gl, region, renderer, font, pixelSize, text, null, vbaaSampleCount); + TextRegionUtil.drawString3D(gl, region, renderer, font, pixelSize, text, null, vbaaSampleCount, + textRenderUtil.tempT1, textRenderUtil.tempT2); } else { - TextRegionUtil.drawString3D(gl, renderModes, renderer, font, pixelSize, text, null, vbaaSampleCount); + TextRegionUtil.drawString3D(gl, renderModes, renderer, font, pixelSize, text, null, vbaaSampleCount, + textRenderUtil.tempT1, textRenderUtil.tempT2); } renderer.enable(gl, false); diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java index 5dcfea4a9..8b653bdfa 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java @@ -247,7 +247,8 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB pmv.glTranslatef(nearPlaneX0, nearPlaneY0+(nearPlaneS * pixelSizeFPS / 2f), nearPlaneZ0); // No cache, keep region alive! - TextRegionUtil.drawString3D(gl, regionFPS, renderer, font, nearPlaneS * pixelSizeFPS, text, null, sampleCountFPS); + TextRegionUtil.drawString3D(gl, regionFPS, renderer, font, nearPlaneS * pixelSizeFPS, text, null, sampleCountFPS, + textRegionUtil.tempT1, textRegionUtil.tempT2); } float dx = width-fontNameBox.getWidth()-2f; @@ -292,13 +293,13 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB } if(!userInput) { if( bottomTextUseFrustum ) { - TextRegionUtil.drawString3D(gl, regionBottom, renderer, font, nearPlaneS * pixelSizeBottom, text2, null, getSampleCount()); + TextRegionUtil.drawString3D(gl, regionBottom, renderer, font, nearPlaneS * pixelSizeBottom, text2, null, getSampleCount(), null, null); } else { textRegionUtil.drawString3D(gl, renderer, font, nearPlaneS * pixelSizeBottom, text2, null, getSampleCount()); } } else { if( bottomTextUseFrustum ) { - TextRegionUtil.drawString3D(gl, regionBottom, renderer, font, nearPlaneS * pixelSizeBottom, userString.toString(), null, getSampleCount()); + TextRegionUtil.drawString3D(gl, regionBottom, renderer, font, nearPlaneS * pixelSizeBottom, userString.toString(), null, getSampleCount(), null, null); } else { textRegionUtil.drawString3D(gl, renderer, font, nearPlaneS * pixelSizeBottom, userString.toString(), null, getSampleCount()); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java index 6209bd975..4a14bb442 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java @@ -90,6 +90,8 @@ public class Label extends UIShape { } private final float[] tmpV3 = new float[3]; + private final AffineTransform tempT1 = new AffineTransform(); + private final AffineTransform tempT2 = new AffineTransform(); private final TextRegionUtil.ShapeVisitor shapeVisitor = new TextRegionUtil.ShapeVisitor() { @Override @@ -102,7 +104,7 @@ public class Label extends UIShape { @Override protected void addShapeToRegion(GL2ES2 gl, RegionRenderer renderer) { - TextRegionUtil.processString(shapeVisitor, null, font, pixelSize, text); + TextRegionUtil.processString(shapeVisitor, null, font, pixelSize, text, tempT1, tempT2); final float[] ctr = box.getCenter(); setRotationOrigin( ctr[0], ctr[1], ctr[2]); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java index dff9cd1c7..336ce7526 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java @@ -72,11 +72,13 @@ public class Label0 { public final AABBox getBounds() { return box; } private final float[] tmpV3 = new float[3]; + private final AffineTransform tempT1 = new AffineTransform(); + private final AffineTransform tempT2 = new AffineTransform(); private final TextRegionUtil.ShapeVisitor shapeVisitor = new TextRegionUtil.ShapeVisitor() { @Override public void visit(OutlineShape shape, AffineTransform t) { - final AffineTransform t1 = new AffineTransform(tLeft).concatenate( t ); + final AffineTransform t1 = t.preConcatenate(tLeft); region.addOutlineShape(shape, t1, rgbaColor); box.resize(shape.getBounds(), t1, tmpV3); } @@ -89,7 +91,7 @@ public class Label0 { box.reset(); this.region = region; this.tLeft = tLeft; - TextRegionUtil.processString(shapeVisitor, null, font, pixelSize, text); + TextRegionUtil.processString(shapeVisitor, null, font, pixelSize, text, tempT1, tempT2); this.region = null; this.tLeft = null; return box; diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java index e83097488..5315a8927 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RIButton.java @@ -37,7 +37,6 @@ import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.font.Font; import com.jogamp.graph.geom.Vertex; import com.jogamp.graph.geom.Vertex.Factory; -import com.jogamp.opengl.math.FloatUtil; import com.jogamp.opengl.math.geom.AABBox; /** @@ -58,6 +57,8 @@ public class RIButton extends UIShape { private float spacingX = DEFAULT_SPACING_X; private float spacingY = DEFAULT_SPACING_Y; private float corner = DEFAULT_CORNER; + private final AffineTransform tempT1 = new AffineTransform(); + private final AffineTransform tempT2 = new AffineTransform(); public RIButton(Factory<? extends Vertex> factory, int renderModes, Font labelFont, String labelText, float width, float height, float labelZOffset) { super(factory, renderModes | Region.COLORCHANNEL_RENDERING_BIT); @@ -129,13 +130,13 @@ public class RIButton extends UIShape { } // Setting pixelSize based on actual text-box size - final AABBox lbox1 = label.font.getPointsBounds(null, label.text, lPixelSize1); + final AABBox lbox1 = label.font.getPointsBounds(null, label.text, lPixelSize1, tempT1, tempT2); // Center text .. (share same center w/ button) final float[] lctr = lbox1.getCenter(); final float[] ctr = box.getCenter(); final float[] ltx = new float[] { ctr[0] - lctr[0], ctr[1] - lctr[1], 0f }; - final AABBox lbox2 = label.addShapeToRegion(lPixelSize1, region, AffineTransform.getTranslateInstance(ltx[0], ltx[1])); + final AABBox lbox2 = label.addShapeToRegion(lPixelSize1, region, tempT1.setToTranslation(ltx[0], ltx[1])); if( DRAW_DEBUG_BOX ) { System.err.printf("RIButton.0: lbox1 %s%n", lbox1); System.err.printf("RIButton.0: lbox2 %s%n", lbox2); |