diff options
author | Sven Gothel <[email protected]> | 2014-05-21 08:53:54 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-05-21 08:53:54 +0200 |
commit | f9a00b91dcd146c72a50237b62270f33bd0da98e (patch) | |
tree | f4387da868608cea5066ce3a8cb9039a16b529de /src/nativewindow/native | |
parent | 0ffba122ea5c4b8cc247234ca9f48ccfcce833cd (diff) |
Bug 742 HiDPI: [Core API Change] Distinguish window-units and pixel-units; Add HiDPI for AWT GLCanvas w/ OSX CALayer
Core API Change:
To support HiDPI thoroughly in JOGL (NativeWindow, JOGL, NEWT)
we need to separate window- and pixel units.
NativeWindow and NativeSurface now have distinguished
access methods for window units and pixel units.
NativeWindow: Using window units
- getWindowWidth() * NEW Method *
- getWindowHeight() * NEW Method *
- getX(), getY(), ...
NativeSurface: Using pixel units
- getWidth() -> getSurfaceWidth() * RENAMED *
- getHeight() -> getSurfaceHeight() * RENAMED *
GLDrawable: Using pixel units
- getWidth() -> getSurfaceWidth() * RENAMED, aligned w/ NativeSurface *
- getHeight() -> getSurfaceHeight() * RENAMED, aligned w/ NativeSurface *
Above changes also removes API collision w/ other windowing TK,
e.g. AWT's getWidth()/getHeight() in GLCanvas
and the same method names in GLDrawable before this change.
+++
Now preliminary 'working':
- AWT GLCanvas
- AWT GLJPanel
Tested manually on OSX w/ and w/o HiDPI Retina:
java com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2AWT -manual -noanim -time 1000000
java com.jogamp.opengl.test.junit.jogl.demos.es2.awt.TestGearsES2GLJPanelAWT -manual -noanim -time 1000000
+++
TODO:
- NEWT
- Change Window.setSize(..) to use pixel units ?
- OSX HiDPI support
- Testing ..
- API refinement
Diffstat (limited to 'src/nativewindow/native')
-rw-r--r-- | src/nativewindow/native/macosx/OSXmisc.m | 33 |
1 files changed, 25 insertions, 8 deletions
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m index d95d1cdbf..15547ffee 100644 --- a/src/nativewindow/native/macosx/OSXmisc.m +++ b/src/nativewindow/native/macosx/OSXmisc.m @@ -41,7 +41,7 @@ #include <jawt_md.h> -// #define VERBOSE 1 +#define VERBOSE 1 // #ifdef VERBOSE // #define DBG_PRINT(...) NSLog(@ ## __VA_ARGS__) @@ -544,19 +544,27 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetNSWindow0 /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: CreateCALayer0 - * Signature: (II)J + * Signature: (IIF)J */ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 - (JNIEnv *env, jclass unused, jint width, jint height) + (JNIEnv *env, jclass unused, jint width, jint height, jfloat contentsScale) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; MyCALayer* layer = [[MyCALayer alloc] init]; - DBG_PRINT("CALayer::CreateCALayer.0: root %p 0/0 %dx%d (refcnt %d)\n", layer, (int)width, (int)height, (int)[layer retainCount]); + DBG_PRINT("CALayer::CreateCALayer.0: root %p 0/0 %dx%d @ scale %lf (refcnt %d)\n", layer, (int)width, (int)height, (double)contentsScale, (int)[layer retainCount]); // avoid zero size if(0 == width) { width = 32; } if(0 == height) { height = 32; } + if( 1.0 != contentsScale ) { +NS_DURING + // Available >= 10.7 + [layer setContentsScale: (CGFloat)contentsScale]; +NS_HANDLER +NS_ENDHANDLER + } + // initial dummy size ! CGRect lFrame = [layer frame]; lFrame.origin.x = 0; @@ -580,10 +588,10 @@ JNIEXPORT jlong JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_CreateCALayer0 /* * Class: Java_jogamp_nativewindow_macosx_OSXUtil * Method: AddCASublayer0 - * Signature: (JJIIIII)V + * Signature: (JJIIIIIF)V */ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 - (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jint x, jint y, jint width, jint height, jint caLayerQuirks) + (JNIEnv *env, jclass unused, jlong rootCALayer, jlong subCALayer, jint x, jint y, jint width, jint height, jfloat contentsScale, jint caLayerQuirks) { NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; MyCALayer* rootLayer = (MyCALayer*) ((intptr_t) rootCALayer); @@ -596,9 +604,18 @@ JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_AddCASublayer0 [subLayer retain]; // Pairs w/ RemoveCASublayer CGRect lRectRoot = [rootLayer frame]; - DBG_PRINT("CALayer::AddCASublayer0.0: Quirks %d, Root %p (refcnt %d), Sub %p (refcnt %d), frame0: %lf/%lf %lfx%lf\n", + + // Available >= 10.7 + DBG_PRINT("CALayer::AddCASublayer0.0: Quirks %d, Root %p (refcnt %d), Sub %p (refcnt %d), frame0: %lf/%lf %lfx%lf scale %lf\n", caLayerQuirks, rootLayer, (int)[rootLayer retainCount], subLayer, (int)[subLayer retainCount], - lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height); + lRectRoot.origin.x, lRectRoot.origin.y, lRectRoot.size.width, lRectRoot.size.height, (float)contentsScale); + + if( 1.0 != contentsScale ) { +NS_DURING + [subLayer setContentsScale: (CGFloat)contentsScale]; +NS_HANDLER +NS_ENDHANDLER + } [subLayer setFrame:lRectRoot]; [rootLayer addSublayer:subLayer]; |