Skip to content

Commit

Permalink
display(iOS): make renderer a property
Browse files Browse the repository at this point in the history
  • Loading branch information
osy committed Aug 3, 2022
1 parent c0887da commit 23209fe
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions Platform/iOS/Display/VMDisplayMetalViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,13 @@
#import "UTM-Swift.h"
@import CocoaSpiceRenderer;

@implementation VMDisplayMetalViewController {
CSRenderer *_renderer;
}
@interface VMDisplayMetalViewController ()

@property (nonatomic, nullable) CSRenderer *renderer;

@end

@implementation VMDisplayMetalViewController

- (instancetype)initWithDisplay:(CSDisplay *)display input:(CSInput *)input {
if (self = [super initWithNibName:nil bundle:nil]) {
Expand Down Expand Up @@ -74,21 +78,21 @@ - (void)viewDidLoad {
return;
}

_renderer = [[CSRenderer alloc] initWithMetalKitView:self.mtkView];
if (!_renderer) {
self.renderer = [[CSRenderer alloc] initWithMetalKitView:self.mtkView];
if (!self.renderer) {
UTMLog(@"Renderer failed initialization");
return;
}

// Initialize our renderer with the view size
CGSize drawableSize = self.view.bounds.size;
self.mtkView.drawableSize = drawableSize;
[_renderer mtkView:self.mtkView drawableSizeWillChange:drawableSize];
[self.renderer mtkView:self.mtkView drawableSizeWillChange:drawableSize];

[_renderer changeUpscaler:self.delegate.qemuDisplayUpscaler
downscaler:self.delegate.qemuDisplayDownscaler];
[self.renderer changeUpscaler:self.delegate.qemuDisplayUpscaler
downscaler:self.delegate.qemuDisplayDownscaler];

self.mtkView.delegate = _renderer;
self.mtkView.delegate = self.renderer;
self.vmDisplay = self.vmDisplay; // reset renderer

[self initTouch];
Expand Down Expand Up @@ -186,7 +190,7 @@ - (void)displayResize:(CGSize)size {

- (void)setVmDisplay:(CSDisplay *)display {
_vmDisplay = display;
_renderer.source = display;
self.renderer.source = display;
}

- (void)setDisplayScaling:(CGFloat)scaling origin:(CGPoint)origin {
Expand Down

0 comments on commit 23209fe

Please sign in to comment.