From 03f8528315fa46c95991a34f3325d7b33ae5538c Mon Sep 17 00:00:00 2001
From: Edward Rudd <urkle@outoforder.cc>
Date: Sat, 02 May 2020 21:48:36 +0000
Subject: [PATCH] Update source to SDL2 2.0.12
---
source/src/video/uikit/SDL_uikitmetalview.m | 45 ++++++++++++++++++++++++---------------------
1 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/source/src/video/uikit/SDL_uikitmetalview.m b/source/src/video/uikit/SDL_uikitmetalview.m
index 436e742..29ed860 100644
--- a/source/src/video/uikit/SDL_uikitmetalview.m
+++ b/source/src/video/uikit/SDL_uikitmetalview.m
@@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
- Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
+ Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@@ -28,7 +28,7 @@
#include "../../SDL_internal.h"
-#if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_RENDER_METAL || SDL_VIDEO_VULKAN)
+#if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL)
#import "../SDL_sysvideo.h"
#import "SDL_uikitwindow.h"
@@ -73,16 +73,12 @@
@end
-SDL_uikitmetalview*
-UIKit_Mtl_AddMetalView(SDL_Window* window)
-{
+SDL_MetalView
+UIKit_Metal_CreateView(_THIS, SDL_Window * window)
+{ @autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
- SDL_uikitview *view = (SDL_uikitview*)data.uiwindow.rootViewController.view;
CGFloat scale = 1.0;
-
- if ([view isKindOfClass:[SDL_uikitmetalview class]]) {
- return (SDL_uikitmetalview *)view;
- }
+ SDL_uikitmetalview *metalview;
if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
/* Set the scale to the natural scale factor of the screen - then
@@ -90,25 +86,32 @@
* dimensions of the screen rather than the dimensions in points
* yielding high resolution on retine displays.
*/
-#ifdef __IPHONE_8_0
if ([data.uiwindow.screen respondsToSelector:@selector(nativeScale)]) {
scale = data.uiwindow.screen.nativeScale;
- } else
-#endif
- {
+ } else {
scale = data.uiwindow.screen.scale;
}
}
- SDL_uikitmetalview *metalview
- = [[SDL_uikitmetalview alloc] initWithFrame:view.frame
- scale:scale];
+
+ metalview = [[SDL_uikitmetalview alloc] initWithFrame:data.uiwindow.bounds
+ scale:scale];
[metalview setSDLWindow:window];
- return metalview;
-}
+ return (void*)CFBridgingRetain(metalview);
+}}
void
-UIKit_Mtl_GetDrawableSize(SDL_Window * window, int * w, int * h)
+UIKit_Metal_DestroyView(_THIS, SDL_MetalView view)
+{ @autoreleasepool {
+ SDL_uikitmetalview *metalview = CFBridgingRelease(view);
+
+ if ([metalview isKindOfClass:[SDL_uikitmetalview class]]) {
+ [metalview setSDLWindow:NULL];
+ }
+}}
+
+void
+UIKit_Metal_GetDrawableSize(SDL_Window * window, int * w, int * h)
{
@autoreleasepool {
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
@@ -129,4 +132,4 @@
}
}
-#endif /* SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_RENDER_METAL || SDL_VIDEO_VULKAN) */
+#endif /* SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL) */
--
Gitblit v1.9.3