summaryrefslogtreecommitdiffstats
path: root/src/nativewindow/native
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow/native')
-rw-r--r--src/nativewindow/native/ios/IOSmisc.m41
-rw-r--r--src/nativewindow/native/macosx/OSXmisc.m16
2 files changed, 26 insertions, 31 deletions
diff --git a/src/nativewindow/native/ios/IOSmisc.m b/src/nativewindow/native/ios/IOSmisc.m
index 49fe8325e..70cff4c06 100644
--- a/src/nativewindow/native/ios/IOSmisc.m
+++ b/src/nativewindow/native/ios/IOSmisc.m
@@ -252,35 +252,35 @@ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_ios_IOSUtil_GetInsets0
/*
* Class: Java_jogamp_nativewindow_ios_IOSUtil
- * Method: GetPixelScale1
- * Signature: (I)D
+ * Method: GetScreenPixelScale1
+ * Signature: (I)F
*/
-JNIEXPORT jdouble JNICALL Java_jogamp_nativewindow_ios_IOSUtil_GetPixelScale1
- (JNIEnv *env, jclass unused, jint displayID)
+JNIEXPORT jfloat JNICALL Java_jogamp_nativewindow_ios_IOSUtil_GetScreenPixelScale1
+ (JNIEnv *env, jclass unused, jint screenIdx)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
CGFloat pixelScale = 1.0; // default
- // UIScreen *screen = IOSUtil_getUIScreenByCGDirectDisplayID((CGDirectDisplayID)displayID);
- UIScreen *screen = [UIScreen mainScreen];
- if( NULL != screen ) {
-NS_DURING
- // Available >= 10.7
- pixelScale = [screen scale]; // HiDPI scaling
-NS_HANDLER
-NS_ENDHANDLER
+
+ NSArray *screens = [UIScreen screens];
+ int count = [screens count];
+ if( 0 <= screenIdx && screenIdx < count ) {
+ UIScreen * screen = (UIScreen *) [screens objectAtIndex: screenIdx];
+ if( NULL != screen ) {
+ pixelScale = [screen scale];
+ }
}
[pool release];
- return (jdouble)pixelScale;
+ return (jfloat)pixelScale;
}
/*
* Class: Java_jogamp_nativewindow_ios_IOSUtil
- * Method: GetPixelScale1
- * Signature: (J)D
+ * Method: GetScreenPixelScale1
+ * Signature: (J)F
*/
-JNIEXPORT jdouble JNICALL Java_jogamp_nativewindow_ios_IOSUtil_GetPixelScale2
+JNIEXPORT jfloat JNICALL Java_jogamp_nativewindow_ios_IOSUtil_GetScreenPixelScale2
(JNIEnv *env, jclass unused, jlong winOrView)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -302,16 +302,11 @@ JNIEXPORT jdouble JNICALL Java_jogamp_nativewindow_ios_IOSUtil_GetPixelScale2
NativewindowCommon_throwNewRuntimeException(env, "neither win nor view %p\n", nsObj);
}
- CGFloat pixelScale = 1.0; // default
-NS_DURING
- // Available >= 10.7
- pixelScale = [screen scale]; // HiDPI scaling
-NS_HANDLER
-NS_ENDHANDLER
+ CGFloat pixelScale = [screen scale];
[pool release];
- return (jdouble)pixelScale;
+ return (jfloat)pixelScale;
}
/*
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m
index fb15c43b9..1135c5fb2 100644
--- a/src/nativewindow/native/macosx/OSXmisc.m
+++ b/src/nativewindow/native/macosx/OSXmisc.m
@@ -266,10 +266,10 @@ JNIEXPORT jobject JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetInsets0
/*
* Class: Java_jogamp_nativewindow_macosx_OSXUtil
- * Method: GetPixelScale1
- * Signature: (I)D
+ * Method: GetScreenPixelScale1
+ * Signature: (I)F
*/
-JNIEXPORT jdouble JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetPixelScale1
+JNIEXPORT jfloat JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetScreenPixelScale1
(JNIEnv *env, jclass unused, jint displayID)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -285,15 +285,15 @@ NS_ENDHANDLER
}
[pool release];
- return (jdouble)pixelScale;
+ return (jfloat)pixelScale;
}
/*
* Class: Java_jogamp_nativewindow_macosx_OSXUtil
- * Method: GetPixelScale1
- * Signature: (J)D
+ * Method: GetScreenPixelScale1
+ * Signature: (J)F
*/
-JNIEXPORT jdouble JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetPixelScale2
+JNIEXPORT jfloat JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetScreenPixelScale2
(JNIEnv *env, jclass unused, jlong winOrView)
{
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
@@ -324,7 +324,7 @@ NS_ENDHANDLER
[pool release];
- return (jdouble)pixelScale;
+ return (jfloat)pixelScale;
}
/*