aboutsummaryrefslogtreecommitdiffstats
path: root/src/graphui/classes/com/jogamp
diff options
context:
space:
mode:
authorSven Göthel <[email protected]>2024-01-14 04:19:10 +0100
committerSven Göthel <[email protected]>2024-01-14 04:19:10 +0100
commit6363ae5fb6975a6f2e7c1093ce81f25b699e3e61 (patch)
treee19fb3347ea0562972c87b6b6fbbf771933646ae /src/graphui/classes/com/jogamp
parent3062f72c7b83cef71d8e6d471846449aba66d861 (diff)
Graph/GraphUI: Revise Graph Region ShaderMapping, fix AABBox-Clipping for Pass2-AA, revise Pass2 AA Quality parameter ..
Misc: - Graph VBORegion2PVBAAES2: Drop unused FBO rescale - Move MIN/MAX QUALITY/SAMPLE from GraphUI Scene -> Graph Region +++ Quality -> Pass2 AA Quality - Drop quality field in region - Pass quality to GLRegion.draw(..) similar to sampleCount for dynamic shader and switch - TODO: Pass quality parameter in TextRegionUtil's functions Fix RegionRenderer Shader Mapping - Use ShaderKey class to properly implement the hash value and equals method - For this, TextureSequence.getTextureFragmentShaderHashID() has been added to provide actual shader-snippet for the equals function - All required criterias are included in the hash value and equals method Fix AABBox Clipping for Pass-2 AA - Clipping in pass2-AA must happen in pass2 on actual gcu_PMVMatrix01 (not ortho) +++ GraphUI GraphShape - Rename: [get,set]{->AA}Quality() GraphUI Scene - Rename: mark{All->}ShapesDirty(), set{AllShapes->}Sharpness(), set{AllShapes->AA}Quality() - Fix setSampleCount(..), i.e. markStatesDirty() not markShapesDirty() - Fix setAAQuality(), markShapesDirty() and markStatesDirty(): Use forAll(..) to traverse through all shapes and groups. GraphUI Group - Add setFixedSize() - Add setClipOnBox() - Document setRelayoutOnDirtyShapes(), isShapeDirty()
Diffstat (limited to 'src/graphui/classes/com/jogamp')
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/GraphShape.java23
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Group.java75
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Scene.java65
-rw-r--r--src/graphui/classes/com/jogamp/graph/ui/Shape.java2
4 files changed, 109 insertions, 56 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java b/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java
index 869d63ec7..27e231aa5 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java
@@ -58,7 +58,7 @@ public abstract class GraphShape extends Shape {
protected int pass2TexUnit = GLRegion.DEFAULT_TWO_PASS_TEXTURE_UNIT;
protected GLRegion region = null;
protected float oshapeSharpness = OutlineShape.DEFAULT_SHARPNESS;
- private int regionQuality = Region.MAX_QUALITY;
+ private int regionPass2Quality = Region.MAX_AA_QUALITY;
private final List<GLRegion> dirtyRegions = new ArrayList<GLRegion>();
/**
@@ -87,15 +87,13 @@ public abstract class GraphShape extends Shape {
public final int getRenderModes() { return renderModes; }
/**
- * Sets the shape's Graph {@link Region}'s quality parameter. Default is {@link Region#MAX_QUALITY}.
- * @param q Graph {@link Region}'s quality parameter, default is {@link Region#MAX_QUALITY}.
+ * Sets the shape's Graph {@link Region}'s pass2 AA-quality parameter. Default is {@link Region#MAX_AA_QUALITY}.
+ * @param q Graph {@link Region}'s pass2 AA-quality parameter, default is {@link Region#MAX_AA_QUALITY}.
* @return this shape for chaining.
*/
- public final GraphShape setQuality(final int q) {
- this.regionQuality = q;
- if( null != region ) {
- region.setQuality(q);
- }
+ public final GraphShape setAAQuality(final int q) {
+ this.regionPass2Quality = q;
+ markStateDirty();
return this;
}
@@ -109,9 +107,9 @@ public abstract class GraphShape extends Shape {
/**
* Return the shape's Graph {@link Region}'s quality parameter.
- * @see #setQuality(int)
+ * @see #setAAQuality(int)
*/
- public final int getQuality() { return regionQuality; }
+ public final int getAAQuality() { return regionPass2Quality; }
/**
* Sets the shape's Graph {@link OutlineShape}'s sharpness parameter. Default is {@link OutlineShape#DEFAULT_SHARPNESS}.
@@ -168,12 +166,12 @@ public abstract class GraphShape extends Shape {
@Override
protected final void drawImpl0(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount, final Vec4f rgba) {
renderer.setColorStatic(rgba);
- region.draw(gl, renderer, sampleCount);
+ region.draw(gl, renderer, regionPass2Quality, sampleCount);
}
@Override
protected final void drawToSelectImpl0(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) {
- region.draw(gl, renderer, sampleCount);
+ region.draw(gl, renderer, 0, sampleCount);
}
/**
@@ -252,7 +250,6 @@ public abstract class GraphShape extends Shape {
box.resize(h.x() + p.right, h.y() + p.top, l.z());
setRotationPivot( box.getCenter() );
}
- region.setQuality(regionQuality);
} else if( isStateDirty() ) {
region.markStateDirty();
}
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Group.java b/src/graphui/classes/com/jogamp/graph/ui/Group.java
index 025213f8d..2267b70cc 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Group.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Group.java
@@ -37,6 +37,8 @@ import com.jogamp.graph.curve.Region;
import com.jogamp.graph.curve.opengl.RegionRenderer;
import com.jogamp.graph.ui.layout.Padding;
import com.jogamp.graph.ui.shapes.Rectangle;
+import com.jogamp.math.FloatUtil;
+import com.jogamp.math.Vec2f;
import com.jogamp.math.Vec3f;
import com.jogamp.math.Vec4f;
import com.jogamp.math.geom.AABBox;
@@ -75,9 +77,14 @@ public class Group extends Shape implements Container {
}
private final List<Shape> shapes = new CopyOnWriteArrayList<Shape>();
+ private final Vec2f fixedSize = new Vec2f();
private Layout layouter;
private Rectangle border = null;
+ private boolean relayoutOnDirtyShapes = true;
+ private boolean widgetMode = false;
+ boolean clipOnBox = false;
+
/**
* Create a group of {@link Shape}s w/o {@link Group.Layout}.
* <p>
@@ -110,6 +117,14 @@ public class Group extends Shape implements Container {
/** Set {@link Group.Layout}. */
public Group setLayout(final Layout l) { layouter = l; return this; }
+ /** Enforce size of this group to given dimension. */
+ public Group setFixedSize(final Vec2f v) { fixedSize.set(v); return this; }
+ public Vec2f getFixedSize() { return fixedSize; }
+
+ /** Enable {@link AABBox} clipping on {@link #getBounds()} for this group and its shapes. */
+ public Group setClipOnBox(final boolean v) { clipOnBox = v; return this; }
+ public boolean getClipOnBox() { return clipOnBox; }
+
@Override
public int getShapeCount() { return shapes.size(); }
@@ -235,6 +250,10 @@ public class Group extends Shape implements Container {
final Object[] shapesS = shapes.toArray();
Arrays.sort(shapesS, (Comparator)Shape.ZAscendingComparator);
+ final AABBox origClipBox = renderer.getClipBBox();
+ if( clipOnBox ) {
+ renderer.setClipBBox( box.transform(pmv.getMv(), new AABBox()) ); // Mv pre-multiplied AABBox
+ }
final int shapeCount = shapesS.length;
for(int i=0; i<shapeCount; i++) {
final Shape shape = (Shape) shapesS[i];
@@ -251,7 +270,11 @@ public class Group extends Shape implements Container {
if( null != border ) {
border.draw(gl, renderer, sampleCount);
}
+ if( clipOnBox ) {
+ renderer.setClipBBox(origClipBox);
+ }
}
+
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected final void drawToSelectImpl0(final GL2ES2 gl, final RegionRenderer renderer, final int[] sampleCount) {
@@ -277,11 +300,17 @@ public class Group extends Shape implements Container {
}
}
- private boolean relayoutOnDirtyShapes = true;
+ /**
+ * Set relayout on dirty shapes mode, defaults to true.
+ * <p>
+ * If relayouting on dirty shape mode is enabler (default),
+ * {@link #isShapeDirty()} traverses through all shapes updating all dirty states of all its groups
+ * provoking a relayout if required.
+ * </p>
+ */
public void setRelayoutOnDirtyShapes(final boolean v) { relayoutOnDirtyShapes = v; }
public boolean getRelayoutOnDirtyShapes() { return relayoutOnDirtyShapes; }
- private boolean widgetMode = false;
/**
* Toggles widget behavior for this group and all its elements, default is disabled.
* <p>
@@ -341,6 +370,14 @@ public class Group extends Shape implements Container {
return v[0];
}
+ /**
+ * {@inheritDoc}
+ * <p>
+ * If relayouting on dirty shape mode is enabler, see {@link #setRelayoutOnDirtyShapes(boolean)},
+ * this method traverses through all shapes updating all dirty states of all its groups
+ * provoking a relayout if required.
+ * </p>
+ */
@Override
protected boolean isShapeDirty() {
if( relayoutOnDirtyShapes ) {
@@ -364,21 +401,25 @@ public class Group extends Shape implements Container {
// box has been reset
final PMVMatrix4f pmv = new PMVMatrix4f();
- if( 0 == shapes.size() ) {
- box.resize(0, 0, 0);
- } else if( null != layouter ) {
- for(final Shape s : shapes) {
- if( needsRMs && null == firstGS && s instanceof GraphShape ) {
- firstGS = (GraphShape)s;
- }
- layouter.preValidate(s);
- if( null != gl ) {
- s.validate(gl);
- } else {
- s.validate(glp);
+ if( null != layouter ) {
+ if( 0 == shapes.size() ) {
+ box.resize(0, 0, 0);
+ } else {
+ for(final Shape s : shapes) {
+ if( needsRMs && null == firstGS && s instanceof GraphShape ) {
+ firstGS = (GraphShape)s;
+ }
+ layouter.preValidate(s);
+ if( null != gl ) {
+ s.validate(gl);
+ } else {
+ s.validate(glp);
+ }
}
}
layouter.layout(this, box, pmv);
+ } else if( 0 == shapes.size() ) {
+ box.resize(0, 0, 0);
} else {
final AABBox tsbox = new AABBox();
for(final Shape s : shapes) {
@@ -405,6 +446,12 @@ public class Group extends Shape implements Container {
box.resize(h.x() + p.right, h.y() + p.top, l.z());
setRotationPivot( box.getCenter() );
}
+ if( !FloatUtil.isZero(fixedSize.x()) && !FloatUtil.isZero(fixedSize.y()) ) {
+ final Vec3f low = box.getLow();
+ final Vec3f high = new Vec3f(low);
+ high.add(fixedSize.x(), fixedSize.y(), 0);
+ box.setSize(low, high);
+ }
if( hasBorder() ) {
if( null == border ) {
final int firstRMs = null != firstGS ? firstGS.getRenderModes() : 0;
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/Scene.java
index 15ced642b..7748a4eb0 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Scene.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Scene.java
@@ -124,12 +124,6 @@ public final class Scene implements Container, GLEventListener {
return FloatUtil.getZBufferEpsilon(zBits, setup.getSceneDist(), setup.getZNear());
}
- /** Minimum sample count {@value} for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT}. */
- public static final int MIN_SAMPLE_COUNT = 1;
-
- /** Maximum sample count {@value} for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT}. */
- public static final int MAX_SAMPLE_COUNT = 8;
-
private static final boolean DEBUG = false;
private final List<Shape> shapes = new CopyOnWriteArrayList<Shape>();
@@ -175,7 +169,7 @@ public final class Scene implements Container, GLEventListener {
/**
* Create a new scene with an internally created {@link RegionRenderer}, using {@link DefaultPMVMatrixSetup#DefaultPMVMatrixSetup()}.
* @param sampleCount sample count for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT},
- * clipped to [{@link #MIN_SAMPLE_COUNT}..{@link #MAX_SAMPLE_COUNT}]
+ * clipped to [{@link Region#MIN_AA_SAMPLE_COUNT}..{@link Region#MAX_AA_SAMPLE_COUNT}]
* @see #Scene(RegionRenderer, int)
* @see #setSampleCount(int)
*/
@@ -187,7 +181,7 @@ public final class Scene implements Container, GLEventListener {
* Create a new scene taking ownership of the given RegionRenderer, using {@link DefaultPMVMatrixSetup#DefaultPMVMatrixSetup()}.
* @param renderer {@link RegionRenderer} to be owned
* @param sampleCount sample count for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT},
- * clipped to [{@link #MIN_SAMPLE_COUNT}..{@link #MAX_SAMPLE_COUNT}]
+ * clipped to [{@link Region#MIN_AA_SAMPLE_COUNT}..{@link Region#MAX_AA_SAMPLE_COUNT}]
* @see #setSampleCount(int)
*/
public Scene(final RegionRenderer renderer, final int sampleCount) {
@@ -195,7 +189,7 @@ public final class Scene implements Container, GLEventListener {
throw new IllegalArgumentException("Null RegionRenderer");
}
this.renderer = renderer;
- this.sampleCount[0] = Math.min(MAX_SAMPLE_COUNT, Math.max(sampleCount, MIN_SAMPLE_COUNT)); // clip
+ this.sampleCount[0] = Math.min(Region.MAX_AA_SAMPLE_COUNT, Math.max(sampleCount, Region.MIN_AA_SAMPLE_COUNT)); // clip
this.screenshot = new GLReadBufferUtil(false, false);
}
@@ -369,36 +363,49 @@ public final class Scene implements Container, GLEventListener {
public int getSampleCount() { return sampleCount[0]; }
/**
- * Sets sample count for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT}
- * @param v sample count, clipped to [{@link #MIN_SAMPLE_COUNT}..{@link #MAX_SAMPLE_COUNT}]
+ * Sets pass2 AA sample count for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT} or {@link Region#MSAA_RENDERING_BIT}
+ * @param v pass2 AA sample count, clipped to [{@link Region#MIN_AA_SAMPLE_COUNT}..{@link Region#MAX_AA_SAMPLE_COUNT}]
* @return clipped and set value
*/
public int setSampleCount(final int v) {
- sampleCount[0] = Math.min(MAX_SAMPLE_COUNT, Math.max(v, MIN_SAMPLE_COUNT)); // clip
- markAllShapesDirty();
+ sampleCount[0] = Math.min(Region.MAX_AA_SAMPLE_COUNT, Math.max(v, Region.MIN_AA_SAMPLE_COUNT)); // clip
+ markStatesDirty();
return sampleCount[0];
}
- public void setAllShapesQuality(final int q) {
- for(int i=0; i<shapes.size(); i++) {
- final Shape shape = shapes.get(i);
- if( shape instanceof GraphShape ) {
- ((GraphShape)shape).setQuality(q);
+ /**
+ * Sets pass2 AA-quality for Graph Region AA {@link Region#getRenderModes() render-modes}: {@link Region#VBAA_RENDERING_BIT}
+ * @param v pass2 AA-quality, clipped to [{@link Region#MIN_AA_QUALITY}..{@link Region#MAX_AA_QUALITY}]
+ * @return clipped and set value
+ */
+ public void setAAQuality(final int v) {
+ final int q = Math.min(Region.MAX_AA_QUALITY, Math.max(v, Region.MIN_AA_QUALITY)); // clip
+ forAll((final Shape s) -> {
+ if( s instanceof GraphShape ) {
+ ((GraphShape)s).setAAQuality(q);
}
- }
+ return false;
+ });
}
- public void setAllShapesSharpness(final float sharpness) {
- for(int i=0; i<shapes.size(); i++) {
- final Shape shape = shapes.get(i);
- if( shape instanceof GraphShape ) {
- ((GraphShape)shape).setSharpness(sharpness);
+ public void setSharpness(final float sharpness) {
+ forAll((final Shape s) -> {
+ if( s instanceof GraphShape ) {
+ ((GraphShape)s).setSharpness(sharpness);
}
- }
+ return false;
+ });
}
- public void markAllShapesDirty() {
- for(int i=0; i<shapes.size(); i++) {
- shapes.get(i).markShapeDirty();
- }
+ public void markShapesDirty() {
+ forAll((final Shape s) -> {
+ s.markShapeDirty();
+ return false;
+ });
+ }
+ public void markStatesDirty() {
+ forAll((final Shape s) -> {
+ s.markStateDirty();
+ return false;
+ });
}
@Override
diff --git a/src/graphui/classes/com/jogamp/graph/ui/Shape.java b/src/graphui/classes/com/jogamp/graph/ui/Shape.java
index 3ba5dbb32..17b1f5344 100644
--- a/src/graphui/classes/com/jogamp/graph/ui/Shape.java
+++ b/src/graphui/classes/com/jogamp/graph/ui/Shape.java
@@ -536,9 +536,11 @@ public abstract class Shape {
}
}
+ /** Returns the shape's dirty state, see {@link #markShapeDirty()}. */
protected boolean isShapeDirty() {
return 0 != ( dirty & DIRTY_SHAPE ) ;
}
+ /** Returns the rendering dirty state, see {@link #markStateDirty()}. */
protected final boolean isStateDirty() {
return 0 != ( dirty & DIRTY_STATE ) ;
}