From 8fbb5bb2f4312b52c24375db3055198a18d66319 Mon Sep 17 00:00:00 2001
From: Sven Gothel
@@ -166,7 +175,7 @@ public class TextRegionUtil {
*
* 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.
*
@@ -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
@@ -328,18 +328,30 @@ 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.
*
* Glyph bounds is based on each glyph's bounding box and `hhea' composed line height.
*
- * The produced shapes are in font em-size [0..1], but can be adjusted with the given transform, progressed and passed to the visitor. - *
- * @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(); -- cgit v1.2.3