aboutsummaryrefslogtreecommitdiffstats
path: root/src/nativewindow
diff options
context:
space:
mode:
Diffstat (limited to 'src/nativewindow')
-rw-r--r--src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java6
-rw-r--r--src/nativewindow/native/macosx/OSXmisc.m40
2 files changed, 43 insertions, 3 deletions
diff --git a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
index e847279e1..e06a68953 100644
--- a/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
+++ b/src/nativewindow/classes/jogamp/nativewindow/macosx/OSXUtil.java
@@ -150,6 +150,11 @@ public class OSXUtil implements ToolkitProperties {
return 1.0f; // default
}
}
+ public static void SetWindowPixelScale(final long windowOrView, final float reqPixelScale) {
+ if( 0 != windowOrView ) {
+ SetWindowPixelScale1(windowOrView, reqPixelScale);
+ }
+ }
public static long CreateNSWindow(final int x, final int y, final int width, final int height) {
final long res[] = { 0 };
@@ -436,6 +441,7 @@ public class OSXUtil implements ToolkitProperties {
private static native float GetScreenPixelScale1(int displayID);
private static native float GetScreenPixelScale2(long windowOrView);
private static native float GetWindowPixelScale1(long windowOrView);
+ private static native void SetWindowPixelScale1(final long windowOrView, final float reqPixelScale);
private static native long CreateNSWindow0(int x, int y, int width, int height);
private static native void DestroyNSWindow0(long nsWindow);
private static native long GetNSView0(long nsWindow);
diff --git a/src/nativewindow/native/macosx/OSXmisc.m b/src/nativewindow/native/macosx/OSXmisc.m
index 8cbfde8ed..091b1a67e 100644
--- a/src/nativewindow/native/macosx/OSXmisc.m
+++ b/src/nativewindow/native/macosx/OSXmisc.m
@@ -358,16 +358,13 @@ JNIEXPORT jfloat JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_GetWindowPixelS
NSObject *nsObj = (NSObject*) (intptr_t) winOrView;
NSWindow* win = NULL;
NSView* view = NULL;
- NSScreen *screen = NULL;
if( [nsObj isKindOfClass:[NSWindow class]] ) {
win = (NSWindow*) nsObj;
view = [win contentView];
- screen = [win screen];
} else if( nsObj != NULL && [nsObj isKindOfClass:[NSView class]] ) {
view = (NSView*) nsObj;
win = [view window];
- screen = [win screen];
} else {
NativewindowCommon_throwNewRuntimeException(env, "neither win nor view %p\n", nsObj);
}
@@ -390,6 +387,43 @@ NS_ENDHANDLER
/*
* Class: Java_jogamp_nativewindow_macosx_OSXUtil
+ * Method: SetWindowPixelScale1
+ * Signature: (JF)V
+ */
+JNIEXPORT void JNICALL Java_jogamp_nativewindow_macosx_OSXUtil_SetWindowPixelScale1
+ (JNIEnv *env, jclass unused, jlong winOrView, jfloat reqPixelScale)
+{
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+
+ NSObject *nsObj = (NSObject*) (intptr_t) winOrView;
+ NSWindow* win = NULL;
+ NSView* view = NULL;
+
+ if( [nsObj isKindOfClass:[NSWindow class]] ) {
+ win = (NSWindow*) nsObj;
+ view = [win contentView];
+ } else if( nsObj != NULL && [nsObj isKindOfClass:[NSView class]] ) {
+ view = (NSView*) nsObj;
+ win = [view window];
+ } else {
+ NativewindowCommon_throwNewRuntimeException(env, "neither win nor view %p\n", nsObj);
+ }
+
+NS_DURING
+ // HiDPI scaling: Setup - Available >= 10.7
+ if( 1.0 == reqPixelScale ) {
+ [view setWantsBestResolutionOpenGLSurface: NO];
+ } else {
+ [view setWantsBestResolutionOpenGLSurface: YES];
+ }
+NS_HANDLER
+NS_ENDHANDLER
+
+ [pool release];
+}
+
+/*
+ * Class: Java_jogamp_nativewindow_macosx_OSXUtil
* Method: CreateNSWindow0
* Signature: (IIIIZ)J
*/