summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-03-07 05:25:07 +0100
committerSven Gothel <[email protected]>2023-03-07 05:25:07 +0100
commit8fbb5bb2f4312b52c24375db3055198a18d66319 (patch)
tree27272b27f4bb81004f5e4a969974e7653d296db7 /src/jogl/classes
parent14a47f60d2dc7c4f6b2d910fcc8489726443db22 (diff)
Graph: Bring back passing through temp AffineTransform instances (optional, but recommended)
Diffstat (limited to 'src/jogl/classes')
-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
3 files changed, 53 insertions, 21 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();