Play-/Source/ui_ios/RenderView.mm
Jean-Philip Desjardins 30568a057d
Some checks failed
Build macOS / build_macos (push) Has been cancelled
Build Android / build_android (apk) (push) Has been cancelled
Build Android / build_android (libretro) (push) Has been cancelled
Build Linux ARM32 / build_linux_arm32 (push) Has been cancelled
Build Linux ARM64 / build_linux_arm64 (push) Has been cancelled
Build Windows Psf / build_windows_psf (off, x86_64, Visual Studio 16 2019, installer64.nsi, x64) (push) Has been cancelled
Build Windows Psf / build_windows_psf (on, x86_64, Visual Studio 16 2019, installer64.nsi, x64) (push) Has been cancelled
Build Windows / build_windows (x86_32, Visual Studio 16 2019, installer32.nsi, win32_msvc2019, Win32) (push) Has been cancelled
Build Windows / build_windows (x86_64, Visual Studio 16 2019, installer64.nsi, win64_msvc2019_64, x64) (push) Has been cancelled
Check Format / run_clangformat (push) Has been cancelled
Build iOS / build_ios (push) Has been cancelled
Build JavaScript / build_js (push) Has been cancelled
Build Linux / build_linux (push) Has been cancelled
Use app_config module.
2025-03-11 16:18:58 -04:00

77 lines
1.7 KiB
Text

#import "RenderView.h"
#import <QuartzCore/QuartzCore.h>
#include "AppConfig.h"
#include "PreferenceDefs.h"
@implementation RenderView
+ (Class)layerClass
{
auto gsHandlerId = CAppConfig::GetInstance().GetPreferenceInteger(PREFERENCE_VIDEO_GS_HANDLER);
switch(gsHandlerId)
{
default:
[[fallthrough]];
case PREFERENCE_VALUE_VIDEO_GS_HANDLER_OPENGL:
return [CAEAGLLayer class];
case PREFERENCE_VALUE_VIDEO_GS_HANDLER_VULKAN:
return [CAMetalLayer class];
}
}
- (void)initView
{
hasRetinaDisplay = NO;
if([[UIScreen mainScreen] respondsToSelector:NSSelectorFromString(@"scale")])
{
if([self respondsToSelector:NSSelectorFromString(@"contentScaleFactor")])
{
float scale = [[UIScreen mainScreen] scale];
self.contentScaleFactor = scale;
if(scale == 2.0f)
{
hasRetinaDisplay = YES;
}
}
}
self.layer.opaque = TRUE;
auto gsHandlerId = CAppConfig::GetInstance().GetPreferenceInteger(PREFERENCE_VIDEO_GS_HANDLER);
if(gsHandlerId == PREFERENCE_VALUE_VIDEO_GS_HANDLER_OPENGL)
{
CAEAGLLayer* layer = (CAEAGLLayer*)self.layer;
layer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking,
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
nil];
}
}
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if(self)
{
[self initView];
}
return self;
}
- (id)initWithCoder:(NSCoder*)decoder
{
self = [super initWithCoder:decoder];
if(self)
{
[self initView];
}
return self;
}
- (BOOL)hasRetinaDisplay
{
return hasRetinaDisplay;
}
@end