Fixed setting the layer drawable size
authorSam Lantinga <slouken@libsdl.org>
Fri, 02 Mar 2018 12:08:18 -0800
changeset 11918c087b18ba812
parent 11917 5ce3f8bf8381
child 11919 8ebcdaa049e5
Fixed setting the layer drawable size
Without this change the drawable had a size of 0 and the metal renderer asserted because the projection matrix wasn't set.
src/video/uikit/SDL_uikitmetalview.m
     1.1 --- a/src/video/uikit/SDL_uikitmetalview.m	Fri Mar 02 14:10:25 2018 -0500
     1.2 +++ b/src/video/uikit/SDL_uikitmetalview.m	Fri Mar 02 12:08:18 2018 -0800
     1.3 @@ -60,7 +60,14 @@
     1.4  /* Set the size of the metal drawables when the view is resized. */
     1.5  - (void)layoutSubviews
     1.6  {
     1.7 +    CGSize bounds;
     1.8 +
     1.9      [super layoutSubviews];
    1.10 +
    1.11 +    bounds = [self bounds].size;
    1.12 +    bounds.width *= self.layer.contentsScale;
    1.13 +    bounds.height *= self.layer.contentsScale;
    1.14 +    ((CAMetalLayer *) self.layer).drawableSize = bounds;
    1.15  }
    1.16  
    1.17  @end
    1.18 @@ -72,9 +79,9 @@
    1.19      SDL_uikitview *view = (SDL_uikitview*)data.uiwindow.rootViewController.view;
    1.20      CGFloat scale = 1.0;
    1.21  
    1.22 -	if ([view isKindOfClass:[SDL_uikitmetalview class]]) {
    1.23 -		return (SDL_uikitmetalview *)view;
    1.24 -	}
    1.25 +    if ([view isKindOfClass:[SDL_uikitmetalview class]]) {
    1.26 +        return (SDL_uikitmetalview *)view;
    1.27 +    }
    1.28  
    1.29      if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
    1.30          /* Set the scale to the natural scale factor of the screen - then