aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/graph/curve/Region.java
diff options
context:
space:
mode:
authorSven Gothel <sgothel@jausoft.com>2023-03-07 19:05:05 +0100
committerSven Gothel <sgothel@jausoft.com>2023-03-07 19:05:05 +0100
commit3bad09f6b7c7f9c93a6cf385abb51a6563e8aec0 (patch)
tree456cf2320e4d8b6970bc401f25d68efa28ad2ae6 /src/jogl/classes/com/jogamp/graph/curve/Region.java
parent5e79fea8981a13d155e0b958aa3e20a546c533bb (diff)
Graph Perf: Add Region.countOutlineShape(), Font.processString(Visitor2,..), TextRegionUtil.countStringRegion() allowing to use Region.setBufferCapacity()
Diffstat (limited to 'src/jogl/classes/com/jogamp/graph/curve/Region.java')
-rw-r--r--src/jogl/classes/com/jogamp/graph/curve/Region.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/jogl/classes/com/jogamp/graph/curve/Region.java b/src/jogl/classes/com/jogamp/graph/curve/Region.java
index 5147008a1..22e63a3f7 100644
--- a/src/jogl/classes/com/jogamp/graph/curve/Region.java
+++ b/src/jogl/classes/com/jogamp/graph/curve/Region.java
@@ -441,6 +441,43 @@ public abstract class Region {
public PerfCounterCtrl perfCounter() { return perfCounterCtrl; }
/**
+ * Count required number of vertices and indices adding to given int[2] `vertIndexCount` array.
+ * <p>
+ * The region's buffer can be either set using {@link Region#setBufferCapacity(int, int)} or grown using {@link Region#growBuffer(int, int)}.
+ * </p>
+ * @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) {
+ final List<Triangle> trisIn = shape.getTriangles(OutlineShape.VerticesState.QUADRATIC_NURBS);
+ final ArrayList<Vertex> vertsIn = shape.getVertices();
+ {
+ final int verticeCount = vertsIn.size() + shape.getAddedVerticeCount();
+ final int indexCount = trisIn.size() * 3;
+ vertIndexCount[0] += verticeCount;
+ vertIndexCount[1] += Math.min( Math.ceil(verticeCount * 0.6), indexCount );
+ }
+ }
+
+ /**
+ * Count required number of vertices and indices adding to given int[2] `vertIndexCount` array.
+ * <p>
+ * The region's buffer can be either set using {@link Region#setBufferCapacity(int, int)} or grown using {@link Region#growBuffer(int, int)}.
+ * </p>
+ * @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<OutlineShape> shapes, final int[/*2*/] vertIndexCount) {
+ for (int i = 0; i < shapes.size(); i++) {
+ countOutlineShape(shapes.get(i), vertIndexCount);
+ }
+ }
+
+ /**
* Add the given {@link OutlineShape} to this region with the given optional {@link AffineTransform}.
* <p>
* In case {@link #setFrustum(Frustum) frustum culling is set}, the {@link OutlineShape}