diff options
author | Sven Gothel <[email protected]> | 2014-02-28 12:16:09 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-02-28 12:16:09 +0100 |
commit | 8920cf318b99c4e30e35b37c963609fa12d5ce04 (patch) | |
tree | 76dc5947c546279d1c71649ddd9b5a5cd4fc4784 | |
parent | ea0059f01866bd6257d4a06164db1b6c906a2949 (diff) |
Bug 801: TextRegionUtil add 'special' for cache-key; Minor edits
Minor edits:
- Add some docs to curve-shader and remove FIXME remark about gcu_Alpha, which will be used < 1.0.
- Font: Add more TTF references
7 files changed, 22 insertions, 15 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java index e7ed335ec..7e8ed4023 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java +++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java @@ -125,11 +125,12 @@ public class TextRegionUtil { throw new GLException("TextRendererImpl01: not initialized!"); } final RenderState rs = renderer.getRenderState(); - GLRegion region = getCachedRegion(font, str, pixelSize); + final int special = 0; + GLRegion region = getCachedRegion(font, str, pixelSize, special); if(null == region) { region = GLRegion.create(renderer.getRenderModes()); addStringToRegion(region, rs.getVertexFactory(), font, str, pixelSize); - addCachedRegion(gl, font, str, pixelSize, region); + addCachedRegion(gl, font, str, pixelSize, special, region); } region.draw(gl, renderer, texSize); } @@ -212,13 +213,13 @@ public class TextRegionUtil { } } - protected final GLRegion getCachedRegion(Font font, CharSequence str, int fontSize) { - return stringCacheMap.get(getKey(font, str, fontSize)); + protected final GLRegion getCachedRegion(Font font, CharSequence str, int fontSize, int special) { + return stringCacheMap.get(getKey(font, str, fontSize, special)); } - protected final void addCachedRegion(GL2ES2 gl, Font font, CharSequence str, int fontSize, GLRegion glyphString) { + protected final void addCachedRegion(GL2ES2 gl, Font font, CharSequence str, int fontSize, int special, GLRegion glyphString) { if ( 0 != getCacheLimit() ) { - final String key = getKey(font, str, fontSize); + final String key = getKey(font, str, fontSize, special); final GLRegion oldRegion = stringCacheMap.put(key, glyphString); if ( null == oldRegion ) { // new entry .. @@ -228,8 +229,8 @@ public class TextRegionUtil { } } - protected final void removeCachedRegion(GL2ES2 gl, Font font, CharSequence str, int fontSize) { - final String key = getKey(font, str, fontSize); + protected final void removeCachedRegion(GL2ES2 gl, Font font, CharSequence str, int fontSize, int special) { + final String key = getKey(font, str, fontSize, special); GLRegion region = stringCacheMap.remove(key); if(null != region) { region.destroy(gl, renderer); @@ -247,10 +248,10 @@ public class TextRegionUtil { } } - protected final String getKey(Font font, CharSequence str, int fontSize) { + protected final String getKey(Font font, CharSequence str, int fontSize, int special) { final StringBuilder sb = new StringBuilder(); return font.getName(sb, Font.NAME_UNIQUNAME) - .append(".").append(str.hashCode()).append(".").append(fontSize).toString(); + .append(".").append(str.hashCode()).append(".").append(fontSize).append(special).toString(); } /** Default cache limit, see {@link #setCacheLimit(int)} */ diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java index 122015218..9758e4d41 100644 --- a/src/jogl/classes/com/jogamp/graph/font/Font.java +++ b/src/jogl/classes/com/jogamp/graph/font/Font.java @@ -35,6 +35,8 @@ import com.jogamp.opengl.math.geom.AABBox; * * TrueType Font Specification: * http://developer.apple.com/fonts/ttrefman/rm06/Chap6.html + * http://www.microsoft.com/typography/SpecificationsOverview.mspx + * http://www.microsoft.com/typography/otspec/ * * TrueType Font Table Introduction: * http://scripts.sil.org/cms/scripts/page.php?item_id=IWS-Chapter08 @@ -76,6 +78,7 @@ public interface Font { * * http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6cmap.html * http://developer.apple.com/textfonts/TTRefMan/RM06/Chap6glyf.html + * http://www.microsoft.com/typography/otspec/glyf.htm */ public interface Glyph { // reserved special glyph IDs diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp index 7643dab7b..2248792cb 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass-weight.fp @@ -45,7 +45,6 @@ void main (void) float gd = (aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0)*(aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0);
vec2 f = vec2((dtx.y - (w*dtx.x*(1.0 - 2.0*rtex.x))/gd), (dty.y - (w*dty.x*(1.0 - 2.0*rtex.x))/gd));
- // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha!
float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
alpha = gcu_Alpha * a;
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp index e12eef4b1..94e551832 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-1pass.fp @@ -16,6 +16,14 @@ void main (void) { + // CDTriangulator2D.extractBoundaryTriangles(..): + // 0 > gcv_TexCoord.y : hole or holeLike + // 0 < gcv_TexCoord.y : !hole (outer) + // + // 0 == gcv_TexCoord.x : vertex-0 of triangle + // 0.5 == gcv_TexCoord.x : vertex-1 of triangle + // 1 == gcv_TexCoord.x : vertex-2 of triangle + // vec2 rtex = vec2(abs(gcv_TexCoord.x),abs(gcv_TexCoord.y)); vec3 c = gcu_ColorStatic.rgb; @@ -39,7 +47,6 @@ void main (void) vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x)); float position = rtex.y - (rtex.x * (1.0 - rtex.x)); - // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); alpha = gcu_Alpha * a; } diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp index fb71abd14..e60556bc6 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass-weight.fp @@ -87,7 +87,6 @@ void main (void) float gd = (aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0)*(aph*rtex.x*rtex.x + 2.0*rtex.x + 1.0);
vec2 f = vec2((dtx.y - (w*dtx.x*(1.0 - 2.0*rtex.x))/gd), (dty.y - (w*dty.x*(1.0 - 2.0*rtex.x))/gd));
- // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha!
float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0);
alpha = gcu_Alpha * a;
}
diff --git a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp index 8e5600dd9..0cf4cf88f 100644 --- a/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp +++ b/src/jogl/classes/jogamp/graph/curve/opengl/shader/curverenderer01-2pass.fp @@ -81,7 +81,6 @@ void main (void) vec2 f = vec2((dtx.y - dtx.x + 2.0*rtex.x*dtx.x), (dty.y - dty.x + 2.0*rtex.x*dty.x)); float position = rtex.y - (rtex.x * (1.0 - rtex.x)); - // FIXME: will we ever set gcu_Alpha != 1.0 ? If not, a==alpha! float a = clamp(0.5 - ( position/length(f) ) * sign(gcv_TexCoord.y), 0.0, 1.0); alpha = gcu_Alpha * a; } 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 6b955b0db..42babcf35 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java @@ -34,7 +34,6 @@ import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLEventListener; import javax.media.opengl.fixedfunc.GLMatrixFunc; -import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RenderState; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.curve.opengl.TextRegionUtil; |