From fdaabdc24976a0ff07ecbb8823ea52e13eb4230d Mon Sep 17 00:00:00 2001 From: Michael Pfaff Date: Tue, 22 Mar 2022 13:53:08 -0400 Subject: [PATCH] Patch macOS build-script --- platform_build/macosx_ant/build.xml | 81 +++++++++---------- .../common/org_lwjgl_opengl_AWTSurfaceLock.c | 2 +- src/native/macosx/context.h | 2 +- src/native/macosx/context.m | 19 +++++ .../org_lwjgl_opengl_MacOSXCanvasPeerInfo.m | 19 +++-- 5 files changed, 73 insertions(+), 50 deletions(-) diff --git a/platform_build/macosx_ant/build.xml b/platform_build/macosx_ant/build.xml index 93177b69..a1762a0f 100644 --- a/platform_build/macosx_ant/build.xml +++ b/platform_build/macosx_ant/build.xml @@ -15,43 +15,34 @@ - + + - - + + + + + - + - - + + - + - - - - - - - - - - - - - - - - - - - + - + + + + + + @@ -66,16 +57,21 @@ + + + + + + - + - - + @@ -111,7 +107,7 @@ - + @@ -133,16 +129,19 @@ - + - + + - + + + @@ -165,12 +164,12 @@ - + - + @@ -179,12 +178,12 @@ - + - + @@ -200,7 +199,7 @@ - + @@ -209,7 +208,7 @@ - + @@ -219,4 +218,4 @@ - \ No newline at end of file + diff --git a/src/native/common/org_lwjgl_opengl_AWTSurfaceLock.c b/src/native/common/org_lwjgl_opengl_AWTSurfaceLock.c index ebb5dacd..a908ce5e 100644 --- a/src/native/common/org_lwjgl_opengl_AWTSurfaceLock.c +++ b/src/native/common/org_lwjgl_opengl_AWTSurfaceLock.c @@ -40,7 +40,7 @@ #include #ifdef __MACH__ -#include +#include #else #include #endif diff --git a/src/native/macosx/context.h b/src/native/macosx/context.h index 2753d3e5..733ab198 100644 --- a/src/native/macosx/context.h +++ b/src/native/macosx/context.h @@ -117,7 +117,7 @@ typedef struct { @interface GLLayer : CAOpenGLLayer { @public - JAWT_MacOSXDrawingSurfaceInfo *macosx_dsi; + JAWT_DrawingSurfaceInfo *macosx_dsi; JAWT_Rectangle canvasBounds; MacOSXWindowInfo *window_info; bool setViewport; diff --git a/src/native/macosx/context.m b/src/native/macosx/context.m index 1bc8c359..34817774 100644 --- a/src/native/macosx/context.m +++ b/src/native/macosx/context.m @@ -87,6 +87,25 @@ void extgl_Close(void) } } +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 + size_t CGDisplayBitsPerPixel(CGDirectDisplayID display) { + CGDisplayModeRef mode = CGDisplayCopyDisplayMode(display); + size_t depth = 0; + + CFStringRef pixEnc = CGDisplayModeCopyPixelEncoding(mode); + if(CFStringCompare(pixEnc, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) + depth = 32; + else if(CFStringCompare(pixEnc, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) + depth = 16; + else if(CFStringCompare(pixEnc, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) + depth = 8; + + return depth; + } +#else + // CGDisplayBitsPerPixel is defined +#endif + NSOpenGLPixelFormat *choosePixelFormat(JNIEnv *env, jobject pixel_format, bool gl32, bool use_display_bpp, bool support_window, bool support_pbuffer, bool double_buffered) { int bpp; jclass cls_pixel_format = (*env)->GetObjectClass(env, pixel_format); diff --git a/src/native/macosx/org_lwjgl_opengl_MacOSXCanvasPeerInfo.m b/src/native/macosx/org_lwjgl_opengl_MacOSXCanvasPeerInfo.m index 203e1cc0..aebb494b 100644 --- a/src/native/macosx/org_lwjgl_opengl_MacOSXCanvasPeerInfo.m +++ b/src/native/macosx/org_lwjgl_opengl_MacOSXCanvasPeerInfo.m @@ -53,7 +53,7 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nInitHandle MacOSXPeerInfo *peer_info = (MacOSXPeerInfo *)(*env)->GetDirectBufferAddress(env, peer_info_handle); AWTSurfaceLock *surface = (AWTSurfaceLock *)(*env)->GetDirectBufferAddress(env, lock_buffer_handle); - JAWT_MacOSXDrawingSurfaceInfo *macosx_dsi = (JAWT_MacOSXDrawingSurfaceInfo *)surface->dsi->platformInfo; + JAWT_DrawingSurfaceInfo *macosx_dsi = (JAWT_DrawingSurfaceInfo *)surface->dsi->platformInfo; // force CALayer usage or check if CALayer is supported (i.e. on Java 5 and Java 6) if(forceCALayer || (surface->awt.version & 0x80000000)) { //JAWT_MACOSX_USE_CALAYER) { @@ -93,11 +93,16 @@ JNIEXPORT jobject JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nInitHandle return window_handle; } } - - // no CALayer support, fallback to using legacy method of getting the NSView of an AWT Canvas - peer_info->parent = macosx_dsi->cocoaViewRef; - peer_info->isCALayer = false; - peer_info->isWindowed = true; + + // no CALayer support + #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 + throwException(env, "No CALayer support and no support legacy for getting NSView of an AWT Canvas"); + #else + // fallback to using legacy method of getting the NSView of an AWT Canvas + peer_info->parent = macosx_dsi->cocoaViewRef; + peer_info->isCALayer = false; + peer_info->isWindowed = true; + #endif [pool release]; return NULL; @@ -335,4 +340,4 @@ JNIEXPORT void JNICALL Java_org_lwjgl_opengl_MacOSXCanvasPeerInfo_nSetLayerBound } -@end \ No newline at end of file +@end