mirror of
https://github.com/encounter/SDL.git
synced 2025-12-21 18:59:15 +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);
|
||||
|
||||
Reference in New Issue
Block a user