diff options
author | Sven Gothel <[email protected]> | 2023-03-07 01:33:22 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-03-07 01:33:22 +0100 |
commit | fb03e913c0c55a9a96e93a00ef6590b9bea9a62a (patch) | |
tree | 060fab60bd6a7f926703c2aedfa00ea466e507fb /src/newt | |
parent | 607eb99b9cad227dd7be6d149c6b6cf57d060c35 (diff) |
Clock: Use Clock.currentNanos() instead of System.nanoTime(); Enhancing FPSCounterImpl accuracy by maintaining timestamps in [ns]
Idea: Perhaps we want to use [ns] for FPSCounter's method types by now?
Diffstat (limited to 'src/newt')
-rw-r--r-- | src/newt/classes/com/jogamp/newt/opengl/GLWindow.java | 5 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/ScreenImpl.java | 10 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/WindowImpl.java | 5 |
3 files changed, 11 insertions, 9 deletions
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java index 6b102ea68..1435aa20a 100644 --- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java +++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java @@ -73,6 +73,7 @@ import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableImpl; import com.jogamp.common.GlueGenVersion; +import com.jogamp.common.os.Clock; import com.jogamp.common.util.SecurityUtil; import com.jogamp.common.util.VersionUtil; import com.jogamp.common.util.locks.RecursiveLock; @@ -679,7 +680,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind public synchronized void setVisibleActionPost(final boolean visible, final boolean nativeWindowCreated) { long t0; if(Window.DEBUG_IMPLEMENTATION) { - t0 = System.nanoTime(); + t0 = Clock.currentNanos(); System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+WindowImpl.getThreadName()+", start"); } else { t0 = 0; @@ -710,7 +711,7 @@ public class GLWindow extends GLAutoDrawableBase implements GLAutoDrawable, Wind } } if(Window.DEBUG_IMPLEMENTATION) { - System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+WindowImpl.getThreadName()+", fin: dt "+ (System.nanoTime()-t0)/1e6 +"ms"); + System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+WindowImpl.getThreadName()+", fin: dt "+ (Clock.currentNanos()-t0)/1e6 +"ms"); } } diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java index b41c28e27..78df525ee 100644 --- a/src/newt/classes/jogamp/newt/ScreenImpl.java +++ b/src/newt/classes/jogamp/newt/ScreenImpl.java @@ -43,7 +43,7 @@ import com.jogamp.nativewindow.NativeWindowException; import com.jogamp.nativewindow.util.Dimension; import com.jogamp.nativewindow.util.Rectangle; import com.jogamp.nativewindow.util.RectangleImmutable; - +import com.jogamp.common.os.Clock; import com.jogamp.common.util.ArrayHashSet; import com.jogamp.common.util.PropertyAccess; import com.jogamp.newt.Display; @@ -184,7 +184,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { { if(null == aScreen) { if(DEBUG) { - tCreated = System.nanoTime(); + tCreated = Clock.currentNanos(); System.err.println("Screen.createNative() START ("+Display.getThreadName()+", "+this+")"); } else { tCreated = 0; @@ -200,7 +200,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { synchronized(screenList) { screensActive++; if(DEBUG) { - System.err.println("Screen.createNative() END ("+Display.getThreadName()+", "+this+"), active "+screensActive+", total "+ (System.nanoTime()-tCreated)/1e6 +"ms"); + System.err.println("Screen.createNative() END ("+Display.getThreadName()+", "+this+"), active "+screensActive+", total "+ (Clock.currentNanos()-tCreated)/1e6 +"ms"); } } ScreenMonitorState.getScreenMonitorState(this.getFQName()).addListener(this); @@ -554,7 +554,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { private final ScreenMonitorState initMonitorState() { long t0; if(DEBUG) { - t0 = System.nanoTime(); + t0 = Clock.currentNanos(); System.err.println("Screen.initMonitorState() START ("+Display.getThreadName()+", "+this+")"); } else { t0 = 0; @@ -614,7 +614,7 @@ public abstract class ScreenImpl extends Screen implements MonitorModeListener { ScreenMonitorState.unlockScreenMonitorState(); } if(DEBUG) { - System.err.println("Screen.initMonitorState() END dt "+ (System.nanoTime()-t0)/1e6 +"ms"); + System.err.println("Screen.initMonitorState() END dt "+ (Clock.currentNanos()-t0)/1e6 +"ms"); } if( !vScrnSizeUpdated ) { updateVirtualScreenOriginAndSize(); diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java index 45329bed9..c860e4c3e 100644 --- a/src/newt/classes/jogamp/newt/WindowImpl.java +++ b/src/newt/classes/jogamp/newt/WindowImpl.java @@ -66,6 +66,7 @@ import jogamp.nativewindow.SurfaceScaleUtils; import jogamp.nativewindow.SurfaceUpdatedHelper; import com.jogamp.common.ExceptionUtils; +import com.jogamp.common.os.Clock; import com.jogamp.common.util.ArrayHashSet; import com.jogamp.common.util.Bitfield; import com.jogamp.common.util.InterruptSource; @@ -738,7 +739,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer private boolean createNative() { long tStart; if(DEBUG_IMPLEMENTATION) { - tStart = System.nanoTime(); + tStart = Clock.currentNanos(); System.err.println("Window.createNative() START ("+getThreadName()+", "+this+")"); } else { tStart = 0; @@ -839,7 +840,7 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer ((DisplayImpl) screen.getDisplay()).dispatchMessagesNative(); // status up2date } if(DEBUG_IMPLEMENTATION) { - System.err.println("Window.createNative() END ("+getThreadName()+", "+this+") total "+ (System.nanoTime()-tStart)/1e6 +"ms"); + System.err.println("Window.createNative() END ("+getThreadName()+", "+this+") total "+ (Clock.currentNanos()-tStart)/1e6 +"ms"); } return isNativeValid() ; } |