graphicsdriver/metal/ca: Add check by respondsToSelector (#767)

This commit is contained in:
Hajime Hoshi 2019-01-02 00:52:03 +09:00
parent a0a17330ee
commit 6350cb6bfd

View File

@ -48,8 +48,11 @@ const char *MetalLayer_SetMaximumDrawableCount(void *metalLayer,
uint_t maximumDrawableCount) { uint_t maximumDrawableCount) {
if (@available(macOS 10.13.2, *)) { if (@available(macOS 10.13.2, *)) {
@try { @try {
if ([(CAMetalLayer *)metalLayer
respondsToSelector:@selector(maximumDrawableCount)]) {
((CAMetalLayer *)metalLayer).maximumDrawableCount = ((CAMetalLayer *)metalLayer).maximumDrawableCount =
(NSUInteger)maximumDrawableCount; (NSUInteger)maximumDrawableCount;
}
} @catch (NSException *exception) { } @catch (NSException *exception) {
return exception.reason.UTF8String; return exception.reason.UTF8String;
} }
@ -60,9 +63,12 @@ const char *MetalLayer_SetMaximumDrawableCount(void *metalLayer,
void MetalLayer_SetDisplaySyncEnabled(void *metalLayer, void MetalLayer_SetDisplaySyncEnabled(void *metalLayer,
BOOL displaySyncEnabled) { BOOL displaySyncEnabled) {
if (@available(macOS 10.13, *)) { if (@available(macOS 10.13, *)) {
if ([(CAMetalLayer *)metalLayer
respondsToSelector:@selector(displaySyncEnabled)]) {
((CAMetalLayer *)metalLayer).displaySyncEnabled = displaySyncEnabled; ((CAMetalLayer *)metalLayer).displaySyncEnabled = displaySyncEnabled;
} }
} }
}
void MetalLayer_SetDrawableSize(void *metalLayer, double width, double height) { void MetalLayer_SetDrawableSize(void *metalLayer, double width, double height) {
((CAMetalLayer *)metalLayer).drawableSize = (CGSize){width, height}; ((CAMetalLayer *)metalLayer).drawableSize = (CGSize){width, height};