diff options
author | Sven Göthel <[email protected]> | 2024-01-15 04:47:34 +0100 |
---|---|---|
committer | Sven Göthel <[email protected]> | 2024-01-15 04:47:34 +0100 |
commit | d7cb4a77b71cb3703ff7ac0667c5a97f29a5bdb4 (patch) | |
tree | 17cb67b7867f0da11a2717492d691a5e96f52636 /src/graphui/classes/com/jogamp | |
parent | 9b8d1825cfb76454e42b196a93dc54d189a8a9a6 (diff) |
Graph/GraphUI AA-Quality (shader): Region: Add DEFAULT_AA_QUALITY and clipping funs for aaQuality/sampleCount; TextRegionUtil: Pass quality parameter in draw-functions
Region.DEFAULT_AA_QUALITY defaults to MAX_AA_QUALITY still
- TODO: AA shader is subject to change ..
Region.draw(..) clips the quality param (save)
TextRegionUtil: Pass quality parameter in draw-functions
- Allowing to select the AA shader
GraphUI Scene and some demos add the AA-quality param
to the status line or screenshot-filename.
- See Region.getRenderModeString(..)
+++
TestTextRendererNEWT20 and TestTextRendererNEWT21
now iterate through all fonts, AA-quality shader and sample-sizes.
Most demos and some more tests take AA-quality into acount,
demos via CommandlineOptions.graphAAQuality
Diffstat (limited to 'src/graphui/classes/com/jogamp')
5 files changed, 64 insertions, 48 deletions
diff --git a/src/graphui/classes/com/jogamp/graph/ui/AnimGroup.java b/src/graphui/classes/com/jogamp/graph/ui/AnimGroup.java index f28c8984e..2c733f1fc 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/AnimGroup.java +++ b/src/graphui/classes/com/jogamp/graph/ui/AnimGroup.java @@ -383,7 +383,7 @@ public class AnimGroup extends Group { { refShape.setTransformMv(pmv); as = new Set(pixPerMM, refShape.getPixelPerShapeUnit(pmv, viewport, new float[2]), refShape, - accel, velocity, ang_accel, ang_velo, allShapes, sourceBounds, lerp); + accel, velocity, ang_accel, ang_velo, allShapes, sourceBounds, lerp); } pmv.popMv(); } @@ -448,10 +448,10 @@ public class AnimGroup extends Group { * @return newly created and added {@link Set} */ public final Set addGlyphSetRandom01(final float pixPerMM, - final GLProfile glp, final PMVMatrix4f pmv, final Recti viewport, final int renderModes, - final Font font, final CharSequence text, final float fontScale, final Vec4f fgCol, - final float accel, final float velocity, final float ang_accel, final float ang_velo, - final AABBox animBox, final boolean z_only, final Random random, final LerpFunc lerp) + final GLProfile glp, final PMVMatrix4f pmv, final Recti viewport, final int renderModes, + final Font font, final CharSequence text, final float fontScale, final Vec4f fgCol, + final float accel, final float velocity, final float ang_accel, final float ang_velo, + final AABBox animBox, final boolean z_only, final Random random, final LerpFunc lerp) { return addGlyphSet(pixPerMM, glp, pmv, viewport, renderModes, font, 'X', text, fontScale, accel, velocity, ang_accel, ang_velo, lerp, (final Set as, final int idx, final ShapeData sd) -> { diff --git a/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java b/src/graphui/classes/com/jogamp/graph/ui/GraphShape.java index 1e00d72f7..65363fa2b 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 regionPass2Quality = Region.MAX_AA_QUALITY; + private int regionPass2Quality = Region.DEFAULT_AA_QUALITY; private final List<GLRegion> dirtyRegions = new ArrayList<GLRegion>(); /** @@ -87,16 +87,22 @@ public abstract class GraphShape extends Shape { public final int getRenderModes() { return renderModes; } /** - * 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}. + * Sets the shape's Graph {@link Region}'s pass2 AA-quality parameter. Default is {@link Region#DEFAULT_AA_QUALITY}. + * @param v Graph {@link Region}'s pass2 AA-quality parameter, default is {@link Region#DEFAULT_AA_QUALITY}. * @return this shape for chaining. */ - public final GraphShape setAAQuality(final int q) { - this.regionPass2Quality = q; + public final GraphShape setAAQuality(final int v) { + this.regionPass2Quality = Region.clipAAQuality(v); markStateDirty(); return this; } + /** + * Return the shape's Graph {@link Region}'s quality parameter. + * @see #setAAQuality(int) + */ + public final int getAAQuality() { return regionPass2Quality; } + /** Set the 2nd pass texture unit. */ public void setTextureUnit(final int pass2TexUnit) { this.pass2TexUnit = pass2TexUnit; @@ -106,12 +112,6 @@ public abstract class GraphShape extends Shape { } /** - * Return the shape's Graph {@link Region}'s quality parameter. - * @see #setAAQuality(int) - */ - public final int getAAQuality() { return regionPass2Quality; } - - /** * Sets the shape's Graph {@link OutlineShape}'s sharpness parameter. Default is {@link OutlineShape#DEFAULT_SHARPNESS}. * * Method issues {@link #markShapeDirty()}. @@ -228,7 +228,7 @@ public abstract class GraphShape extends Shape { } @Override - protected final void validateImpl(final GLProfile glp, final GL2ES2 gl) { + protected final void validateImpl(final GL2ES2 gl, final GLProfile glp) { if( null != gl ) { clearDirtyRegions(gl); } diff --git a/src/graphui/classes/com/jogamp/graph/ui/Group.java b/src/graphui/classes/com/jogamp/graph/ui/Group.java index 2267b70cc..d13fdef75 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Group.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Group.java @@ -394,7 +394,7 @@ public class Group extends Shape implements Container { } @Override - protected void validateImpl(final GLProfile glp, final GL2ES2 gl) { + protected void validateImpl(final GL2ES2 gl, final GLProfile glp) { if( isShapeDirty() ) { final boolean needsRMs = hasBorder() && null == border; GraphShape firstGS = null; @@ -410,11 +410,7 @@ public class Group extends Shape implements Container { firstGS = (GraphShape)s; } layouter.preValidate(s); - if( null != gl ) { - s.validate(gl); - } else { - s.validate(glp); - } + s.validate(gl, glp); } } layouter.layout(this, box, pmv); @@ -426,11 +422,7 @@ public class Group extends Shape implements Container { if( needsRMs && null == firstGS && s instanceof GraphShape ) { firstGS = (GraphShape)s; } - if( null != gl ) { - s.validate(gl); - } else { - s.validate(glp); - } + s.validate(gl, glp); pmv.pushMv(); s.setTransformMv(pmv); s.getBounds().transform(pmv.getMv(), tsbox); diff --git a/src/graphui/classes/com/jogamp/graph/ui/Scene.java b/src/graphui/classes/com/jogamp/graph/ui/Scene.java index 7748a4eb0..d41378251 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Scene.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Scene.java @@ -138,6 +138,7 @@ public final class Scene implements Container, GLEventListener { private final RegionRenderer renderer; private final int[] sampleCount = new int[1]; + private int globalAAQuality = -1; // undefined /** Describing the bounding box in shape's object model-coordinates of the near-plane parallel at its scene-distance, post {@link #translate(PMVMatrix4f)} */ private final AABBox planeBox = new AABBox(0f, 0f, 0f, 0f, 0f, 0f); @@ -189,7 +190,7 @@ public final class Scene implements Container, GLEventListener { throw new IllegalArgumentException("Null RegionRenderer"); } this.renderer = renderer; - this.sampleCount[0] = Math.min(Region.MAX_AA_SAMPLE_COUNT, Math.max(sampleCount, Region.MIN_AA_SAMPLE_COUNT)); // clip + this.sampleCount[0] = Region.clipAASampleCount(sampleCount); this.screenshot = new GLReadBufferUtil(false, false); } @@ -368,7 +369,7 @@ public final class Scene implements Container, GLEventListener { * @return clipped and set value */ public int setSampleCount(final int v) { - sampleCount[0] = Math.min(Region.MAX_AA_SAMPLE_COUNT, Math.max(v, Region.MIN_AA_SAMPLE_COUNT)); // clip + sampleCount[0] = Region.clipAASampleCount(v); markStatesDirty(); return sampleCount[0]; } @@ -379,7 +380,8 @@ public final class Scene implements Container, GLEventListener { * @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 + final int q = Region.clipAAQuality(v); + globalAAQuality = q; forAll((final Shape s) -> { if( s instanceof GraphShape ) { ((GraphShape)s).setAAQuality(q); @@ -387,6 +389,9 @@ public final class Scene implements Container, GLEventListener { return false; }); } + /** Returns the global AA quality value if set via {@link #setAAQuality(int)}, otherwise {@code -1}. */ + public int getAAQuality() { return globalAAQuality; } + public void setSharpness(final float sharpness) { forAll((final Shape s) -> { if( s instanceof GraphShape ) { @@ -1263,7 +1268,7 @@ public final class Scene implements Container, GLEventListener { /** * Return a formatted status string containing avg fps and avg frame duration. * @param glad GLAutoDrawable instance for FPSCounter, its chosen GLCapabilities and its GL's swap-interval - * @param renderModes render modes for {@link Region#getRenderModeString(int, int, int)} + * @param renderModes render modes for {@link Region#getRenderModeString(int, int, int, int)} * @param quality the Graph-Curve quality setting or -1 to be ignored * @param dpi the monitor's DPI (vertical preferred) * @return formatted status string @@ -1281,20 +1286,25 @@ public final class Scene implements Container, GLEventListener { td = 0f; } final GLCapabilitiesImmutable caps = glad.getChosenGLCapabilities(); - final String modeS = Region.getRenderModeString(renderModes, getSampleCount(), caps.getNumSamples()); - final String qualityStr, blendStr; - if( 0 <= quality ) { - qualityStr = ", q "+quality; - } else { - qualityStr = ""; - } + final String modeS = Region.getRenderModeString(renderModes, quality, getSampleCount(), caps.getNumSamples()); + final String blendStr; if( getRenderer().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED) ) { blendStr = ", blend"; } else { blendStr = ""; } - return String.format("%03.1f/%03.1f fps, %.1f ms/f, vsync %d, dpi %.1f, %s%s%s, a %d", - lfps, tfps, td, glad.getGL().getSwapInterval(), dpi, modeS, qualityStr, blendStr, caps.getAlphaBits()); + return String.format("%03.1f/%03.1f fps, %.1f ms/f, vsync %d, dpi %.1f, %s%s, a %d", + lfps, tfps, td, glad.getGL().getSwapInterval(), dpi, modeS, blendStr, caps.getAlphaBits()); + } + /** + * Return a formatted status string containing avg fps and avg frame duration using {@link #getAAQuality()} + * @param glad GLAutoDrawable instance for FPSCounter, its chosen GLCapabilities and its GL's swap-interval + * @param renderModes render modes for {@link Region#getRenderModeString(int, int, int, int)} + * @param dpi the monitor's DPI (vertical preferred) + * @return formatted status string + */ + public String getStatusText(final GLAutoDrawable glad, final int renderModes, final float dpi) { + return getStatusText(glad, renderModes, globalAAQuality, dpi); } /** @@ -1312,7 +1322,7 @@ public final class Scene implements Container, GLEventListener { /** * Return the unique next technical screenshot PNG {@link File} instance as follows: * <pre> - * filename = [{dir}][{prefix}-]{@link Region#getRenderModeString(int, int, int)}[-{contentDetails}]-snap{screenShotCount}-{resolution}.png + * filename = [{dir}][{prefix}-]{@link Region#getRenderModeString(int, int, int, int)}[-{contentDetails}]-snap{screenShotCount}-{resolution}.png * </pre> * Implementation increments {@link #getScreenshotCount()}. * @@ -1330,7 +1340,7 @@ public final class Scene implements Container, GLEventListener { final String dir2 = ( null != dir && dir.length() > 0 ) ? dir : ""; final String prefix2 = ( null != prefix && prefix.length() > 0 ) ? prefix+"-" : ""; final RegionRenderer renderer = getRenderer(); - final String modeS = Region.getRenderModeString(renderModes, getSampleCount(), caps.getNumSamples()); + final String modeS = Region.getRenderModeString(renderModes, globalAAQuality, getSampleCount(), caps.getNumSamples()); final String contentDetail2 = ( null != contentDetail && contentDetail.length() > 0 ) ? contentDetail+"-" : ""; return new File( String.format((Locale)null, "%s%s%s-%ssnap%02d-%04dx%04d.png", dir2, prefix2, modeS, contentDetail2, diff --git a/src/graphui/classes/com/jogamp/graph/ui/Shape.java b/src/graphui/classes/com/jogamp/graph/ui/Shape.java index 17b1f5344..225750b09 100644 --- a/src/graphui/classes/com/jogamp/graph/ui/Shape.java +++ b/src/graphui/classes/com/jogamp/graph/ui/Shape.java @@ -456,7 +456,7 @@ public abstract class Shape { /** Return unscaled rotation origin, aka pivot. Null if not set via {@link #getRotationPivot()}. */ public final Vec3f getRotationPivot() { return rotPivot; } /** - * Set unscaled rotation origin, aka pivot. Usually the {@link #getBounds()} center and should be set while {@link #validateImpl(GLProfile, GL2ES2)}. + * Set unscaled rotation origin, aka pivot. Usually the {@link #getBounds()} center and should be set while {@link #validateImpl(GL2ES2, GLProfile)}. * @return this shape for chaining */ public final Shape setRotationPivot(final float px, final float py, final float pz) { @@ -464,7 +464,7 @@ public abstract class Shape { return this; } /** - * Set unscaled rotation origin, aka pivot. Usually the {@link #getBounds()} center and should be set while {@link #validateImpl(GLProfile, GL2ES2)}. + * Set unscaled rotation origin, aka pivot. Usually the {@link #getBounds()} center and should be set while {@link #validateImpl(GL2ES2, GLProfile)}. * @param pivot rotation origin * @return this shape for chaining */ @@ -688,7 +688,7 @@ public abstract class Shape { if( isShapeDirty() ) { box.reset(); } - validateImpl(gl.getGLProfile(), gl); + validateImpl(gl, gl.getGLProfile()); dirty = 0; } return this; @@ -707,13 +707,27 @@ public abstract class Shape { if( isShapeDirty() ) { box.reset(); } - validateImpl(glp, null); + validateImpl(null, glp); dirty = 0; } return this; } /** + * Validate the shape via {@link #validate(GL2ES2)} if {@code gl} is not null, + * otherwise uses {@link #validate(GLProfile)}. + * @see #validate(GL2ES2) + * @see #validate(GLProfile) + */ + public final Shape validate(final GL2ES2 gl, final GLProfile glp) { + if( null != gl ) { + return validate(gl); + } else { + return validate(glp); + } + } + + /** * Setup the {@link PMVMatrix4f#getMv() modelview matrix} of the given {@link PMVMatrix4f} for this object. * - Scale shape from its center position * - Rotate shape around optional scaled pivot, see {@link #setRotationPivot(float[])}), otherwise rotate around its scaled center (default) @@ -1822,7 +1836,7 @@ public abstract class Shape { // // - protected abstract void validateImpl(final GLProfile glp, final GL2ES2 gl); + protected abstract void validateImpl(final GL2ES2 gl, final GLProfile glp); /** * Actual draw implementation, called by {@link #draw(GL2ES2, RegionRenderer, int[])} |