From 2ec55fd974a63b705a4777c256d2222c874fa043 Mon Sep 17 00:00:00 2001 From: chai Date: Thu, 31 Jan 2019 18:38:35 +0800 Subject: *SDL project --- .../3rdParty/SDL2/src/video/uikit/SDL_uikitmetalview.m | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'Source/3rdParty/SDL2/src/video/uikit/SDL_uikitmetalview.m') diff --git a/Source/3rdParty/SDL2/src/video/uikit/SDL_uikitmetalview.m b/Source/3rdParty/SDL2/src/video/uikit/SDL_uikitmetalview.m index 104189d..436e742 100644 --- a/Source/3rdParty/SDL2/src/video/uikit/SDL_uikitmetalview.m +++ b/Source/3rdParty/SDL2/src/video/uikit/SDL_uikitmetalview.m @@ -49,9 +49,8 @@ { if ((self = [super initWithFrame:frame])) { self.tag = METALVIEW_TAG; - /* Set the desired scale. The default drawableSize of a CAMetalLayer - * is its bounds x its scale so nothing further needs to be done. */ self.layer.contentsScale = scale; + [self updateDrawableSize]; } return self; @@ -61,6 +60,15 @@ - (void)layoutSubviews { [super layoutSubviews]; + [self updateDrawableSize]; +} + +- (void)updateDrawableSize +{ + CGSize size = self.bounds.size; + size.width *= self.layer.contentsScale; + size.height *= self.layer.contentsScale; + ((CAMetalLayer *)self.layer).drawableSize = size; } @end @@ -72,9 +80,9 @@ UIKit_Mtl_AddMetalView(SDL_Window* window) SDL_uikitview *view = (SDL_uikitview*)data.uiwindow.rootViewController.view; CGFloat scale = 1.0; - if ([view isKindOfClass:[SDL_uikitmetalview class]]) { - return (SDL_uikitmetalview *)view; - } + if ([view isKindOfClass:[SDL_uikitmetalview class]]) { + return (SDL_uikitmetalview *)view; + } if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) { /* Set the scale to the natural scale factor of the screen - then -- cgit v1.1-26-g67d0