metal and moltenvk: fix highdpi.

This commit is contained in:
Alex Szpakowski 2018-01-02 21:44:28 -04:00
parent ef1014ac68
commit f9cd765020
2 changed files with 3 additions and 7 deletions

View File

@ -563,9 +563,6 @@ static int
METAL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) METAL_GetOutputSize(SDL_Renderer * renderer, int *w, int *h)
{ @autoreleasepool { { @autoreleasepool {
METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata; METAL_RenderData *data = (__bridge METAL_RenderData *) renderer->driverdata;
// !!! FIXME: We shouldn't need ActivateRenderer, but drawableSize is 0
// in the first frame without it.
METAL_ActivateRenderer(renderer);
if (w) { if (w) {
*w = (int)data.mtllayer.drawableSize.width; *w = (int)data.mtllayer.drawableSize.width;
} }

View File

@ -61,11 +61,12 @@
useHighDPI:(bool)useHighDPI useHighDPI:(bool)useHighDPI
{ {
if ((self = [super initWithFrame:frame])) { if ((self = [super initWithFrame:frame])) {
self.wantsLayer = YES;
/* Allow resize. */ /* Allow resize. */
self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable; self.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
_tag = METALVIEW_TAG; _tag = METALVIEW_TAG;
_useHighDPI = useHighDPI; _useHighDPI = useHighDPI;
[self updateDrawableSize]; [self updateDrawableSize];
} }
@ -100,8 +101,6 @@ Cocoa_Mtl_AddMetalView(SDL_Window* window)
SDL_cocoametalview *metalview SDL_cocoametalview *metalview
= [[SDL_cocoametalview alloc] initWithFrame:view.frame = [[SDL_cocoametalview alloc] initWithFrame:view.frame
useHighDPI:(window->flags & SDL_WINDOW_ALLOW_HIGHDPI)]; useHighDPI:(window->flags & SDL_WINDOW_ALLOW_HIGHDPI)];
// Instantiate the CAMetalLayer
metalview.wantsLayer = YES;
[view addSubview:metalview]; [view addSubview:metalview];
return metalview; return metalview;
} }