diff options
author | chai <chaifix@163.com> | 2019-01-31 18:38:35 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2019-01-31 18:38:35 +0800 |
commit | 2ec55fd974a63b705a4777c256d2222c874fa043 (patch) | |
tree | 48f1fea59ee9fc713a28a9aac3f05b98dc5ae66f /Source/3rdParty/SDL2/src/video/uikit/SDL_uikitmetalview.m | |
parent | c581dfbf1e849f393861d15e82aa6446c0c1c310 (diff) |
*SDL project
Diffstat (limited to 'Source/3rdParty/SDL2/src/video/uikit/SDL_uikitmetalview.m')
-rw-r--r-- | Source/3rdParty/SDL2/src/video/uikit/SDL_uikitmetalview.m | 18 |
1 files changed, 13 insertions, 5 deletions
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 |