From d84812b6fb398c73cb3f339ab13d74b7e6822181 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 25 Feb 2014 23:10:06 +0100 Subject: Bug 802: Graph TextRenderer Performance Part-2 (fix artifacts, cleanup, incomplete) - OutlineShape - Add DIRTY_VERTICES bit in triangulation, which in turn solves the rendering artifact issue. - transformOutlines(..) -> protected - Note: Always pick triangles first, then vertices. The former renders vertices dirty. - Region - Make triangles / vertices accessible - Add 'validateIndices()' to add indices for triangles, code moved from the GLRegion* impl. Shall be refined later! - GLRegion - Passing 'RegionRenderer' instead of RenderState .. reducing argument numbers and aligning all related 'render' methods while giving association to the RegionRenderer. - Renderer -> RegionRenderer, dropping 'intermediate' RegionRenderer - Dropping draw() in RegionRenderer, should be issued simply by GLRegion in a unique fashion. - Dropping RegionFactory Too simple code as-is, simply invoke in Region.create(..) - Overall: - Add 'final' qualifier - Remove overloaded methods where rither default args can be used or a followup method call completes the 'intention'. --- .../jogamp/graph/curve/opengl/TextRenderUtil.java | 35 ++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) (limited to 'src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderUtil.java') diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderUtil.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderUtil.java index cef589f4f..6ac3d926f 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderUtil.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRenderUtil.java @@ -35,7 +35,6 @@ import java.util.List; import javax.media.opengl.GL2ES2; import javax.media.opengl.GLException; -import jogamp.graph.curve.opengl.RegionFactory; import jogamp.graph.geom.plane.AffineTransform; import com.jogamp.graph.curve.OutlineShape; @@ -53,9 +52,9 @@ import com.jogamp.graph.geom.Vertex.Factory; */ public class TextRenderUtil { - public final Renderer renderer; + public final RegionRenderer renderer; - public TextRenderUtil(final Renderer renderer) { + public TextRenderUtil(final RegionRenderer renderer) { this.renderer = renderer; } @@ -75,7 +74,7 @@ public class TextRenderUtil { final Font font, final CharSequence str, final int pixelSize) { final int charCount = str.length(); - final GLRegion region = RegionFactory.create(renderModes); + final GLRegion region = Region.create(renderModes); // region.setFlipped(true); final Font.Metrics metrics = font.getMetrics(); @@ -108,7 +107,7 @@ public class TextRenderUtil { final Font.Glyph glyph = font.getGlyph(character); final OutlineShape glyphShape = glyph.getShape(); - if( null == glyphShape || glyphShape.getVertices().size() < 3 ) { + if( null == glyphShape ) { continue; } // glyphShape.closeLastOutline(); @@ -116,10 +115,16 @@ public class TextRenderUtil { if( false ) { region.addOutlineShape(glyphShape, t); } else { - final ArrayList trisIn = glyphShape.getTriangles(); + // System.err.println("XXXXX Pre TRI"); + // glyphShape.getVertices(); + final ArrayList trisIn = glyphShape.getTriangles(OutlineShape.VerticesState.QUADRATIC_NURBS); + final ArrayList gVertices = glyphShape.getVertices(); + + if( gVertices.size() < 3 ) { + continue; + } region.addTriangles(trisIn, t, numVertices); - final ArrayList gVertices = glyphShape.getVertices(); for(int j=0; j gtris = shape.getTriangles(); + ArrayList gtris = shape.getTriangles(OutlineShape.VerticesState.QUADRATIC_NURBS); region.addTriangles(gtris, null, 0); final ArrayList gVertices = shape.getVertices(); @@ -198,7 +203,7 @@ public class TextRenderUtil { region = createRegion(renderer.getRenderModes(), rs.getVertexFactory(), font, str, pixelSize); addCachedRegion(gl, font, str, pixelSize, region); } - region.draw(gl, rs, renderer.getWidth(), renderer.getHeight(), texSize); + region.draw(gl, renderer, texSize); } /** @@ -212,14 +217,14 @@ public class TextRenderUtil { * The actual used texture-width is written back when mp rendering is enabled, otherwise the store is untouched. * @throws Exception if TextRenderer not initialized */ - public static void drawString3D(final Renderer renderer, final GL2ES2 gl, + public static void drawString3D(final RegionRenderer renderer, final GL2ES2 gl, final Font font, final CharSequence str, final int fontSize, final int[/*1*/] texSize) { if(!renderer.isInitialized()){ throw new GLException("TextRendererImpl01: not initialized!"); } final RenderState rs = renderer.getRenderState(); GLRegion region = createRegion(renderer.getRenderModes(), rs.getVertexFactory(), font, str, fontSize); - region.draw(gl, rs, renderer.getWidth(), renderer.getHeight(), texSize); + region.draw(gl, renderer, texSize); } /** FIXME @@ -238,7 +243,7 @@ public class TextRenderUtil { final Iterator iterator = stringCacheMap.values().iterator(); while(iterator.hasNext()){ final GLRegion region = iterator.next(); - region.destroy(gl, renderer.getRenderState()); + region.destroy(gl, renderer); } stringCacheMap.clear(); stringCacheArray.clear(); @@ -304,7 +309,7 @@ public class TextRenderUtil { final String key = getKey(font, str, fontSize); GLRegion region = stringCacheMap.remove(key); if(null != region) { - region.destroy(gl, renderer.getRenderState()); + region.destroy(gl, renderer); } stringCacheArray.remove(key); } @@ -313,7 +318,7 @@ public class TextRenderUtil { final String key = stringCacheArray.remove(idx); final GLRegion region = stringCacheMap.remove(key); if(null != region) { - region.destroy(gl, renderer.getRenderState()); + region.destroy(gl, renderer); } } -- cgit v1.2.3