src/video/uikit/SDL_uikitmetalview.m
changeset 11918 c087b18ba812
parent 11886 27d81cb6e6af
child 12002 9116d02d3feb
equal deleted inserted replaced
11917:5ce3f8bf8381 11918:c087b18ba812
    58 }
    58 }
    59 
    59 
    60 /* Set the size of the metal drawables when the view is resized. */
    60 /* Set the size of the metal drawables when the view is resized. */
    61 - (void)layoutSubviews
    61 - (void)layoutSubviews
    62 {
    62 {
       
    63     CGSize bounds;
       
    64 
    63     [super layoutSubviews];
    65     [super layoutSubviews];
       
    66 
       
    67     bounds = [self bounds].size;
       
    68     bounds.width *= self.layer.contentsScale;
       
    69     bounds.height *= self.layer.contentsScale;
       
    70     ((CAMetalLayer *) self.layer).drawableSize = bounds;
    64 }
    71 }
    65 
    72 
    66 @end
    73 @end
    67 
    74 
    68 SDL_uikitmetalview*
    75 SDL_uikitmetalview*
    70 {
    77 {
    71     SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
    78     SDL_WindowData *data = (__bridge SDL_WindowData *)window->driverdata;
    72     SDL_uikitview *view = (SDL_uikitview*)data.uiwindow.rootViewController.view;
    79     SDL_uikitview *view = (SDL_uikitview*)data.uiwindow.rootViewController.view;
    73     CGFloat scale = 1.0;
    80     CGFloat scale = 1.0;
    74 
    81 
    75 	if ([view isKindOfClass:[SDL_uikitmetalview class]]) {
    82     if ([view isKindOfClass:[SDL_uikitmetalview class]]) {
    76 		return (SDL_uikitmetalview *)view;
    83         return (SDL_uikitmetalview *)view;
    77 	}
    84     }
    78 
    85 
    79     if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
    86     if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
    80         /* Set the scale to the natural scale factor of the screen - then
    87         /* Set the scale to the natural scale factor of the screen - then
    81          * the backing dimensions of the Metal view will match the pixel
    88          * the backing dimensions of the Metal view will match the pixel
    82          * dimensions of the screen rather than the dimensions in points
    89          * dimensions of the screen rather than the dimensions in points