diff options
author | Sven Gothel <[email protected]> | 2011-10-01 01:34:15 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-10-01 01:34:15 +0200 |
commit | 1807d508a6fc9a492692fc3621a254fdbaee47fd (patch) | |
tree | ca9ed019d1c8e125a988bd3d5a8f069b184e1735 | |
parent | e29d192999c676a5e3472df6daadd14fc8b69227 (diff) |
NEWT/Android: 565, 5551 or RGBA_8888 (no RGBX/888) ; surfaceRealized() ASAP
4 files changed, 70 insertions, 39 deletions
diff --git a/src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java b/src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java index 0c5684a1f..14742734b 100644 --- a/src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java +++ b/src/android/com/jogamp/android/launcher/NEWTLauncherActivity.java @@ -66,8 +66,8 @@ public abstract class NEWTLauncherActivity extends Activity { System.setProperty("jogl.debug.GLProfile", "true"); System.setProperty("jogl.debug.GLDrawable", "true"); System.setProperty("jogl.debug.GLSLCode", "true"); - System.setProperty("jogl.debug.GLSLState", "true"); - System.setProperty("jogl.debug.DebugGL", "true"); + // System.setProperty("jogl.debug.GLSLState", "true"); + // System.setProperty("jogl.debug.DebugGL", "true"); // System.setProperty("jogl.debug.TraceGL", "true"); // System.setProperty("newt.debug", "all"); diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java b/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java index 34935e0f9..72c0bce64 100644 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java +++ b/src/newt/classes/jogamp/newt/driver/android/AndroidDisplay.java @@ -39,7 +39,7 @@ public class AndroidDisplay extends jogamp.newt.DisplayImpl { static { NEWTJNILibLoader.loadNEWT(); - if (!AndroidWindow.initIDs()) { + if (!AndroidWindow.initIDs0()) { throw new NativeWindowException("Failed to initialize Android NEWT Windowing library"); } } diff --git a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java index aff95ba96..71d257ec5 100644 --- a/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java +++ b/src/newt/classes/jogamp/newt/driver/android/AndroidWindow.java @@ -34,7 +34,6 @@ import jogamp.newt.driver.android.event.AndroidNewtEventFactory; import javax.media.nativewindow.Capabilities; import javax.media.nativewindow.CapabilitiesImmutable; -import javax.media.nativewindow.GraphicsConfigurationFactory; import javax.media.nativewindow.NativeWindowException; import javax.media.nativewindow.egl.EGLGraphicsDevice; import javax.media.nativewindow.util.Insets; @@ -124,13 +123,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { rCaps.getGreenBits()<=5 && rCaps.getBlueBits()<=5 && rCaps.getAlphaBits()==1) { - fmt = PixelFormat.RGBA_5551; - } else - if(rCaps.getRedBits()<=8 && - rCaps.getGreenBits()<=8 && - rCaps.getBlueBits()<=8 && - rCaps.getAlphaBits()==0) { - fmt = PixelFormat.RGBX_8888; + fmt = PixelFormat.RGBA_5551; // FIXME: Supported ? } else { fmt = PixelFormat.RGBA_8888; } @@ -234,7 +227,7 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { @Override protected void closeNativeImpl() { - release(surfaceHandle); + release0(surfaceHandle); surface = null; surfaceHandle = 0; eglSurface = 0; @@ -308,7 +301,9 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { // public void surfaceCreated(SurfaceHolder holder) { - Log.d(MD.TAG, "surfaceCreated"); + Log.d(MD.TAG, "surfaceCreated: "+x+"/"+y+" "+width+"x"+height); + surfaceRealized(holder); + Log.d(MD.TAG, "surfaceCreated: X"); } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { @@ -326,23 +321,43 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { getScreen().getCurrentScreenMode(); // if ScreenMode changed .. trigger ScreenMode event if(0 == surfaceHandle) { - this.format = format; - capsByFormat = (GLCapabilitiesImmutable) fixCaps(format, getRequestedCapabilities()); - // capsByFormat = (GLCapabilitiesImmutable) fixCapsAlpha(getRequestedCapabilities()); - // capsByFormat = (GLCapabilitiesImmutable) getRequestedCapabilities(); - surface = holder.getSurface(); - surfaceHandle = getSurfaceHandle(surface); - acquire(surfaceHandle); - int surfaceVisualID = getSurfaceVisualID(surfaceHandle); - Log.d(MD.TAG, "surfaceChanged (create): isValid: "+surface.isValid()+ - ", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+", surfaceVisualID: "+surfaceVisualID); - positionChanged(false, 0, 0); - sizeChanged(false, width, height, false); - if(isVisible()) { - setVisible(true); + surfaceRealized(holder); + } else { + if(0>x || 0>y) { + x = 0; + y = 0; + positionChanged(false, 0, 0); } + sizeChanged(false, width, height, false); } windowRepaint(0, 0, width, height); + Log.d(MD.TAG, "surfaceChanged: X"); + } + + private void surfaceRealized(SurfaceHolder holder) { + surface = holder.getSurface(); + surfaceHandle = getSurfaceHandle0(surface); + acquire0(surfaceHandle); + format = getSurfaceVisualID0(surfaceHandle); + if(0>x || 0>y) { + x = 0; + y = 0; + positionChanged(false, 0, 0); + } + sizeChanged(false, getWidth0(surfaceHandle), getHeight0(surfaceHandle), false); + + Log.d(MD.TAG, "surfaceRealized: isValid: "+surface.isValid()+ + ", new surfaceHandle 0x"+Long.toHexString(surfaceHandle)+", format: "+format+ + ", "+x+"/"+y+" "+width+"x"+height); + + capsByFormat = (GLCapabilitiesImmutable) fixCaps(format, getRequestedCapabilities()); + // capsByFormat = (GLCapabilitiesImmutable) fixCapsAlpha(getRequestedCapabilities()); + // capsByFormat = (GLCapabilitiesImmutable) getRequestedCapabilities(); + + if(isVisible()) { + setVisible(true); + } + Log.d(MD.TAG, "surfaceRealized: X"); } public void surfaceDestroyed(SurfaceHolder holder) { @@ -372,11 +387,13 @@ public class AndroidWindow extends jogamp.newt.WindowImpl implements Callback2 { //---------------------------------------------------------------------- // Internals only // - protected static native boolean initIDs(); - protected static native long getSurfaceHandle(Surface surface); - protected static native int getSurfaceVisualID(long surfaceHandle); - protected static native void setSurfaceVisualID(long surfaceHandle, int nativeVisualID); - protected static native void acquire(long surfaceHandle); - protected static native void release(long surfaceHandle); + protected static native boolean initIDs0(); + protected static native long getSurfaceHandle0(Surface surface); + protected static native int getSurfaceVisualID0(long surfaceHandle); + protected static native void setSurfaceVisualID0(long surfaceHandle, int nativeVisualID); + protected static native int getWidth0(long surfaceHandle); + protected static native int getHeight0(long surfaceHandle); + protected static native void acquire0(long surfaceHandle); + protected static native void release0(long surfaceHandle); } diff --git a/src/newt/native/AndroidWindow.c b/src/newt/native/AndroidWindow.c index d75bc27d7..fa5765672 100644 --- a/src/newt/native/AndroidWindow.c +++ b/src/newt/native/AndroidWindow.c @@ -23,42 +23,56 @@ #endif -JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_android_AndroidWindow_getSurfaceHandle +JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_android_AndroidWindow_getSurfaceHandle0 (JNIEnv *env, jclass clazz, jobject surface) { ANativeWindow * anw = ANativeWindow_fromSurface(env, surface); return (jlong) (intptr_t) anw; } -JNIEXPORT jint JNICALL Java_jogamp_newt_driver_android_AndroidWindow_getSurfaceVisualID +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_android_AndroidWindow_getSurfaceVisualID0 (JNIEnv *env, jclass clazz, jlong surfaceHandle) { ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; return (jint) ANativeWindow_getFormat(anw); } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_AndroidWindow_setSurfaceVisualID +JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_AndroidWindow_setSurfaceVisualID0 (JNIEnv *env, jclass clazz, jlong surfaceHandle, jint nativeVisualID) { ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; ANativeWindow_setBuffersGeometry(anw, 0, 0, nativeVisualID); } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_AndroidWindow_acquire +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_android_AndroidWindow_getWidth0 + (JNIEnv *env, jclass clazz, jlong surfaceHandle) +{ + ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; + return (jint) ANativeWindow_getWidth(anw); +} + +JNIEXPORT jint JNICALL Java_jogamp_newt_driver_android_AndroidWindow_getHeight0 + (JNIEnv *env, jclass clazz, jlong surfaceHandle) +{ + ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; + return (jint) ANativeWindow_getHeight(anw); +} + +JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_AndroidWindow_acquire0 (JNIEnv *env, jclass clazz, jlong surfaceHandle) { ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; ANativeWindow_acquire(anw); } -JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_AndroidWindow_release +JNIEXPORT void JNICALL Java_jogamp_newt_driver_android_AndroidWindow_release0 (JNIEnv *env, jclass clazz, jlong surfaceHandle) { ANativeWindow * anw = (ANativeWindow *) (intptr_t) surfaceHandle; ANativeWindow_release(anw); } -JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_android_AndroidWindow_initIDs +JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_android_AndroidWindow_initIDs0 (JNIEnv *env, jclass clazz) { DBG_PRINT( "initIDs ok\n" ); |