(OSX) Fix PowerPC build

This commit is contained in:
twinaphex 2021-01-17 05:02:07 +01:00
parent f6833cf595
commit 1e9f6f175e
10 changed files with 56 additions and 64 deletions

View File

@ -75,7 +75,7 @@
_inflightSemaphore = dispatch_semaphore_create(MAX_INFLIGHT); _inflightSemaphore = dispatch_semaphore_create(MAX_INFLIGHT);
_device = d; _device = d;
_layer = layer; _layer = layer;
#if TARGET_OS_OSX #ifdef OSX
_layer.framebufferOnly = NO; _layer.framebufferOnly = NO;
_layer.displaySyncEnabled = YES; _layer.displaySyncEnabled = YES;
#endif #endif
@ -166,14 +166,14 @@
- (void)setDisplaySyncEnabled:(bool)displaySyncEnabled - (void)setDisplaySyncEnabled:(bool)displaySyncEnabled
{ {
#if TARGET_OS_OSX #ifdef OSX
_layer.displaySyncEnabled = displaySyncEnabled; _layer.displaySyncEnabled = displaySyncEnabled;
#endif #endif
} }
- (bool)displaySyncEnabled - (bool)displaySyncEnabled
{ {
#if TARGET_OS_OSX #ifdef OSX
return _layer.displaySyncEnabled; return _layer.displaySyncEnabled;
#else #else
return NO; return NO;
@ -646,7 +646,7 @@
if (_blitCommandBuffer) if (_blitCommandBuffer)
{ {
#if TARGET_OS_OSX #ifdef OSX
if (_captureEnabled) if (_captureEnabled)
{ {
id<MTLBlitCommandEncoder> bce = [_blitCommandBuffer blitCommandEncoder]; id<MTLBlitCommandEncoder> bce = [_blitCommandBuffer blitCommandEncoder];
@ -741,14 +741,13 @@ static const NSUInteger kConstantAlignment = 4;
- (void)commitRanges - (void)commitRanges
{ {
#if TARGET_OS_OSX #ifdef OSX
for (BufferNode *n = _head; n != nil; n = n.next) BufferNode *n;
for (n = _head; n != nil; n = n.next)
{ {
if (n.allocated > 0) if (n.allocated > 0)
{
[n.src didModifyRange:NSMakeRange(0, n.allocated)]; [n.src didModifyRange:NSMakeRange(0, n.allocated)];
} }
}
#endif #endif
} }
@ -785,9 +784,7 @@ static const NSUInteger kConstantAlignment = 4;
NSUInteger blockLen = _blockLen; NSUInteger blockLen = _blockLen;
if (length > blockLen) if (length > blockLen)
{
blockLen = length; blockLen = length;
}
_current.next = [[BufferNode alloc] initWithBuffer:[_device newBufferWithLength:blockLen options:opts]]; _current.next = [[BufferNode alloc] initWithBuffer:[_device newBufferWithLength:blockLen options:opts]];
if (!_current.next) if (!_current.next)

View File

@ -23,7 +23,7 @@
#else #else
#include <ApplicationServices/ApplicationServices.h> #include <ApplicationServices/ApplicationServices.h>
#endif #endif
#if TARGET_OS_OSX #ifdef OSX
#include <OpenGL/CGLTypes.h> #include <OpenGL/CGLTypes.h>
#include <OpenGL/OpenGL.h> #include <OpenGL/OpenGL.h>
#include <AppKit/NSScreen.h> #include <AppKit/NSScreen.h>
@ -114,7 +114,7 @@ void *nsview_get_ptr(void)
void nsview_set_ptr(CocoaView *p) { g_instance = p; } void nsview_set_ptr(CocoaView *p) { g_instance = p; }
#if TARGET_OS_OSX #ifdef OSX
static NSOpenGLPixelFormat* g_format; static NSOpenGLPixelFormat* g_format;
void *glcontext_get_ptr(void) { return (BRIDGE void *)g_context; } void *glcontext_get_ptr(void) { return (BRIDGE void *)g_context; }
#endif #endif
@ -232,7 +232,7 @@ float get_backing_scale_factor(void)
return backing_scale_def; return backing_scale_def;
backing_scale_def = 1.0f; backing_scale_def = 1.0f;
#if TARGET_OS_OSX #ifdef OSX
{ {
id nsscreen = objc_getClass("NSScreen"); id nsscreen = objc_getClass("NSScreen");
SEL selector = sel_registerName("backingScaleFactor"); SEL selector = sel_registerName("backingScaleFactor");
@ -259,7 +259,7 @@ void cocoagl_gfx_ctx_update(void)
{ {
case GFX_CTX_OPENGL_API: case GFX_CTX_OPENGL_API:
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(HAVE_OPENGL_CORE) #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(HAVE_OPENGL_CORE)
#if TARGET_OS_OSX #ifdef OSX
#if MAC_OS_X_VERSION_10_7 #if MAC_OS_X_VERSION_10_7
CGLUpdateContext(g_hw_ctx.CGLContextObj); CGLUpdateContext(g_hw_ctx.CGLContextObj);
CGLUpdateContext(g_context.CGLContextObj); CGLUpdateContext(g_context.CGLContextObj);
@ -289,14 +289,12 @@ static void cocoagl_gfx_ctx_destroy(void *data)
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(HAVE_OPENGL_CORE) #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(HAVE_OPENGL_CORE)
[GLContextClass clearCurrentContext]; [GLContextClass clearCurrentContext];
#if TARGET_OS_OSX #ifdef OSX
[g_context clearDrawable]; [g_context clearDrawable];
RELEASE(g_context); RELEASE(g_context);
RELEASE(g_format); RELEASE(g_format);
if (g_hw_ctx) if (g_hw_ctx)
{
[g_hw_ctx clearDrawable]; [g_hw_ctx clearDrawable];
}
RELEASE(g_hw_ctx); RELEASE(g_hw_ctx);
#endif #endif
[GLContextClass clearCurrentContext]; [GLContextClass clearCurrentContext];
@ -325,7 +323,7 @@ static enum gfx_ctx_api cocoagl_gfx_ctx_get_api(void *data) { return cocoagl_api
static void cocoagl_gfx_ctx_show_mouse(void *data, bool state) static void cocoagl_gfx_ctx_show_mouse(void *data, bool state)
{ {
#if TARGET_OS_OSX #ifdef OSX
if (state) if (state)
[NSCursor unhide]; [NSCursor unhide];
else else
@ -361,7 +359,7 @@ float cocoagl_gfx_ctx_get_native_scale(void)
return ret; return ret;
} }
#if TARGET_OS_OSX #ifdef OSX
static void cocoagl_gfx_ctx_update_title(void *data) static void cocoagl_gfx_ctx_update_title(void *data)
{ {
const ui_window_t *window = ui_companion_driver_get_window_ptr(); const ui_window_t *window = ui_companion_driver_get_window_ptr();
@ -385,7 +383,7 @@ static bool cocoagl_gfx_ctx_get_metrics(
float *value) float *value)
{ {
RAScreen *screen = (BRIDGE RAScreen*)get_chosen_screen(); RAScreen *screen = (BRIDGE RAScreen*)get_chosen_screen();
#if TARGET_OS_OSX #ifdef OSX
NSDictionary *description = [screen deviceDescription]; NSDictionary *description = [screen deviceDescription];
NSSize display_pixel_size = [[description objectForKey:NSDeviceSize] sizeValue]; NSSize display_pixel_size = [[description objectForKey:NSDeviceSize] sizeValue];
CGSize display_physical_size = CGDisplayScreenSize( CGSize display_physical_size = CGDisplayScreenSize(
@ -397,7 +395,7 @@ static bool cocoagl_gfx_ctx_get_metrics(
float physical_height = display_physical_size.height; float physical_height = display_physical_size.height;
float scale = get_backing_scale_factor(); float scale = get_backing_scale_factor();
float dpi = (display_width/ physical_width) * 25.4f * scale; float dpi = (display_width/ physical_width) * 25.4f * scale;
#elif defined(HAVE_COCOATOUCH) #else
float scale = cocoagl_gfx_ctx_get_native_scale(); float scale = cocoagl_gfx_ctx_get_native_scale();
CGRect screen_rect = [screen bounds]; CGRect screen_rect = [screen bounds];
float display_height = screen_rect.size.height; float display_height = screen_rect.size.height;
@ -474,7 +472,7 @@ static void cocoagl_gfx_ctx_get_video_size(void *data,
unsigned* width, unsigned* height) unsigned* width, unsigned* height)
{ {
float screenscale = cocoagl_gfx_ctx_get_native_scale(); float screenscale = cocoagl_gfx_ctx_get_native_scale();
#if TARGET_OS_OSX #ifdef OSX
CGRect size, cgrect; CGRect size, cgrect;
GLsizei backingPixelWidth, backingPixelHeight; GLsizei backingPixelWidth, backingPixelHeight;
#if defined(HAVE_COCOA_METAL) #if defined(HAVE_COCOA_METAL)
@ -620,10 +618,10 @@ static void cocoagl_gfx_ctx_swap_buffers(void *data)
if (!(--cocoa_ctx->fast_forward_skips < 0)) if (!(--cocoa_ctx->fast_forward_skips < 0))
return; return;
#if TARGET_OS_OSX #ifdef OSX
[g_context flushBuffer]; [g_context flushBuffer];
[g_hw_ctx flushBuffer]; [g_hw_ctx flushBuffer];
#elif defined(HAVE_COCOATOUCH) #else
if (g_view) if (g_view)
[g_view display]; [g_view display];
#endif #endif
@ -694,7 +692,7 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data,
CocoaView *g_view = (CocoaView*)nsview_get_ptr(); CocoaView *g_view = (CocoaView*)nsview_get_ptr();
#endif #endif
cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data; cocoa_ctx_data_t *cocoa_ctx = (cocoa_ctx_data_t*)data;
#if TARGET_OS_OSX #ifdef OSX
static bool static bool
has_went_fullscreen = false; has_went_fullscreen = false;
cocoa_ctx->width = width; cocoa_ctx->width = width;
@ -706,7 +704,7 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data,
case GFX_CTX_OPENGL_API: case GFX_CTX_OPENGL_API:
case GFX_CTX_OPENGL_ES_API: case GFX_CTX_OPENGL_ES_API:
{ {
#if TARGET_OS_OSX #ifdef OSX
if ([g_view respondsToSelector: @selector(setWantsBestResolutionOpenGLSurface:)]) if ([g_view respondsToSelector: @selector(setWantsBestResolutionOpenGLSurface:)])
[g_view setWantsBestResolutionOpenGLSurface:YES]; [g_view setWantsBestResolutionOpenGLSurface:YES];
@ -782,7 +780,7 @@ static bool cocoagl_gfx_ctx_set_video_mode(void *data,
break; break;
} }
#if TARGET_OS_OSX #ifdef OSX
/* TODO: Screen mode support. */ /* TODO: Screen mode support. */
if (fullscreen) if (fullscreen)
{ {
@ -917,7 +915,7 @@ const gfx_ctx_driver_t gfx_ctx_cocoagl = {
NULL, /* get_video_output_next */ NULL, /* get_video_output_next */
cocoagl_gfx_ctx_get_metrics, cocoagl_gfx_ctx_get_metrics,
NULL, /* translate_aspect */ NULL, /* translate_aspect */
#if TARGET_OS_OSX #ifdef OSX
cocoagl_gfx_ctx_update_title, cocoagl_gfx_ctx_update_title,
#else #else
NULL, /* update_title */ NULL, /* update_title */

View File

@ -776,15 +776,12 @@ INPUT
#endif #endif
#if defined(HAVE_LIBSHAKE) #if defined(HAVE_LIBSHAKE)
#if TARGET_OS_OSX
#include "../deps/libShake/src/common/error.c" #include "../deps/libShake/src/common/error.c"
#include "../deps/libShake/src/common/helpers.c" #include "../deps/libShake/src/common/helpers.c"
#include "../deps/libShake/src/common/presets.c" #include "../deps/libShake/src/common/presets.c"
#if defined(OSX)
#include "../deps/libShake/src/osx/shake.c" #include "../deps/libShake/src/osx/shake.c"
#elif defined(__linux__) || (defined(BSD) && !defined(__MACH__)) #elif defined(__linux__) || (defined(BSD) && !defined(__MACH__))
#include "../deps/libShake/src/common/error.c"
#include "../deps/libShake/src/common/helpers.c"
#include "../deps/libShake/src/common/presets.c"
#include "../deps/libShake/src/linux/shake.c" #include "../deps/libShake/src/linux/shake.c"
#endif #endif
#endif #endif

View File

@ -32,18 +32,14 @@
#include "../ui/drivers/cocoa/cocoa_common.m" #include "../ui/drivers/cocoa/cocoa_common.m"
#include "../gfx/drivers_context/cocoa_gl_ctx.m" #include "../gfx/drivers_context/cocoa_gl_ctx.m"
#if defined(HAVE_COCOATOUCH) #if defined(OSX)
#include "../ui/drivers/ui_cocoatouch.m"
#else
#if TARGET_OS_OSX
#include "../ui/drivers/cocoa/ui_cocoa_window.m" #include "../ui/drivers/cocoa/ui_cocoa_window.m"
#include "../ui/drivers/cocoa/ui_cocoa_browser_window.m" #include "../ui/drivers/cocoa/ui_cocoa_browser_window.m"
#include "../ui/drivers/cocoa/ui_cocoa_application.m" #include "../ui/drivers/cocoa/ui_cocoa_application.m"
#include "../ui/drivers/cocoa/ui_cocoa_msg_window.m" #include "../ui/drivers/cocoa/ui_cocoa_msg_window.m"
#include "../ui/drivers/ui_cocoa.m" #include "../ui/drivers/ui_cocoa.m"
#endif #else
#include "../ui/drivers/ui_cocoatouch.m"
#endif #endif
#endif #endif

View File

@ -1152,7 +1152,7 @@ static const ui_companion_driver_t *ui_companion_drivers[] = {
#if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__) #if defined(_WIN32) && !defined(_XBOX) && !defined(__WINRT__)
&ui_companion_win32, &ui_companion_win32,
#endif #endif
#if TARGET_OS_OSX #if defined(OSX)
&ui_companion_cocoa, &ui_companion_cocoa,
#endif #endif
&ui_companion_null, &ui_companion_null,

View File

@ -86,7 +86,7 @@ id apple_platform;
} }
#endif #endif
#if TARGET_OS_OSX #ifdef OSX
@property(nonatomic, retain) NSWindow IBOutlet *window; @property(nonatomic, retain) NSWindow IBOutlet *window;
@end @end

View File

@ -40,7 +40,7 @@
#define RAScreen NSScreen #define RAScreen NSScreen
#endif #endif
#if TARGET_OS_OSX #if defined(OSX)
#include <AppKit/AppKit.h> #include <AppKit/AppKit.h>
#endif #endif
@ -75,7 +75,7 @@ typedef struct
} apple_frontend_settings_t; } apple_frontend_settings_t;
extern apple_frontend_settings_t apple_frontend_settings; extern apple_frontend_settings_t apple_frontend_settings;
#if TARGET_OS_OSX #if defined(OSX)
@interface CocoaView : NSView @interface CocoaView : NSView
+ (CocoaView*)get; + (CocoaView*)get;

View File

@ -42,7 +42,7 @@ void *glkitview_init(void);
@implementation CocoaView @implementation CocoaView
#if TARGET_OS_OSX #if defined(OSX)
#ifdef HAVE_COCOA_METAL #ifdef HAVE_COCOA_METAL
- (BOOL)layer:(CALayer *)layer shouldInheritContentsScale:(CGFloat)newScale fromWindow:(NSWindow *)window { return YES; } - (BOOL)layer:(CALayer *)layer shouldInheritContentsScale:(CGFloat)newScale fromWindow:(NSWindow *)window { return YES; }
#endif #endif
@ -64,7 +64,7 @@ void *glkitview_init(void);
{ {
self = [super init]; self = [super init];
#if TARGET_OS_OSX #if defined(OSX)
[self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; [self setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
NSArray *array = [NSArray arrayWithObjects:NSColorPboardType, NSFilenamesPboardType, nil]; NSArray *array = [NSArray arrayWithObjects:NSColorPboardType, NSFilenamesPboardType, nil];
[self registerForDraggedTypes:array]; [self registerForDraggedTypes:array];
@ -81,7 +81,7 @@ void *glkitview_init(void);
#endif #endif
#endif #endif
#if TARGET_OS_OSX #if defined(OSX)
video_driver_display_type_set(RARCH_DISPLAY_OSX); video_driver_display_type_set(RARCH_DISPLAY_OSX);
video_driver_display_set(0); video_driver_display_set(0);
video_driver_display_userdata_set((uintptr_t)self); video_driver_display_userdata_set((uintptr_t)self);
@ -95,7 +95,7 @@ void *glkitview_init(void);
return self; return self;
} }
#if TARGET_OS_OSX #if defined(OSX)
- (void)setFrame:(NSRect)frameRect - (void)setFrame:(NSRect)frameRect
{ {
[super setFrame:frameRect]; [super setFrame:frameRect];

View File

@ -23,6 +23,10 @@
#define MAC_OS_X_VERSION_10_12 101200 #define MAC_OS_X_VERSION_10_12 101200
#endif #endif
#ifndef NSEventModifierFlags
#define NSEventModifierFlags NSUInteger
#endif
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12
#define NSEventModifierFlagCommand NSCommandKeyMask #define NSEventModifierFlagCommand NSCommandKeyMask
#define NSEventModifierFlagControl NSControlKeyMask #define NSEventModifierFlagControl NSControlKeyMask

View File

@ -126,7 +126,7 @@ static char **waiting_argv;
{ {
CGFloat delta_x = event.deltaX; CGFloat delta_x = event.deltaX;
CGFloat delta_y = event.deltaY; CGFloat delta_y = event.deltaY;
CGPoint pos = CONVERT_POINT(); NSPoint pos = CONVERT_POINT();
cocoa_input_data_t cocoa_input_data_t
*apple = (cocoa_input_data_t*) *apple = (cocoa_input_data_t*)
input_driver_get_data(); input_driver_get_data();
@ -155,7 +155,7 @@ static char **waiting_argv;
case NSEventTypeOtherMouseDown: case NSEventTypeOtherMouseDown:
{ {
NSInteger number = event.buttonNumber; NSInteger number = event.buttonNumber;
CGPoint pos = CONVERT_POINT(); NSPoint pos = CONVERT_POINT();
cocoa_input_data_t cocoa_input_data_t
*apple = (cocoa_input_data_t*) *apple = (cocoa_input_data_t*)
input_driver_get_data(); input_driver_get_data();
@ -170,7 +170,7 @@ static char **waiting_argv;
case NSEventTypeOtherMouseUp: case NSEventTypeOtherMouseUp:
{ {
NSInteger number = event.buttonNumber; NSInteger number = event.buttonNumber;
CGPoint pos = CONVERT_POINT(); NSPoint pos = CONVERT_POINT();
cocoa_input_data_t cocoa_input_data_t
*apple = (cocoa_input_data_t*) *apple = (cocoa_input_data_t*)
input_driver_get_data(); input_driver_get_data();