aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-02-23 16:41:47 +0100
committerSven Gothel <[email protected]>2012-02-23 16:41:47 +0100
commit5b05aa83f57b7492b2705529033a7eaa09cf4463 (patch)
tree788e7a5d16ebce1a984f20f2b94faf96d5c62126
parent352013de5564013fe2b6444e6469ef2886f1adb9 (diff)
NEWT: Add time costs in DEBUG mode. NEWT/XRandR: Reuse XRRScreenConfiguration to reduce perf hit on Linux ARM Omap4.
On Linux ARM Omap4, we experience a performance hit when using XRandR: 1st call of XRRSizes: ~ 1668 ms Each call of XRRGetScreenInfo: ~ 1109 ms Even though XRRGetScreenInfo is cached in NEWT's X11Screen initialization, overall init time is ~2s, far too expensive.
-rw-r--r--make/build-newt.xml2
-rwxr-xr-xmake/scripts/targetcommand-1.sh8
-rwxr-xr-xmake/scripts/tests.sh6
-rw-r--r--src/newt/classes/com/jogamp/newt/opengl/GLWindow.java14
-rw-r--r--src/newt/classes/jogamp/newt/ScreenImpl.java54
-rw-r--r--src/newt/classes/jogamp/newt/WindowImpl.java9
-rw-r--r--src/newt/classes/jogamp/newt/driver/x11/X11Screen.java101
-rw-r--r--src/newt/native/X11Screen.c136
8 files changed, 195 insertions, 135 deletions
diff --git a/make/build-newt.xml b/make/build-newt.xml
index 6e3d7b262..cc0688378 100644
--- a/make/build-newt.xml
+++ b/make/build-newt.xml
@@ -534,9 +534,9 @@
<patternset id="c.src.files.newt">
<include name="${rootrel.src.c}/NewtCommon.c" />
+ <!-- include name="${rootrel.src.c}/timespec.c" /--> <!-- currently used for X11 and OSX with special PERF DEBUG MODE-->
<include name="${rootrel.src.c}/WindowsWindow.c" if="isWindows"/>
<include name="${rootrel.src.c}/*.m" if="isOSX"/>
- <!-- include name="${rootrel.src.c}/timespec.c" if="isOSX"/--> <!-- currently only used for OSX with special PERF DEBUG MODE-->
<include name="${rootrel.src.c}/AndroidWindow.c" if="isAndroid"/>
<include name="${rootrel.src.c}/X11Display.c" if="isX11"/>
<include name="${rootrel.src.c}/X11Screen.c" if="isX11"/>
diff --git a/make/scripts/targetcommand-1.sh b/make/scripts/targetcommand-1.sh
index 21bbaf5c3..b50b0ff6d 100755
--- a/make/scripts/targetcommand-1.sh
+++ b/make/scripts/targetcommand-1.sh
@@ -2,7 +2,8 @@
THISDIR=`pwd`
-#XTRA_FLAGS=""
+XTRA_FLAGS="-Dnewt.debug.Screen"
+#XTRA_FLAGS="-Dnewt.debug.Window -Djogl.debug.EGL -Djogl.debug.GLContext -Djogl.debug.GLDrawable"
#XTRA_FLAGS="-Djogl.debug.EGL"
#XTRA_FLAGS="-Djogl.debug.GraphicsConfiguration"
#XTRA_FLAGS="-Djogl.debug.GLContext -Djogl.debug.GLDrawable"
@@ -23,7 +24,7 @@ THISDIR=`pwd`
# Some Regressions (Panda, Omap4)
#
-TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2
+#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestMapBuffer01NEWT
@@ -32,7 +33,7 @@ TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2
-#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT
+TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedNEWT
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.caps.TestMultisampleNEWT
#TSTCLASS=com.jogamp.opengl.test.junit.jogl.caps.TestTranslucencyNEWT
@@ -79,6 +80,7 @@ TSTCLASS=com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2
function junit_run() {
java \
+ -Xprof \
-cp ../../gluegen/make/lib/junit.jar:/usr/share/ant/lib/ant.jar:/usr/share/ant/lib/ant-junit.jar:../../gluegen/build-linux-armv7/gluegen-rt.jar:../build-linux-armv7/jar/jogl.all-noawt.jar:../build-linux-armv7/jar/jogl.test.jar\
-Djava.awt.headless=true\
$XTRA_FLAGS \
diff --git a/make/scripts/tests.sh b/make/scripts/tests.sh
index 40fb694b1..cda1aadc1 100755
--- a/make/scripts/tests.sh
+++ b/make/scripts/tests.sh
@@ -72,7 +72,7 @@ function jrun() {
#D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Djogamp.debug.Lock.TraceLock -Dnativewindow.debug.ToolkitLock.TraceLock"
#D_ARGS="-Djogamp.common.utils.locks.Lock.timeout=600000 -Djogamp.debug.Lock -Dnativewindow.debug.X11Util"
#D_ARGS="-Dnewt.debug.EDT -Djogamp.common.utils.locks.Lock.timeout=600000 -Djogl.debug.Animator -Dnewt.debug.Display -Dnewt.debug.Screen"
- #D_ARGS="-Dnewt.debug.Screen"
+ D_ARGS="-Dnewt.debug.Screen"
#D_ARGS="-Dnewt.debug.Window -Djogamp.common.utils.locks.Lock.timeout=600000 -Djogl.debug.Animator"
#D_ARGS="-Djogl.debug.Animator -Dnewt.debug=all"
#D_ARGS="-Dnewt.debug.EDT -Dnewt.debug.Display -Dnativewindow.debug.X11Util -Djogl.debug.GLDrawable -Djogl.debug.GLCanvas"
@@ -186,13 +186,13 @@ function testawtswt() {
#testnoawt com.jogamp.opengl.test.junit.jogl.offscreen.TestOffscreen02BitmapNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestMainVersionGLWindowNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLProfile01NEWT $*
-#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $*
+testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownCompleteNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestShutdownSharedNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestInitConcurrentNEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug00NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestGLDebug01NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT $*
-testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $*
+#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextListNEWT2 $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES1NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT $*
#testnoawt com.jogamp.opengl.test.junit.jogl.acore.TestSharedContextVBOES2NEWT2 $*
diff --git a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
index dc2db7f74..c0d79a5d4 100644
--- a/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
+++ b/src/newt/classes/com/jogamp/newt/opengl/GLWindow.java
@@ -394,11 +394,12 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
}
public synchronized void setVisibleActionPost(boolean visible, boolean nativeWindowCreated) {
+ long t0;
if(Window.DEBUG_IMPLEMENTATION) {
- String msg = "GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+Thread.currentThread()+", start";
- System.err.println(msg);
- // Exception e1 = new Exception(msg);
- // e1.printStackTrace();
+ t0 = System.nanoTime();
+ System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+Thread.currentThread()+", start");
+ } else {
+ t0 = 0;
}
/* if (nativeWindowCreated && null != context) {
@@ -423,10 +424,7 @@ public class GLWindow implements GLAutoDrawable, Window, NEWTEventConsumer, FPSC
context.setContextCreationFlags(additionalCtxCreationFlags);
}
if(Window.DEBUG_IMPLEMENTATION) {
- String msg = "GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+Thread.currentThread()+", fin";
- System.err.println(msg);
- //Exception e1 = new Exception(msg);
- //e1.printStackTrace();
+ System.err.println("GLWindow.setVisibleActionPost("+visible+", "+nativeWindowCreated+") "+Thread.currentThread()+", fin: dt "+ (System.nanoTime()-t0)/1e6 +"ms");
}
}
diff --git a/src/newt/classes/jogamp/newt/ScreenImpl.java b/src/newt/classes/jogamp/newt/ScreenImpl.java
index a6bd960b7..6c78a9653 100644
--- a/src/newt/classes/jogamp/newt/ScreenImpl.java
+++ b/src/newt/classes/jogamp/newt/ScreenImpl.java
@@ -74,7 +74,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
protected static volatile boolean usrSizeQueried = false;
private static AccessControlContext localACC = AccessController.getContext();
private ArrayList<ScreenModeListener> referencedScreenModeListener = new ArrayList<ScreenModeListener>();
- long t0; // creationTime
+ private long tCreated; // creationTime
static {
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@@ -177,21 +177,26 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
public synchronized final void createNative()
throws NativeWindowException
- {
+ {
if(null == aScreen) {
if(DEBUG) {
+ tCreated = System.nanoTime();
System.err.println("Screen.createNative() START ("+DisplayImpl.getThreadName()+", "+this+")");
+ } else {
+ tCreated = 0;
}
- t0 = System.currentTimeMillis();
+
display.addReference();
+
createNativeImpl();
if(null == aScreen) {
throw new NativeWindowException("Screen.createNative() failed to instanciate an AbstractGraphicsScreen");
}
+
initScreenModeStatus();
updateVirtualScreenOriginAndSize();
if(DEBUG) {
- System.err.println("Screen.createNative() END ("+DisplayImpl.getThreadName()+", "+this+")");
+ System.err.println("Screen.createNative() END ("+DisplayImpl.getThreadName()+", "+this+"), total "+ (System.nanoTime()-tCreated)/1e6 +"ms");
}
synchronized(screenList) {
screensActive++;
@@ -361,7 +366,7 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
ScreenMode smU = getScreenModesOrig().get(screenMode); // unify via value hash
if(smU.equals(smC)) {
if(DEBUG) {
- System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): 0.0 is-current (skip) "+smU+" == "+smC);
+ System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tCreated)+"): 0.0 is-current (skip) "+smU+" == "+smC);
}
return true;
}
@@ -372,32 +377,26 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
boolean success;
sms.lock();
try {
- long t0=0, t1=0;
+ final long tStart;
if(DEBUG) {
- System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): 0.0 "+smU);
- t0 = System.currentTimeMillis();
- }
-
+ tStart = System.nanoTime();
+ } else {
+ tStart = 0;
+ }
+
sms.fireScreenModeChangeNotify(smU);
-
if(DEBUG) {
- System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): 0.1 "+smU);
- t1 = System.currentTimeMillis();
+ System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): fireScreenModeChangeNotify() "+smU);
}
- success = setCurrentScreenModeImpl(smU);
-
+ success = setCurrentScreenModeImpl(smU);
if(DEBUG) {
- t1 = System.currentTimeMillis() - t1;
- System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): X.0 "+smU+", success: "+success);
+ System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): setCurrentScreenModeImpl() "+smU+", success: "+success);
}
- sms.fireScreenModeChanged(smU, success);
-
+ sms.fireScreenModeChanged(smU, success);
if(DEBUG) {
- t0 = System.currentTimeMillis() - t0;
- System.err.println("Screen.setCurrentScreenMode ("+(System.currentTimeMillis()-t0)+"): X.X "+smU+", success: "+success+
- " - dt0 "+t0+"ms, dt1 "+t1+"ms");
+ System.err.println("Screen.setCurrentScreenMode ("+(System.nanoTime()-tStart)/1e6+"ms): X.X "+smU+", success: "+success);
}
} finally {
sms.unlock();
@@ -514,6 +513,14 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
}
private ScreenModeStatus initScreenModeStatus() {
+ long t0;
+ if(DEBUG) {
+ t0 = System.nanoTime();
+ System.err.println("Screen.initScreenModeStatus() START ("+DisplayImpl.getThreadName()+", "+this+")");
+ } else {
+ t0 = 0;
+ }
+
ScreenModeStatus sms;
ScreenModeStatus.lockScreenModeStatus();
try {
@@ -545,6 +552,9 @@ public abstract class ScreenImpl extends Screen implements ScreenModeListener {
} finally {
ScreenModeStatus.unlockScreenModeStatus();
}
+ if(DEBUG) {
+ System.err.println("Screen.initScreenModeStatus() END dt "+ (System.nanoTime()-t0)/1e6 +"ms");
+ }
return sms;
}
diff --git a/src/newt/classes/jogamp/newt/WindowImpl.java b/src/newt/classes/jogamp/newt/WindowImpl.java
index 9d15ae8c7..62e42c185 100644
--- a/src/newt/classes/jogamp/newt/WindowImpl.java
+++ b/src/newt/classes/jogamp/newt/WindowImpl.java
@@ -273,9 +273,14 @@ public abstract class WindowImpl implements Window, NEWTEventConsumer
}
private boolean createNative() {
+ long tStart;
if(DEBUG_IMPLEMENTATION) {
+ tStart = System.nanoTime();
System.err.println("Window.createNative() START ("+getThreadName()+", "+this+")");
- }
+ } else {
+ tStart = 0;
+ }
+
if( null != parentWindow &&
NativeSurface.LOCK_SURFACE_NOT_READY >= parentWindow.lockSurface() ) {
throw new NativeWindowException("Parent surface lock: not ready: "+parentWindow);
@@ -322,7 +327,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+")");
+ System.err.println("Window.createNative() END ("+getThreadName()+", "+this+") total "+ (System.nanoTime()-tStart)/1e6 +"ms");
}
return isNativeValid() ;
}
diff --git a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
index ed5ebc04e..9dbac5d7f 100644
--- a/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
+++ b/src/newt/classes/jogamp/newt/driver/x11/X11Screen.java
@@ -175,31 +175,42 @@ public class X11Screen extends ScreenImpl {
protected ScreenMode getCurrentScreenModeImpl() {
return runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<ScreenMode>() {
public ScreenMode run(long dpy) {
- int resNumber = getNumScreenModeResolutions0(dpy, screen_idx);
- if(0==resNumber) {
+ long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx);
+ if(0 == screenConfigHandle) {
return null;
}
- int resIdx = getCurrentScreenResolutionIndex0(dpy, screen_idx);
- if(0>resIdx) {
- return null;
- }
- if(resIdx>=resNumber) {
- throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber);
- }
- int[] res = getScreenModeResolution0(dpy, screen_idx, resIdx);
- if(null==res || 0==res.length) {
- return null;
- }
- if(0>=res[0] || 0>=res[1]) {
- throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber);
- }
- int rate = getCurrentScreenRate0(dpy, screen_idx);
- if(0>rate) {
- return null;
- }
- int rot = getCurrentScreenRotation0(dpy, screen_idx);
- if(0>rot) {
- return null;
+ int[] res;
+ int rate, rot;
+ try {
+ int resNumber = getNumScreenModeResolutions0(dpy, screen_idx);
+ if(0==resNumber) {
+ return null;
+ }
+
+ int resIdx = getCurrentScreenResolutionIndex0(screenConfigHandle);
+ if(0>resIdx) {
+ return null;
+ }
+ if(resIdx>=resNumber) {
+ throw new RuntimeException("Invalid resolution index: ! "+resIdx+" < "+resNumber);
+ }
+ res = getScreenModeResolution0(dpy, screen_idx, resIdx);
+ if(null==res || 0==res.length) {
+ return null;
+ }
+ if(0>=res[0] || 0>=res[1]) {
+ throw new InternalError("invalid resolution: "+res[0]+"x"+res[1]+" for res idx "+resIdx+"/"+resNumber);
+ }
+ rate = getCurrentScreenRate0(screenConfigHandle);
+ if(0>rate) {
+ return null;
+ }
+ rot = getCurrentScreenRotation0(screenConfigHandle);
+ if(0>rot) {
+ return null;
+ }
+ } finally {
+ freeScreenConfiguration0(screenConfigHandle);
}
int[] props = new int[ScreenModeUtil.NUM_SCREEN_MODE_PROPERTIES_ALL];
int i = 0;
@@ -226,21 +237,30 @@ public class X11Screen extends ScreenImpl {
boolean done = runWithLockedDisplayHandle( new DisplayImpl.DisplayRunnable<Boolean>() {
public Boolean run(long dpy) {
boolean done = false;
- int resNumber = getNumScreenModeResolutions0(dpy, screen_idx);
- int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx);
- if(0>resIdx || resIdx>=resNumber) {
- throw new RuntimeException("Invalid resolution index: ! 0 < "+resIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode);
+ long screenConfigHandle = getScreenConfiguration0(dpy, screen_idx);
+ if(0 == screenConfigHandle) {
+ return Boolean.valueOf(done);
}
-
- final int f = screenMode.getMonitorMode().getRefreshRate();
- final int r = screenMode.getRotation();
- if( setCurrentScreenModeStart0(dpy, screen_idx, resIdx, f, r) ) {
- while(!done && System.currentTimeMillis()-t0 < SCREEN_MODE_CHANGE_TIMEOUT) {
- done = setCurrentScreenModePollEnd0(dpy, screen_idx, resIdx, f, r);
- if(!done) {
- try { Thread.sleep(10); } catch (InterruptedException e) { }
+ try {
+ int resNumber = getNumScreenModeResolutions0(dpy, screen_idx);
+ int resIdx = getScreenModesIdx2NativeIdx().get(screenModeIdx);
+ if(0>resIdx || resIdx>=resNumber) {
+ throw new RuntimeException("Invalid resolution index: ! 0 < "+resIdx+" < "+resNumber+", screenMode["+screenModeIdx+"] "+screenMode);
+ }
+
+ final int f = screenMode.getMonitorMode().getRefreshRate();
+ final int r = screenMode.getRotation();
+
+ if( setCurrentScreenModeStart0(dpy, screen_idx, screenConfigHandle, resIdx, f, r) ) {
+ while(!done && System.currentTimeMillis()-t0 < SCREEN_MODE_CHANGE_TIMEOUT) {
+ done = setCurrentScreenModePollEnd0(dpy, screen_idx, resIdx, f, r);
+ if(!done) {
+ try { Thread.sleep(10); } catch (InterruptedException e) { }
+ }
}
}
+ } finally {
+ freeScreenConfiguration0(screenConfigHandle);
}
return Boolean.valueOf(done);
}
@@ -321,11 +341,14 @@ public class X11Screen extends ScreenImpl {
private static native int[] getScreenModeRates0(long display, int screen_index, int mode_index);
- private static native int getCurrentScreenResolutionIndex0(long display, int screen_index);
- private static native int getCurrentScreenRate0(long display, int screen_index);
- private static native int getCurrentScreenRotation0(long display, int screen_index);
+ private static native long getScreenConfiguration0(long display, int screen_index);
+ private static native void freeScreenConfiguration0(long screenConfiguration);
+
+ private static native int getCurrentScreenResolutionIndex0(long screenConfiguration);
+ private static native int getCurrentScreenRate0(long screenConfiguration);
+ private static native int getCurrentScreenRotation0(long screenConfiguration);
/** needs own Display connection for XRANDR event handling */
- private static native boolean setCurrentScreenModeStart0(long display, int screen_index, int mode_index, int freq, int rot);
+ private static native boolean setCurrentScreenModeStart0(long display, int screen_index, long screenConfiguration, int mode_index, int freq, int rot);
private static native boolean setCurrentScreenModePollEnd0(long display, int screen_index, int mode_index, int freq, int rot);
}
diff --git a/src/newt/native/X11Screen.c b/src/newt/native/X11Screen.c
index 4dcb8f6f1..698eed89d 100644
--- a/src/newt/native/X11Screen.c
+++ b/src/newt/native/X11Screen.c
@@ -26,8 +26,15 @@
* or implied, of JogAmp Community.
*/
+// #define VERBOSE_ON 1
+// #define DBG_PERF 1
+
#include "X11Common.h"
+#ifdef DBG_PERF
+ #include "timespec.h"
+#endif
+
/*
* Class: jogamp_newt_driver_x11_X11Screen
* Method: GetScreen
@@ -163,16 +170,31 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getNumScreenModeRes
(JNIEnv *env, jclass clazz, jlong display, jint scrn_idx)
{
Display *dpy = (Display *) (intptr_t) display;
+#ifdef DBG_PERF
+ struct timespec t0, t1, td;
+ long td_ms;
+ timespec_now(&t0);
+#endif
if(False == NewtScreen_hasRANDR(dpy)) {
DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getNumScreenModeResolutions0: RANDR not available\n");
return 0;
}
+#ifdef DBG_PERF
+ timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td);
+ fprintf(stderr, "X11Screen_getNumScreenModeResolution0.1: %ld ms\n", td_ms); fflush(NULL);
+#endif
+
int num_sizes;
XRRScreenSize *xrrs = XRRSizes(dpy, (int)scrn_idx, &num_sizes); //get possible screen resolutions
- DBG_PRINT("getNumScreenModeResolutions0: %d\n", num_sizes);
+#ifdef DBG_PERF
+ timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td);
+ fprintf(stderr, "X11Screen_getNumScreenModeResolution0.2 (XRRSizes): %ld ms\n", td_ms); fflush(NULL);
+#endif
+
+ DBG_PRINT("getNumScreenModeResolutions0: %p:%d -> %d\n", dpy, (int)scrn_idx, num_sizes);
return num_sizes;
}
@@ -264,27 +286,61 @@ JNIEXPORT jintArray JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenModeR
/*
* Class: jogamp_newt_driver_x11_X11Screen
- * Method: getCurrentScreenRate0
- * Signature: (JI)I
+ * Method: getScreenConfiguration0
+ * Signature: (JI)J
*/
-JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRate0
- (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx)
+JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_x11_X11Screen_getScreenConfiguration0
+ (JNIEnv *env, jclass clazz, jlong display, jint screen_idx)
{
Display *dpy = (Display *) (intptr_t) display;
- Window root = RootWindow(dpy, (int)scrn_idx);
-
+ Window root = RootWindow(dpy, (int)screen_idx);
+#ifdef DBG_PERF
+ struct timespec t0, t1, td;
+ long td_ms;
+ timespec_now(&t0);
+#endif
+
if(False == NewtScreen_hasRANDR(dpy)) {
- DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRate0: RANDR not available\n");
- return -1;
+ DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getScreenConfiguration0: RANDR not available\n");
+ return 0;
}
+#ifdef DBG_PERF
+ timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td);
+ fprintf(stderr, "X11Screen_getScreenConfiguration0.1: %ld ms\n", td_ms); fflush(NULL);
+#endif
// get current resolutions and frequencies
XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root);
- short original_rate = XRRConfigCurrentRate(conf);
+#ifdef DBG_PERF
+ timespec_now(&t1); timespec_subtract(&td, &t1, &t0); td_ms = timespec_milliseconds(&td);
+ fprintf(stderr, "X11Screen_getScreenConfiguration0.2 (XRRGetScreenInfo): %ld ms\n", td_ms); fflush(NULL);
+#endif
- //free
- XRRFreeScreenConfigInfo(conf);
+ return (jlong) (intptr_t) conf;
+}
+
+/*
+ * Class: jogamp_newt_driver_x11_X11Screen
+ * Method: freeScreenConfiguration0
+ * Signature: (J)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_newt_driver_x11_X11Screen_freeScreenConfiguration0
+ (JNIEnv *env, jclass clazz, jlong screenConfiguration)
+{
+ XRRFreeScreenConfigInfo( (XRRScreenConfiguration *) (intptr_t) screenConfiguration );
+}
+
+/*
+ * Class: jogamp_newt_driver_x11_X11Screen
+ * Method: getCurrentScreenRate0
+ * Signature: (J)I
+ */
+JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRate0
+ (JNIEnv *env, jclass clazz, jlong screenConfiguration)
+{
+ XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration;
+ short original_rate = XRRConfigCurrentRate(conf);
DBG_PRINT("getCurrentScreenRate0: %d\n", (int)original_rate);
return (jint) original_rate;
@@ -293,28 +349,16 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRat
/*
* Class: jogamp_newt_driver_x11_X11Screen
* Method: getCurrentScreenRotation0
- * Signature: (JI)I
+ * Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRotation0
- (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx)
+ (JNIEnv *env, jclass clazz, jlong screenConfiguration)
{
- Display *dpy = (Display *) (intptr_t) display;
- Window root = RootWindow(dpy, (int)scrn_idx);
-
- if(False == NewtScreen_hasRANDR(dpy)) {
- DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRotation0: RANDR not available\n");
- return -1;
- }
-
- //get current resolutions and frequencies
- XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root);
-
+ XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration;
Rotation rotation;
+
XRRConfigCurrentConfiguration(conf, &rotation);
- //free
- XRRFreeScreenConfigInfo(conf);
-
return NewtScreen_XRotation2Degree(env, rotation);
}
@@ -322,60 +366,42 @@ JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenRot
/*
* Class: jogamp_newt_driver_x11_X11Screen
* Method: getCurrentScreenResolutionIndex0
- * Signature: (JI)I
+ * Signature: (J)I
*/
JNIEXPORT jint JNICALL Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenResolutionIndex0
- (JNIEnv *env, jclass clazz, jlong display, jint scrn_idx)
+ (JNIEnv *env, jclass clazz, jlong screenConfiguration)
{
- Display *dpy = (Display *) (intptr_t) display;
- Window root = RootWindow(dpy, (int)scrn_idx);
+ XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration;
- if(False == NewtScreen_hasRANDR(dpy)) {
- DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_getCurrentScreenResolutionIndex0: RANDR not available\n");
- return -1;
- }
-
- // get current resolutions and frequency configuration
- XRRScreenConfiguration *conf = XRRGetScreenInfo(dpy, root);
short original_rate = XRRConfigCurrentRate(conf);
Rotation original_rotation;
SizeID original_size_id = XRRConfigCurrentConfiguration(conf, &original_rotation);
- //free
- XRRFreeScreenConfigInfo(conf);
-
DBG_PRINT("getCurrentScreenResolutionIndex0: %d\n", (int)original_size_id);
- return (jint)original_size_id;
+ return (jint)original_size_id;
}
/*
* Class: jogamp_newt_driver_x11_X11Screen
* Method: setCurrentScreenModeStart0
- * Signature: (JIIII)Z
+ * Signature: (JIJIII)Z
*/
JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Screen_setCurrentScreenModeStart0
- (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jint resMode_idx, jint freq, jint rotation)
+ (JNIEnv *env, jclass clazz, jlong display, jint screen_idx, jlong screenConfiguration, jint resMode_idx, jint freq, jint rotation)
{
Display *dpy = (Display *) (intptr_t) display;
+ XRRScreenConfiguration *conf = (XRRScreenConfiguration *) (intptr_t) screenConfiguration;
Window root = RootWindow(dpy, (int)screen_idx);
- if(False == NewtScreen_hasRANDR(dpy)) {
- DBG_PRINT("Java_jogamp_newt_driver_x11_X11Screen_setCurrentScreenModeStart0: RANDR not available\n");
- return JNI_FALSE;
- }
-
int num_sizes;
XRRScreenSize *xrrs = XRRSizes(dpy, (int)screen_idx, &num_sizes); //get possible screen resolutions
- XRRScreenConfiguration *conf;
int rot;
if( 0 > resMode_idx || resMode_idx >= num_sizes ) {
NewtCommon_throwNewRuntimeException(env, "Invalid resolution index: ! 0 < %d < %d", resMode_idx, num_sizes);
}
- conf = XRRGetScreenInfo(dpy, root);
-
switch(rotation) {
case 0:
rot = RR_Rotate_0;
@@ -402,10 +428,6 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_x11_X11Screen_setCurrentScree
XRRSetScreenConfigAndRate(dpy, conf, root, (int)resMode_idx, rot, (short)freq, CurrentTime);
XSync(dpy, False);
- //free
- XRRFreeScreenConfigInfo(conf);
- XSync(dpy, False);
-
return JNI_TRUE;
}