diff options
author | Sven Gothel <[email protected]> | 2023-04-20 04:39:30 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-04-20 04:39:30 +0200 |
commit | fad6cd0cc8033b6ef1ee16998cccd0d756030147 (patch) | |
tree | 68071302d5a9e257273c7407093ab1b26e12d9bf /src/graphui/classes | |
parent | 593b9c6360fd32fdca7d4e3da71525be15157726 (diff) |
GraphUI Button.createGLRegion(): Pre-calc Region buffer size for BaseButton (16) + Label-Text to avoid buffer grow
Diffstat (limited to 'src/graphui/classes')
-rw-r--r-- | src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java b/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java index c1be8064d..a19a58003 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java +++ b/src/graphui/classes/com/jogamp/graph/ui/shapes/Button.java @@ -28,9 +28,10 @@ package com.jogamp.graph.ui.shapes; import com.jogamp.opengl.GL2ES2; - +import com.jogamp.opengl.GLProfile; import com.jogamp.graph.curve.OutlineShape; import com.jogamp.graph.curve.Region; +import com.jogamp.graph.curve.opengl.GLRegion; import com.jogamp.graph.curve.opengl.RegionRenderer; import com.jogamp.graph.font.Font; import com.jogamp.graph.geom.plane.AffineTransform; @@ -96,6 +97,18 @@ public class Button extends BaseButton { } @Override + protected GLRegion createGLRegion(final GLProfile glp) { + final int[] vertIndexCount = { 0, 0 }; + final Font.GlyphVisitor2 visitor = new Font.GlyphVisitor2() { + @Override + public final void visit(final char symbol, final Font.Glyph glyph) { + Region.countOutlineShape(glyph.getShape(), vertIndexCount); + } }; + this.label.getFont().processString(visitor, this.label.getText()); + return GLRegion.create(glp, renderModes, null, 16+vertIndexCount[0], 16+vertIndexCount[1]); + } + + @Override protected void addShapeToRegion() { addBaseShapeToRegion( FloatUtil.isZero(labelZOffset) ? 0f : -labelZOffset ); |