[Commits] SDL: macOS: Fix MoltenVK Metal view resizing, and allow the meta...

libsdl.org revision control commits-owner at libsdl.org
Sun Dec 31 11:21:43 PST 2017


details:   https://hg.libsdl.org/SDL/rev/4da70548aa06
changeset: 11797:4da70548aa06
user:      Alex Szpakowski <slime73 at gmail.com>
date:      Sun Dec 31 15:21:25 2017 -0400
description:
macOS: Fix MoltenVK Metal view resizing, and allow the metal view to be used without vulkan.

diffstat:

 include/SDL_config_macosx.h          |   7 ++++++-
 src/video/cocoa/SDL_cocoametalview.h |  10 +++++-----
 src/video/cocoa/SDL_cocoametalview.m |  13 +++++++------
 3 files changed, 18 insertions(+), 12 deletions(-)

diffs (103 lines):

diff -r 8f385b1fd0b6 -r 4da70548aa06 include/SDL_config_macosx.h
--- a/include/SDL_config_macosx.h	Sun Dec 31 03:51:17 2017 -0500
+++ b/include/SDL_config_macosx.h	Sun Dec 31 15:21:25 2017 -0400
@@ -184,7 +184,12 @@
 #endif
 
 #ifndef SDL_VIDEO_RENDER_METAL
+/* Metal only supported on 64-bit architectures with 10.11+ */
+#if TARGET_CPU_X86_64 && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101100)
 #define SDL_VIDEO_RENDER_METAL    1
+#else
+#define SDL_VIDEO_RENDER_METAL    0
+#endif
 #endif
 
 /* Enable OpenGL support */
@@ -209,7 +214,7 @@
 #if TARGET_CPU_X86_64 && (MAC_OS_X_VERSION_MAX_ALLOWED >= 101100)
 #define SDL_VIDEO_VULKAN 1
 #else
-#define  SDL_VIDEO_VULKAN 0
+#define SDL_VIDEO_VULKAN 0
 #endif
 
 /* Enable system power support */
diff -r 8f385b1fd0b6 -r 4da70548aa06 src/video/cocoa/SDL_cocoametalview.h
--- a/src/video/cocoa/SDL_cocoametalview.h	Sun Dec 31 03:51:17 2017 -0500
+++ b/src/video/cocoa/SDL_cocoametalview.h	Sun Dec 31 15:21:25 2017 -0400
@@ -32,11 +32,11 @@
 #import "../SDL_sysvideo.h"
 #import "SDL_cocoawindow.h"
 
-#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_COCOA
+#if SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_RENDER_METAL)
 
-#include <Cocoa/Cocoa.h>
-#include <Metal/Metal.h>
-#include <QuartzCore/CAMetalLayer.h>
+#import <Cocoa/Cocoa.h>
+#import <Metal/Metal.h>
+#import <QuartzCore/CAMetalLayer.h>
 
 #define METALVIEW_TAG 255
 
@@ -57,7 +57,7 @@
 
 void Cocoa_Mtl_GetDrawableSize(SDL_Window * window, int * w, int * h);
 
-#endif /* SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_COCOA */
+#endif /* SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_RENDER_METAL) */
 
 #endif /* SDL_cocoametalview_h_ */
 
diff -r 8f385b1fd0b6 -r 4da70548aa06 src/video/cocoa/SDL_cocoametalview.m
--- a/src/video/cocoa/SDL_cocoametalview.m	Sun Dec 31 03:51:17 2017 -0500
+++ b/src/video/cocoa/SDL_cocoametalview.m	Sun Dec 31 15:21:25 2017 -0400
@@ -28,7 +28,7 @@
 
 #import "SDL_cocoametalview.h"
 
-#if SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_COCOA
+#if SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_RENDER_METAL)
 
 #include "SDL_assert.h"
 
@@ -44,7 +44,7 @@
 }
 
 /* Indicate the view wants to draw using a backing layer instead of drawRect. */
--(BOOL) wantsUpdateLayer
+- (BOOL)wantsUpdateLayer
 {
     return YES;
 }
@@ -52,7 +52,7 @@
 /* When the wantsLayer property is set to YES, this method will be invoked to
  * return a layer instance.
  */
--(CALayer*) makeBackingLayer
+- (CALayer*)makeBackingLayer
 {
     return [self.class.layerClass layer];
 }
@@ -74,8 +74,9 @@
 }
 
 /* Set the size of the metal drawables when the view is resized. */
-- (void)resizeSubviewsWithOldSize:(NSSize)oldSize {
-    [super resizeSubviewsWithOldSize:oldSize];
+- (void)resizeWithOldSuperviewSize:(NSSize)oldSize
+{
+    [super resizeWithOldSuperviewSize:oldSize];
     [self updateDrawableSize];
 }
 
@@ -123,6 +124,6 @@
     }
 }
 
-#endif /* SDL_VIDEO_VULKAN && SDL_VIDEO_DRIVER_COCOA */
+#endif /* SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_RENDER_METAL) */
 
 /* vi: set ts=4 sw=4 expandtab: */


More information about the commits mailing list