aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java31
-rw-r--r--src/jogl/classes/com/jogamp/graph/font/Font.java30
-rw-r--r--src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java13
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/PerfTextRendererNEWT00.java11
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/GPUTextRendererListenerBase01.java16
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/UIShapeDemo01.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/UITypeDemo01.java8
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java5
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label0.java10
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java4
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RoundButton.java2
-rw-r--r--src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java6
13 files changed, 104 insertions, 48 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 547a07fba..0547d994a 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/opengl/TextRegionUtil.java
@@ -156,6 +156,15 @@ public class TextRegionUtil {
}
/**
+ * Try using {@link #drawString3D(GL2ES2, int, RegionRenderer, Font, CharSequence, float[], int[], AffineTransform, AffineTransform)} to reuse {@link AffineTransform} instances.
+ */
+ public static AABBox drawString3D(final GL2ES2 gl, final int renderModes,
+ final RegionRenderer renderer, final Font font, final CharSequence str,
+ final float[] rgbaColor, final int[/*1*/] sampleCount) {
+ return drawString3D(gl, renderModes, renderer, font, str, rgbaColor, sampleCount, new AffineTransform(), new AffineTransform());
+ }
+
+ /**
* Render the string in 3D space w.r.t. the font in font em-size [0..1] at the end of an internally temporary {@link GLRegion}.
* <p>
* The shapes added to the GLRegion are in font em-size [0..1].
@@ -166,7 +175,7 @@ public class TextRegionUtil {
* <p>
* In case of a multisampling region renderer, i.e. {@link Region#VBAA_RENDERING_BIT}, recreating the {@link GLRegion}
* is a huge performance impact.
- * In such case better use {@link #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, float[], int[])}
+ * In such case better use {@link #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, float[], int[], AffineTransform, AffineTransform)}
* instead.
* </p>
* @param gl the current GL state
@@ -176,23 +185,33 @@ public class TextRegionUtil {
* @param rgbaColor if {@link Region#hasColorChannel()} RGBA color must be passed, otherwise value is ignored.
* @param sampleCount desired multisampling sample count for msaa-rendering.
* The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
+ * @param tmp1 temp {@link AffineTransform} to be reused
+ * @param tmp2 temp {@link AffineTransform} to be reused
* @throws Exception if TextRenderer not initialized
* @return the bounding box of the given string from the produced and rendered GLRegion
*/
public static AABBox drawString3D(final GL2ES2 gl, final int renderModes,
final RegionRenderer renderer, final Font font, final CharSequence str,
- final float[] rgbaColor, final int[/*1*/] sampleCount) {
+ final float[] rgbaColor, final int[/*1*/] sampleCount, final AffineTransform tmp1, final AffineTransform tmp2) {
if(!renderer.isInitialized()){
throw new GLException("TextRendererImpl01: not initialized!");
}
final GLRegion region = GLRegion.create(gl.getGLProfile(), renderModes, null);
- final AABBox res = addStringToRegion(region, font, null, str, rgbaColor);
+ final AABBox res = addStringToRegion(region, font, null, str, rgbaColor, tmp1, tmp2);
region.draw(gl, renderer, sampleCount);
region.destroy(gl);
return res;
}
/**
+ * Try using {@link #drawString3D(GL2ES2, GLRegion, RegionRenderer, Font, CharSequence, float[], int[], AffineTransform, AffineTransform)} to reuse {@link AffineTransform} instances.
+ */
+ public static AABBox drawString3D(final GL2ES2 gl, final GLRegion region, final RegionRenderer renderer,
+ final Font font, final CharSequence str, final float[] rgbaColor, final int[/*1*/] sampleCount) {
+ return drawString3D(gl, region, renderer, font, str, rgbaColor, sampleCount, new AffineTransform(), new AffineTransform());
+ }
+
+ /**
* Render the string in 3D space w.r.t. the font in font em-size [0..1] at the end of the given {@link GLRegion}.
* <p>
* User might want to {@link GLRegion#clear(GL2ES2)} the region before calling this method.
@@ -211,16 +230,18 @@ public class TextRegionUtil {
* @param rgbaColor if {@link Region#hasColorChannel()} RGBA color must be passed, otherwise value is ignored.
* @param sampleCount desired multisampling sample count for msaa-rendering.
* The actual used scample-count is written back when msaa-rendering is enabled, otherwise the store is untouched.
+ * @param tmp1 temp {@link AffineTransform} to be reused
+ * @param tmp2 temp {@link AffineTransform} to be reused
* @return the bounding box of the given string from the produced and rendered GLRegion
* @throws Exception if TextRenderer not initialized
*/
public static AABBox drawString3D(final GL2ES2 gl, final GLRegion region, final RegionRenderer renderer,
final Font font, final CharSequence str, final float[] rgbaColor,
- final int[/*1*/] sampleCount) {
+ final int[/*1*/] sampleCount, final AffineTransform tmp1, final AffineTransform tmp2) {
if(!renderer.isInitialized()){
throw new GLException("TextRendererImpl01: not initialized!");
}
- final AABBox res = addStringToRegion(region, font, null, str, rgbaColor);
+ final AABBox res = addStringToRegion(region, font, null, str, rgbaColor, tmp1, tmp2);
region.draw(gl, renderer, sampleCount);
return res;
}
diff --git a/src/jogl/classes/com/jogamp/graph/font/Font.java b/src/jogl/classes/com/jogamp/graph/font/Font.java
index 907bbde8a..ebebbda06 100644
--- a/src/jogl/classes/com/jogamp/graph/font/Font.java
+++ b/src/jogl/classes/com/jogamp/graph/font/Font.java
@@ -329,17 +329,29 @@ public interface Font {
AABBox getMetricBounds(final CharSequence string);
/**
+ * Try using {@link #getGlyphBounds(CharSequence, AffineTransform, AffineTransform)} to reuse {@link AffineTransform} instances.
+ */
+ AABBox getGlyphBounds(final CharSequence string);
+
+ /**
* Returns accurate bounding box by taking each glyph's font em-sized bounding box into account.
* <p>
* Glyph bounds is based on each glyph's bounding box and `hhea' composed line height.
* </p>
* @param string string text
+ * @param tmp1 temp {@link AffineTransform} to be reused
+ * @param tmp2 temp {@link AffineTransform} to be reused
* @return the bounding box of the given string in font em-size [0..1]
* @see #getGlyphBoundsFU(CharSequence)
* @see #getGlyphShapeBounds(CharSequence)
* @see #getMetricBounds(CharSequence)
*/
- AABBox getGlyphBounds(final CharSequence string);
+ AABBox getGlyphBounds(final CharSequence string, final AffineTransform tmp1, final AffineTransform tmp2);
+
+ /**
+ * Try using {@link #getGlyphBoundsFU(CharSequence, AffineTransform, AffineTransform)} to reuse {@link AffineTransform} instances.
+ */
+ AABBox getGlyphBoundsFU(final CharSequence string);
/**
* Returns accurate bounding box by taking each glyph's font-units sized bounding box into account.
@@ -347,10 +359,12 @@ public interface Font {
* Glyph bounds is based on each glyph's bounding box and `hhea' composed line height.
* </p>
* @param string string text
+ * @param tmp1 temp {@link AffineTransform} to be reused
+ * @param tmp2 temp {@link AffineTransform} to be reused
* @return the bounding box of the given string in font-units [0..1]
* @see #getGlyphBounds(CharSequence)
*/
- AABBox getGlyphBoundsFU(final CharSequence string);
+ AABBox getGlyphBoundsFU(final CharSequence string, final AffineTransform tmp1, final AffineTransform tmp2);
/**
* Returns accurate bounding box by taking each glyph's font em-sized {@link OutlineShape} into account.
@@ -388,16 +402,8 @@ public interface Font {
boolean isPrintableChar(final char c);
/**
- * Visit each {@link Glyph}'s {@link OutlineShape} of the string with the {@link OutlineShape.Visitor}
- * while passing the progressed {@link AffineTransform}.
- * <p>
- * The produced shapes are in font em-size [0..1], but can be adjusted with the given transform, progressed and passed to the visitor.
- * </p>
- * @param visitor handling each glyph's outline shape in font em-size [0..1] and the given {@link AffineTransform}
- * @param transform optional given transform
- * @param font the target {@link Font}
- * @param string string text
- * @return the bounding box of the given string by taking each glyph's font em-sized [0..1] {@link OutlineShape} into account.
+ * Try using {@link #processString(com.jogamp.graph.curve.OutlineShape.Visitor, AffineTransform, CharSequence, AffineTransform, AffineTransform)}
+ * to reuse {@link AffineTransform} instances.
*/
AABBox processString(final OutlineShape.Visitor visitor, final AffineTransform transform,
final CharSequence string);
diff --git a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
index aba7d6807..d2137ae36 100644
--- a/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
+++ b/src/jogl/classes/jogamp/graph/font/typecast/TypecastFont.java
@@ -291,17 +291,22 @@ class TypecastFont implements Font {
@Override
public AABBox getGlyphBounds(final CharSequence string) {
- return getGlyphBoundsFU(string).scale2(1.0f/metrics.getUnitsPerEM(), new float[3]);
+ return getGlyphBounds(string, new AffineTransform(), new AffineTransform());
+ }
+ @Override
+ public AABBox getGlyphBounds(final CharSequence string, final AffineTransform tmp1, final AffineTransform tmp2) {
+ return getGlyphBoundsFU(string, tmp1, tmp2).scale2(1.0f/metrics.getUnitsPerEM(), new float[3]);
}
@Override
public AABBox getGlyphBoundsFU(final CharSequence string) {
+ return getGlyphBoundsFU(string, new AffineTransform(), new AffineTransform());
+ }
+ @Override
+ public AABBox getGlyphBoundsFU(final CharSequence string, final AffineTransform temp1, final AffineTransform temp2) {
if (null == string || 0 == string.length() ) {
return new AABBox();
}
- final AffineTransform temp1 = new AffineTransform();
- final AffineTransform temp2 = new AffineTransform();
-
final AABBox res = new AABBox();
final int charCount = string.length();
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/PerfTextRendererNEWT00.java b/src/test/com/jogamp/opengl/test/junit/graph/PerfTextRendererNEWT00.java
index f8fd06695..44b1f087d 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/PerfTextRendererNEWT00.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/PerfTextRendererNEWT00.java
@@ -259,6 +259,10 @@ public class PerfTextRendererNEWT00 {
font.perfCounter().enable(true);
}
+ final AffineTransform translation = new AffineTransform();
+ final AffineTransform tmp1 = new AffineTransform();
+ final AffineTransform tmp2 = new AffineTransform();
+
for(int loop_i=0; loop_i < loop_count; ++loop_i) {
final long t2 = Clock.currentNanos(); // all initialized but graph
if( null != perf ) {
@@ -292,11 +296,10 @@ public class PerfTextRendererNEWT00 {
{
// all sizes in em
final float x_width = font.getAdvanceWidth( font.getGlyphID('X') );
- final AffineTransform t = new AffineTransform();
- t.setToTranslation(3*x_width, 0f);
- final AABBox tbox_1 = font.getGlyphBounds(text);
- final AABBox rbox_1 = TextRegionUtil.addStringToRegion(region, font, t, text, fg_color);
+ translation.setToTranslation(3*x_width, 0f);
+ final AABBox tbox_1 = font.getGlyphBounds(text, tmp1, tmp2);
+ final AABBox rbox_1 = TextRegionUtil.addStringToRegion(region, font, translation, text, fg_color, tmp1, tmp2);
t4 = Clock.currentNanos(); // text added to region
if( 0 == loop_i && !do_perf ) {
System.err.println("Text_1: tbox "+tbox_1);
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 f307a1196..21aee7c40 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/TextRendererGLELBase.java
@@ -43,6 +43,7 @@ import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.font.FontScale;
import com.jogamp.graph.font.FontSet;
import com.jogamp.graph.geom.SVertex;
+import com.jogamp.graph.geom.plane.AffineTransform;
import com.jogamp.newt.Window;
import com.jogamp.opengl.util.PMVMatrix;
@@ -59,6 +60,9 @@ public abstract class TextRendererGLELBase implements GLEventListener {
protected RegionRenderer renderer = null;
protected TextRegionUtil textRenderUtil = null;
+ protected final AffineTransform tempT1 = new AffineTransform();
+ protected final AffineTransform tempT2 = new AffineTransform();
+
/** scale pixel, default is 1f */
protected float pixelScale = 1.0f;
@@ -272,9 +276,9 @@ public abstract class TextRendererGLELBase implements GLEventListener {
if( cacheRegion ) {
textRenderUtil.drawString3D(gl, renderer, font, text, null, vbaaSampleCount);
} else if( null != region ) {
- TextRegionUtil.drawString3D(gl, region, renderer, font, text, null, vbaaSampleCount);
+ TextRegionUtil.drawString3D(gl, region, renderer, font, text, null, vbaaSampleCount, tempT1, tempT1);
} else {
- TextRegionUtil.drawString3D(gl, renderModes, renderer, font, text, null, vbaaSampleCount);
+ TextRegionUtil.drawString3D(gl, renderModes, renderer, font, text, null, vbaaSampleCount, tempT1, tempT1);
}
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 8fa3744fd..ec179ffdc 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
@@ -46,6 +46,7 @@ import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.font.FontScale;
import com.jogamp.graph.font.FontSet;
+import com.jogamp.graph.geom.plane.AffineTransform;
import com.jogamp.newt.Window;
import com.jogamp.newt.event.KeyEvent;
import com.jogamp.newt.event.KeyListener;
@@ -90,6 +91,9 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
String headtext;
AABBox headbox;
+ protected final AffineTransform tempT1 = new AffineTransform();
+ protected final AffineTransform tempT2 = new AffineTransform();
+
static final String text2 = "The quick brown fox jumps over the lazy dog";
public static final String text_help =
"JOGAMP graph demo using Resolution Independent NURBS\n"+
@@ -234,15 +238,15 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
} else {
System.err.println("Using vertical default DPI of "+dpiV+", "+ppmmV+" pixel/mm");
}
- fontNameBox = font.getGlyphBounds(fontName);
+ fontNameBox = font.getGlyphBounds(fontName, tempT1, tempT2);
setHeadBox(headType, true);
{
final float pixelSizeFName = FontScale.toPixels(fontSizeFName, dpiV);
System.err.println("XXX: fontName size "+fontSizeFName+"pt, dpiV "+dpiV+" -> "+pixelSizeFName+"px");
System.err.println("XXX: fontName boxM fu "+font.getMetricBoundsFU(fontName));
- System.err.println("XXX: fontName boxG fu "+font.getGlyphBoundsFU(fontName));
+ System.err.println("XXX: fontName boxG fu "+font.getGlyphBoundsFU(fontName, tempT1, tempT2));
System.err.println("XXX: fontName boxM em "+font.getMetricBounds(fontName));
- System.err.println("XXX: fontName boxG em "+font.getGlyphBounds(fontName));
+ System.err.println("XXX: fontName boxG em "+font.getGlyphBounds(fontName, tempT1, tempT2));
System.err.println("XXX: fontName box height px "+(fontNameBox.getHeight() * pixelSizeFName));
}
}
@@ -339,7 +343,7 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
pmv.glScalef(sxy, sxy, 1.0f);
}
// No cache, keep region alive!
- TextRegionUtil.drawString3D(gl, regionFPS.clear(gl), renderer, font, text, null, sampleCountFPS);
+ TextRegionUtil.drawString3D(gl, regionFPS.clear(gl), renderer, font, text, null, sampleCountFPS, tempT1, tempT2);
pmv.glPopMatrix();
}
@@ -393,13 +397,13 @@ public abstract class GPUTextRendererListenerBase01 extends GPURendererListenerB
}
if(!userInput) {
if( bottomTextUseFrustum ) {
- TextRegionUtil.drawString3D(gl, regionBottom.clear(gl), renderer, font, text2, null, getSampleCount());
+ TextRegionUtil.drawString3D(gl, regionBottom.clear(gl), renderer, font, text2, null, getSampleCount(), tempT1, tempT2);
} else {
textRegionUtil.drawString3D(gl, renderer, font, text2, null, getSampleCount());
}
} else {
if( bottomTextUseFrustum ) {
- TextRegionUtil.drawString3D(gl, regionBottom.clear(gl), renderer, font, userString.toString(), null, getSampleCount());
+ TextRegionUtil.drawString3D(gl, regionBottom.clear(gl), renderer, font, userString.toString(), null, getSampleCount(), tempT1, tempT2);
} else {
textRegionUtil.drawString3D(gl, renderer, font, userString.toString(), null, getSampleCount());
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/UIShapeDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/UIShapeDemo01.java
index d09f00000..63c147cdd 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/UIShapeDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/UIShapeDemo01.java
@@ -56,6 +56,7 @@ import com.jogamp.graph.font.Font;
import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.font.FontSet;
import com.jogamp.graph.geom.SVertex;
+import com.jogamp.graph.geom.plane.AffineTransform;
import com.jogamp.newt.Window;
import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
@@ -167,6 +168,9 @@ public class UIShapeDemo01 implements GLEventListener {
boolean ignoreInput = false;
+ protected final AffineTransform tempT1 = new AffineTransform();
+ protected final AffineTransform tempT2 = new AffineTransform();
+
public UIShapeDemo01(final Font font, final int renderModes, final RenderState rs, final boolean debug, final boolean trace) {
this.font = font;
this.renderModes = renderModes;
@@ -275,13 +279,13 @@ public class UIShapeDemo01 implements GLEventListener {
}
full_width_o = objCoord1[0] - objCoord0[0];
}
- final AABBox txt_box_em = font.getGlyphBounds(text);
+ final AABBox txt_box_em = font.getGlyphBounds(text, tempT1, tempT2);
final float full_width_s = full_width_o / txt_box_em.getWidth();
final float txt_scale = full_width_s/2f;
pmv.glPushMatrix();
pmv.glScalef(txt_scale, txt_scale, 1f);
pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f);
- final AABBox txt_box_r = TextRegionUtil.drawString3D(gl, renderModes, renderer, font, text, new float[] { 0, 0, 0, 1 }, sampleCount);
+ final AABBox txt_box_r = TextRegionUtil.drawString3D(gl, renderModes, renderer, font, text, new float[] { 0, 0, 0, 1 }, sampleCount, tempT1, tempT2);
if( once ) {
final AABBox txt_box_em2 = font.getGlyphShapeBounds(null, text);
System.err.println("XXX: full_width: "+full_width_o+" / "+txt_box_em.getWidth()+" -> "+full_width_s);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/UITypeDemo01.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/UITypeDemo01.java
index 5c638f953..44e014bd8 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/UITypeDemo01.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/UITypeDemo01.java
@@ -62,6 +62,7 @@ import com.jogamp.graph.font.FontFactory;
import com.jogamp.graph.font.FontSet;
import com.jogamp.graph.font.Font.Glyph;
import com.jogamp.graph.geom.SVertex;
+import com.jogamp.graph.geom.plane.AffineTransform;
import com.jogamp.newt.Window;
import com.jogamp.newt.event.KeyAdapter;
import com.jogamp.newt.event.KeyEvent;
@@ -185,6 +186,9 @@ public class UITypeDemo01 implements GLEventListener {
boolean ignoreInput = false;
+ protected final AffineTransform tempT1 = new AffineTransform();
+ protected final AffineTransform tempT2 = new AffineTransform();
+
@SuppressWarnings("unused")
public UITypeDemo01(final Font font, final int glyph_id, final String text, final int renderModes, final RenderState rs, final boolean debug, final boolean trace) {
this.font = font;
@@ -341,13 +345,13 @@ public class UITypeDemo01 implements GLEventListener {
System.err.println("XXX: txt_box_e2 "+txt_box_em2);
}
} else if( Glyph.ID_UNKNOWN == glyph_id ) {
- final AABBox txt_box_em = font.getGlyphBounds(text);
+ final AABBox txt_box_em = font.getGlyphBounds(text, tempT1, tempT2);
final float full_width_s = full_width_o / txt_box_em.getWidth();
final float full_height_s = full_height_o / txt_box_em.getHeight();
final float txt_scale = full_width_s < full_height_s ? full_width_s/2f : full_height_s/2f;
pmv.glScalef(txt_scale, txt_scale, 1f);
pmv.glTranslatef(-txt_box_em.getWidth(), 0f, 0f);
- final AABBox txt_box_r = TextRegionUtil.drawString3D(gl, renderModes, renderer, font, text, fg_color, sampleCount);
+ final AABBox txt_box_r = TextRegionUtil.drawString3D(gl, renderModes, renderer, font, text, fg_color, sampleCount, tempT1, tempT2);
if( once ) {
final AABBox txt_box_em2 = font.getGlyphShapeBounds(null, text);
System.err.println("XXX: full_width: "+full_width_o+" / "+txt_box_em.getWidth()+" -> "+full_width_s);
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 d85475451..c4c450763 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
@@ -97,9 +97,8 @@ public class Label extends UIShape {
@Override
protected void addShapeToRegion(final GL2ES2 gl, final RegionRenderer renderer) {
- final AffineTransform t_sxy = new AffineTransform();
- t_sxy.setToScale(pixelSize, pixelSize);
- final AABBox fbox = font.processString(shapeVisitor, t_sxy, text);
+ tempT1.setToScale(pixelSize, pixelSize);
+ final AABBox fbox = font.processString(shapeVisitor, tempT1, text, tempT2, tempT3);
final float[] ctr = box.getCenter();
setRotationOrigin( ctr[0], ctr[1], ctr[2]);
box.resize(fbox);
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 5cf0f9af5..7d8f34261 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
@@ -65,10 +65,12 @@ public class Label0 {
this.font = font;
}
- public final AABBox addShapeToRegion(final float scale, final Region region, final AffineTransform tLeft) {
- final AffineTransform t_sxy = new AffineTransform(tLeft);
- t_sxy.scale(scale, scale, new AffineTransform());
- return TextRegionUtil.addStringToRegion(region, font, t_sxy, text, rgbaColor);
+ public final AABBox addShapeToRegion(final float scale, final Region region, final AffineTransform tLeft,
+ final AffineTransform tmp1, final AffineTransform tmp2, final AffineTransform tmp3)
+ {
+ tmp1.setTransform(tLeft);
+ tmp1.scale(scale, scale, tmp2);
+ return TextRegionUtil.addStringToRegion(region, font, tmp1, text, rgbaColor, tmp2, tmp3);
}
@Override
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java
index 4ea341fba..6a3637e4a 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java
@@ -95,7 +95,7 @@ public class LabelButton extends RoundButton {
// Precompute text-box size .. guessing pixelSize
final float lw = width * ( 1f - spacingX ) ;
final float lh = height * ( 1f - spacingY ) ;
- final AABBox lbox0_em = label.font.getGlyphBounds(label.text);
+ final AABBox lbox0_em = label.font.getGlyphBounds(label.text, tempT1, tempT2);
final float lsx = lw / lbox0_em.getWidth();
final float lsy = lh / lbox0_em.getHeight();
final float lScale = lsx < lsy ? lsx : lsy;
@@ -117,7 +117,7 @@ public class LabelButton extends RoundButton {
System.err.printf ("RIButton: tleft %f / %f, %f / %f%n", ltx[0], ltx[1], ltx[0] * lScale, ltx[1] * lScale);
}
- final AABBox lbox2 = label.addShapeToRegion(lScale, region, tempT1.setToTranslation(ltx[0], ltx[1]));
+ final AABBox lbox2 = label.addShapeToRegion(lScale, region, tempT1.setToTranslation(ltx[0], ltx[1]), tempT2, tempT3, tempT4);
if( DRAW_DEBUG_BOX ) {
System.err.printf("RIButton.X: lbox2 %s%n", lbox2);
}
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RoundButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RoundButton.java
index 7e096f46c..1f238763d 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RoundButton.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/RoundButton.java
@@ -41,8 +41,6 @@ public abstract class RoundButton extends UIShape {
protected float width;
protected float height;
protected float corner = DEFAULT_CORNER;
- protected final AffineTransform tempT1 = new AffineTransform();
- protected final AffineTransform tempT2 = new AffineTransform();
protected RoundButton(final Factory<? extends Vertex> factory, final int renderModes, final float width, final float height) {
super(factory, renderModes);
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java
index 22eeec50f..62e6e0753 100644
--- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java
+++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/UIShape.java
@@ -39,6 +39,7 @@ import com.jogamp.graph.curve.opengl.GLRegion;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.geom.Vertex;
import com.jogamp.graph.geom.Vertex.Factory;
+import com.jogamp.graph.geom.plane.AffineTransform;
import com.jogamp.newt.event.GestureHandler.GestureEvent;
import com.jogamp.newt.event.GestureHandler.GestureListener;
import com.jogamp.newt.event.MouseAdapter;
@@ -61,6 +62,11 @@ public abstract class UIShape {
private final int renderModes;
protected final AABBox box;
+ protected final AffineTransform tempT1 = new AffineTransform();
+ protected final AffineTransform tempT2 = new AffineTransform();
+ protected final AffineTransform tempT3 = new AffineTransform();
+ protected final AffineTransform tempT4 = new AffineTransform();
+
protected final float[] translate = new float[] { 0f, 0f, 0f };
protected final Quaternion rotation = new Quaternion();
protected final float[] rotOrigin = new float[] { 0f, 0f, 0f };