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/classes/jogamp | |
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/classes/jogamp')
-rw-r--r-- | src/newt/classes/jogamp/newt/ScreenImpl.java | 10 | ||||
-rw-r--r-- | src/newt/classes/jogamp/newt/WindowImpl.java | 5 |
2 files changed, 8 insertions, 7 deletions
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() ; } |