2021-06-27 08:42:26 -04:00
|
|
|
#import "RenderView.h"
|
|
|
|
#import <QuartzCore/QuartzCore.h>
|
2025-03-11 12:48:26 -04:00
|
|
|
#include "AppConfig.h"
|
2021-06-27 08:42:26 -04:00
|
|
|
#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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-06-29 08:14:27 -04:00
|
|
|
|
2021-06-27 08:42:26 -04:00
|
|
|
self.layer.opaque = TRUE;
|
2021-06-29 08:14:27 -04:00
|
|
|
|
2021-06-27 08:42:26 -04:00
|
|
|
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:
|
2021-06-29 08:14:27 -04:00
|
|
|
[NSNumber numberWithBool:FALSE], kEAGLDrawablePropertyRetainedBacking,
|
|
|
|
kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat,
|
|
|
|
nil];
|
2021-06-27 08:42:26 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (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
|