mirror of
https://github.com/encounter/SDL.git
synced 2025-12-16 08:27:05 +00:00
Leave the Metal view active on the window when recreating the Metal renderer
Fixes https://github.com/libsdl-org/SDL/issues/5140 Also move the metal tag definition to SDL_syswm.h so it can be used by applications
This commit is contained in:
@@ -39,7 +39,6 @@
|
||||
#import <Metal/Metal.h>
|
||||
#import <QuartzCore/CAMetalLayer.h>
|
||||
|
||||
#define METALVIEW_TAG 255
|
||||
|
||||
@interface SDL_cocoametalview : NSView
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@
|
||||
#if SDL_VIDEO_DRIVER_COCOA && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL)
|
||||
|
||||
#include "SDL_events.h"
|
||||
#include "SDL_syswm.h"
|
||||
|
||||
|
||||
static int SDLCALL
|
||||
SDL_MetalViewEventWatch(void *userdata, SDL_Event *event)
|
||||
@@ -103,7 +105,7 @@ SDL_MetalViewEventWatch(void *userdata, SDL_Event *event)
|
||||
|
||||
- (NSInteger)tag
|
||||
{
|
||||
return METALVIEW_TAG;
|
||||
return SDL_METALVIEW_TAG;
|
||||
}
|
||||
|
||||
- (void)updateDrawableSize
|
||||
@@ -173,7 +175,7 @@ Cocoa_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||
{ @autoreleasepool {
|
||||
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
|
||||
NSView *contentView = data->sdlContentView;
|
||||
SDL_cocoametalview* metalview = [contentView viewWithTag:METALVIEW_TAG];
|
||||
SDL_cocoametalview* metalview = [contentView viewWithTag:SDL_METALVIEW_TAG];
|
||||
if (metalview) {
|
||||
CAMetalLayer *layer = (CAMetalLayer*)metalview.layer;
|
||||
SDL_assert(layer != NULL);
|
||||
|
||||
@@ -38,7 +38,6 @@
|
||||
#import <Metal/Metal.h>
|
||||
#import <QuartzCore/CAMetalLayer.h>
|
||||
|
||||
#define METALVIEW_TAG 255
|
||||
|
||||
@interface SDL_uikitmetalview : SDL_uikitview
|
||||
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
|
||||
#if SDL_VIDEO_DRIVER_UIKIT && (SDL_VIDEO_VULKAN || SDL_VIDEO_METAL)
|
||||
|
||||
#import "../SDL_sysvideo.h"
|
||||
#include "SDL_syswm.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
|
||||
#import "SDL_uikitwindow.h"
|
||||
#import "SDL_uikitmetalview.h"
|
||||
|
||||
@@ -47,7 +49,7 @@
|
||||
scale:(CGFloat)scale
|
||||
{
|
||||
if ((self = [super initWithFrame:frame])) {
|
||||
self.tag = METALVIEW_TAG;
|
||||
self.tag = SDL_METALVIEW_TAG;
|
||||
self.layer.contentsScale = scale;
|
||||
[self updateDrawableSize];
|
||||
}
|
||||
@@ -122,7 +124,7 @@ UIKit_Metal_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
|
||||
@autoreleasepool {
|
||||
SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
|
||||
SDL_uikitview *view = (SDL_uikitview*)data.uiwindow.rootViewController.view;
|
||||
SDL_uikitmetalview* metalview = [view viewWithTag:METALVIEW_TAG];
|
||||
SDL_uikitmetalview* metalview = [view viewWithTag:SDL_METALVIEW_TAG];
|
||||
if (metalview) {
|
||||
CAMetalLayer *layer = (CAMetalLayer*)metalview.layer;
|
||||
assert(layer != NULL);
|
||||
|
||||
Reference in New Issue
Block a user