From 93fede2562cab03478bbc1e0df1846a42103c563 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 19 Apr 2023 20:47:12 +0200 Subject: Graph: Region.countOutlineShape(..) -> static, allow usage w/o instance; TextRegionUtil.addStringToRegion() grow region buffer w/ counting (as well); GLRegion.create(..) count + reuse create(.., size) static-ctor All supported string -> region method utilize pre-calc of size and growth! Before, GraphUI's Label0 used TextRegionUtil.addStringToRegion() and hence missed this optimization path. --- src/jogl/classes/com/jogamp/graph/curve/Region.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/jogl/classes/com/jogamp/graph/curve/Region.java') diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java index 799b8b7bd..e897acba1 100644 --- a/src/jogl/classes/com/jogamp/graph/curve/Region.java +++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java @@ -477,14 +477,20 @@ public abstract class Region { /** * Count required number of vertices and indices adding to given int[2] `vertIndexCount` array. *

- * The region's buffer can be either set using {@link Region#setBufferCapacity(int, int)} or grown using {@link Region#growBuffer(int, int)}. + * The region's buffer can be either set using {@link Region#setBufferCapacity(int, int)}, + * {@link GLRegion#create(GLProfile, int, TextureSequence, int, int) GLRegion ctor w/ initial capacities} + * or grown using {@link Region#growBuffer(int, int)}. + *

+ *

+ * Method is utilized in {@link GLRegion#create(GLProfile, int, TextureSequence, com.jogamp.graph.font.Font, CharSequence) GLRegion ctor w/ font + text}, + * computing the initial capacity. *

* @param shape the {@link OutlineShape} to count * @param vertIndexCount the int[2] storage where the counted vertices and indices are added, vertices at [0] and indices at [1] * @see #setBufferCapacity(int, int) * @see #growBuffer(int, int) */ - public final void countOutlineShape(final OutlineShape shape, final int[/*2*/] vertIndexCount) { + public static final void countOutlineShape(final OutlineShape shape, final int[/*2*/] vertIndexCount) { final List trisIn = shape.getTriangles(OutlineShape.VerticesState.QUADRATIC_NURBS); final ArrayList vertsIn = shape.getVertices(); { @@ -498,14 +504,16 @@ public abstract class Region { /** * Count required number of vertices and indices adding to given int[2] `vertIndexCount` array. *

- * The region's buffer can be either set using {@link Region#setBufferCapacity(int, int)} or grown using {@link Region#growBuffer(int, int)}. + * The region's buffer can be either set using {@link Region#setBufferCapacity(int, int)}, + * {@link GLRegion#create(GLProfile, int, TextureSequence, int, int) GLRegion ctor w/ initial capacities} + * or grown using {@link Region#growBuffer(int, int)}. *

* @param shapes list of {@link OutlineShape} to count * @param vertIndexCount the int[2] storage where the counted vertices and indices are added, vertices at [0] and indices at [1] * @see #setBufferCapacity(int, int) * @see #growBuffer(int, int) */ - public final void countOutlineShapes(final List shapes, final int[/*2*/] vertIndexCount) { + public static final void countOutlineShapes(final List shapes, final int[/*2*/] vertIndexCount) { for (int i = 0; i < shapes.size(); i++) { countOutlineShape(shapes.get(i), vertIndexCount); } -- cgit v1.2.3