| | |
| | | { |
| | | 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; |
| | |
| | | - (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 |
| | |
| | | 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 |