diff options
author | Sven Gothel <[email protected]> | 2023-03-08 05:39:56 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-03-08 05:39:56 +0100 |
commit | d76fc6f518606def8ddc52e0cd4d8a29bd2536fc (patch) | |
tree | f8332e129ab8c3238b7cdf05eeab4d681fbb4671 /src/test/com/jogamp | |
parent | adfe4abec47313d2c533096f6c3e9a94d2fc4571 (diff) |
Graph: Font: Add equals() + hash() API doc; GraphUI's Label*.setText(): Only modify values if text and/or font differs, skipping markShapeDirty() saves performance.
Diffstat (limited to 'src/test/com/jogamp')
3 files changed, 38 insertions, 15 deletions
diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java index f9a333fc4..c1ef5f7fd 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/GPUUISceneGLListener0A.java @@ -179,6 +179,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { throw new RuntimeException(ioe); } sceneUIController = new SceneUIController(sceneDist, zNear, zFar); + // sceneUIController.setSampleCount(3); // easy on embedded devices w/ just 3 samples (default is 4)? screenshot = new GLReadBufferUtil(false, false); } @@ -929,7 +930,7 @@ public class GPUUISceneGLListener0A implements GLEventListener { if( null != animator ) { lfps = animator.getLastFPS(); tfps = animator.getTotalFPS(); - td = animator.getTotalFPSDuration()/1000f; + td = (float)animator.getLastFPSPeriod() / (float)animator.getUpdateFPSFrames(); } else { lfps = 0f; tfps = 0f; @@ -938,16 +939,18 @@ public class GPUUISceneGLListener0A implements GLEventListener { final String modeS = Region.getRenderModeString(renderModes); final String text; if( null == actionText ) { - text = String.format("%03.1f/%03.1f fps, v-sync %d, dpi %.1f, %s-samples %d, q %d, td %.0f, blend %b, alpha %d, msaa %d", - lfps, tfps, gl.getSwapInterval(), dpiH, modeS, sceneUIController.getSampleCount(), fpsLabel.getQuality(), td, + text = String.format("%03.1f/%03.1f fps, %.1f ms/f, v-sync %d, dpi %.1f, %s-samples %d, q %d, msaa %d, blend %b, alpha %d", + lfps, tfps, td, gl.getSwapInterval(), dpiH, modeS, sceneUIController.getSampleCount(), fpsLabel.getQuality(), + drawable.getChosenGLCapabilities().getNumSamples(), renderer.getRenderState().isHintMaskSet(RenderState.BITHINT_BLENDING_ENABLED), - drawable.getChosenGLCapabilities().getAlphaBits(), - drawable.getChosenGLCapabilities().getNumSamples()); + drawable.getChosenGLCapabilities().getAlphaBits()); } else { text = String.format("%03.1f/%03.1f fps, v-sync %d, %s", lfps, tfps, gl.getSwapInterval(), actionText); } - fpsLabel.setText(text); + if( fpsLabel.setText(text) ) { // marks dirty only if text differs. + System.err.println(text); + } } sceneUIController.display(drawable); } diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java index c4c450763..d64b9a731 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/Label.java @@ -52,18 +52,36 @@ public class Label extends UIShape { return text; } - public void setText(final String text) { - this.text = text; - markShapeDirty(); + /** + * Returns true if text has been updated, false if unchanged. + * @param text the text to be set. + */ + public boolean setText(final String text) { + if( !this.text.equals(text) ) { + this.text = text; + markShapeDirty(); + return true; + } else { + return false; + } } public Font getFont() { return font; } - public void setFont(final Font font) { - this.font = font; - markShapeDirty(); + /** + * Returns true if font has been updated, false if unchanged. + * @param font the font to be set. + */ + public boolean setFont(final Font font) { + if( !this.font.equals(font) ) { + this.font = font; + markShapeDirty(); + return true; + } else { + return false; + } } public float getPixelSize() { diff --git a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java index 6a3637e4a..8a357c8a6 100644 --- a/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java +++ b/src/test/com/jogamp/opengl/test/junit/graph/demos/ui/LabelButton.java @@ -165,9 +165,11 @@ public class LabelButton extends RoundButton { } public final void setLabelText(final Font labelFont, final String labelText) { - label.setFont(labelFont); - label.setText(labelText); - markShapeDirty(); + if( !label.getText().equals(labelText) || !label.getFont().equals(labelFont) ) { + label.setFont(labelFont); + label.setText(labelText); + markShapeDirty(); + } } @Override |