Do not access "view" in getMetalLayerSize

Fixes Main thread checker assert in getMetalLayerSize
Use the layer.contentsScale to adjust for high DPI instead of "view convertSizeToBacking"
This commit is contained in:
Jake Turner
2021-03-25 09:36:33 +00:00
committed by Baldur Karlsson
parent 57b6190c85
commit 1700249a79
2 changed files with 6 additions and 8 deletions
+2 -2
View File
@@ -29,7 +29,7 @@
#include <dlfcn.h>
// helpers defined in vk_apple.mm
void getMetalLayerSize(void *viewHandle, void *layerHandle, int &width, int &height);
void getMetalLayerSize(void *layerHandle, int &width, int &height);
#if defined(VK_USE_PLATFORM_MACOS_MVK)
@@ -147,7 +147,7 @@ void VulkanReplay::GetOutputWindowDimensions(uint64_t id, int32_t &w, int32_t &h
return;
}
getMetalLayerSize(outw.cocoa.view, outw.cocoa.layer, w, h);
getMetalLayerSize(outw.cocoa.layer, w, h);
}
static const rdcstr VulkanLibraryName = "libvulkan.1.dylib"_lit;
+4 -6
View File
@@ -1,13 +1,11 @@
#import <Cocoa/Cocoa.h>
void getMetalLayerSize(void *viewHandle, void* layerHandle, int& width, int& height)
void getMetalLayerSize(void* layerHandle, int& width, int& height)
{
NSView *view = (NSView *)viewHandle;
assert([view isKindOfClass:[NSView class]]);
CALayer *layer = (CALayer *)layerHandle;
assert([layer isKindOfClass:[CALayer class]]);
CGSize viewScale = [view convertSizeToBacking:layer.bounds.size];
width = viewScale.width;
height = viewScale.height;
const CGFloat scaleFactor = layer.contentsScale;
width = layer.bounds.size.width * scaleFactor;
height = layer.bounds.size.height * scaleFactor;
}