Changed the way retina resolutions are handled in iOS. iOS-improvements
authorAlex Szpakowski <slime73@gmail.com>
Mon, 14 Jul 2014 22:35:48 -0300
branchiOS-improvements
changeset 9488f15520430c94
parent 9487 f9fbc2d1edb0
child 9489 6cd0275146b3
Changed the way retina resolutions are handled in iOS.

Previously, SDL would always expose display modes and window dimensions in terms of pixels, and would add an extra 'fake' display mode on retina screens which would contain the non-retina resolution. Calling SDL_CreateWindow with the dimensions of that fake display mode would not work.

Now, SDL only exposes display modes and window dimensions in terms of points rather than pixels. If the SDL_WINDOW_ALLOW_HIGHDPI flag is passed into SDL_CreateWindow, then any OpenGL contexts created from that window will be sized in pixels rather than points (retrievable with SDL_GL_GetDrawableSize.) Window dimensions and mouse coordinates are still in terms of points rather than pixels even with that flag.

This matches the behavior of SDL in OS X more closely, and lets users choose whether to make use of retina displays and lets them handle it properly.
src/video/uikit/SDL_uikitmodes.h
src/video/uikit/SDL_uikitmodes.m
src/video/uikit/SDL_uikitopengles.h
src/video/uikit/SDL_uikitopengles.m
src/video/uikit/SDL_uikitopenglview.h
src/video/uikit/SDL_uikitopenglview.m
src/video/uikit/SDL_uikitvideo.m
src/video/uikit/SDL_uikitview.m
src/video/uikit/SDL_uikitviewcontroller.h
src/video/uikit/SDL_uikitviewcontroller.m
src/video/uikit/SDL_uikitwindow.m
     1.1 --- a/src/video/uikit/SDL_uikitmodes.h	Mon Jul 14 16:50:25 2014 -0300
     1.2 +++ b/src/video/uikit/SDL_uikitmodes.h	Mon Jul 14 22:35:48 2014 -0300
     1.3 @@ -28,13 +28,11 @@
     1.4  typedef struct
     1.5  {
     1.6      UIScreen *uiscreen;
     1.7 -    CGFloat scale;
     1.8  } SDL_DisplayData;
     1.9  
    1.10  typedef struct
    1.11  {
    1.12      UIScreenMode *uiscreenmode;
    1.13 -    CGFloat scale;
    1.14  } SDL_DisplayModeData;
    1.15  
    1.16  extern SDL_bool UIKit_IsDisplayLandscape(UIScreen *uiscreen);
     2.1 --- a/src/video/uikit/SDL_uikitmodes.m	Mon Jul 14 16:50:25 2014 -0300
     2.2 +++ b/src/video/uikit/SDL_uikitmodes.m	Mon Jul 14 22:35:48 2014 -0300
     2.3 @@ -28,7 +28,7 @@
     2.4  
     2.5  static int
     2.6  UIKit_AllocateDisplayModeData(SDL_DisplayMode * mode,
     2.7 -    UIScreenMode * uiscreenmode, CGFloat scale)
     2.8 +    UIScreenMode * uiscreenmode)
     2.9  {
    2.10      SDL_DisplayModeData *data = NULL;
    2.11  
    2.12 @@ -41,8 +41,6 @@
    2.13  
    2.14          data->uiscreenmode = uiscreenmode;
    2.15          [data->uiscreenmode retain];
    2.16 -
    2.17 -        data->scale = scale;
    2.18      }
    2.19  
    2.20      mode->driverdata = data;
    2.21 @@ -63,14 +61,14 @@
    2.22  
    2.23  static int
    2.24  UIKit_AddSingleDisplayMode(SDL_VideoDisplay * display, int w, int h,
    2.25 -    UIScreenMode * uiscreenmode, CGFloat scale)
    2.26 +    UIScreenMode * uiscreenmode)
    2.27  {
    2.28      SDL_DisplayMode mode;
    2.29      SDL_zero(mode);
    2.30  
    2.31      mode.format = SDL_PIXELFORMAT_ABGR8888;
    2.32      mode.refresh_rate = 0;
    2.33 -    if (UIKit_AllocateDisplayModeData(&mode, uiscreenmode, scale) < 0) {
    2.34 +    if (UIKit_AllocateDisplayModeData(&mode, uiscreenmode) < 0) {
    2.35          return -1;
    2.36      }
    2.37  
    2.38 @@ -85,16 +83,16 @@
    2.39  }
    2.40  
    2.41  static int
    2.42 -UIKit_AddDisplayMode(SDL_VideoDisplay * display, int w, int h, CGFloat scale,
    2.43 +UIKit_AddDisplayMode(SDL_VideoDisplay * display, int w, int h,
    2.44                       UIScreenMode * uiscreenmode, SDL_bool addRotation)
    2.45  {
    2.46 -    if (UIKit_AddSingleDisplayMode(display, w, h, uiscreenmode, scale) < 0) {
    2.47 +    if (UIKit_AddSingleDisplayMode(display, w, h, uiscreenmode) < 0) {
    2.48          return -1;
    2.49      }
    2.50  
    2.51      if (addRotation) {
    2.52          /* Add the rotated version */
    2.53 -        if (UIKit_AddSingleDisplayMode(display, h, w, uiscreenmode, scale) < 0) {
    2.54 +        if (UIKit_AddSingleDisplayMode(display, h, w, uiscreenmode) < 0) {
    2.55              return -1;
    2.56          }
    2.57      }
    2.58 @@ -114,24 +112,16 @@
    2.59          size.height = height;
    2.60      }
    2.61  
    2.62 -    /* When dealing with UIKit all coordinates are specified in terms of
    2.63 -     * what Apple refers to as points. [UIScreen scale] indicates the
    2.64 -     * relationship between points and pixels. Since SDL has no notion
    2.65 -     * of points, we must compensate in all cases where dealing with such
    2.66 -     * units.
    2.67 -     */
    2.68 -    CGFloat scale = [uiscreen scale];
    2.69 -
    2.70      SDL_VideoDisplay display;
    2.71      SDL_DisplayMode mode;
    2.72      SDL_zero(mode);
    2.73      mode.format = SDL_PIXELFORMAT_ABGR8888;
    2.74 -    mode.w = (int)(size.width * scale);
    2.75 -    mode.h = (int)(size.height * scale);
    2.76 +    mode.w = (int) size.width;
    2.77 +    mode.h = (int) size.height;
    2.78  
    2.79 -    UIScreenMode * uiscreenmode = [uiscreen currentMode];
    2.80 +    UIScreenMode *uiscreenmode = [uiscreen currentMode];
    2.81  
    2.82 -    if (UIKit_AllocateDisplayModeData(&mode, uiscreenmode, scale) < 0) {
    2.83 +    if (UIKit_AllocateDisplayModeData(&mode, uiscreenmode) < 0) {
    2.84          return -1;
    2.85      }
    2.86  
    2.87 @@ -148,7 +138,6 @@
    2.88  
    2.89      [uiscreen retain];
    2.90      data->uiscreen = uiscreen;
    2.91 -    data->scale = scale;
    2.92  
    2.93      display.driverdata = data;
    2.94      SDL_AddVideoDisplay(&display);
    2.95 @@ -186,11 +175,14 @@
    2.96  
    2.97      SDL_bool isLandscape = UIKit_IsDisplayLandscape(data->uiscreen);
    2.98      SDL_bool addRotation = (data->uiscreen == [UIScreen mainScreen]);
    2.99 +    CGFloat scale = data->uiscreen.scale;
   2.100  
   2.101      for (UIScreenMode *uimode in [data->uiscreen availableModes]) {
   2.102 +        /* The size of a UIScreenMode is in pixels, but we deal exclusively in
   2.103 +         * points (except in SDL_GL_GetDrawableSize.) */
   2.104          CGSize size = [uimode size];
   2.105 -        int w = (int)size.width;
   2.106 -        int h = (int)size.height;
   2.107 +        int w = (int)(size.width / scale);
   2.108 +        int h = (int)(size.height / scale);
   2.109  
   2.110          /* Make sure the width/height are oriented correctly */
   2.111          if (isLandscape != (w > h)) {
   2.112 @@ -200,17 +192,7 @@
   2.113          }
   2.114  
   2.115          /* Add the native screen resolution. */
   2.116 -        UIKit_AddDisplayMode(display, w, h, data->scale, uimode, addRotation);
   2.117 -
   2.118 -        if (data->scale != 1.0f) {
   2.119 -            /* Add the native screen resolution divided by its scale.
   2.120 -             * This is so devices capable of e.g. 640x960 also advertise 320x480.
   2.121 -             */
   2.122 -            UIKit_AddDisplayMode(display,
   2.123 -                (int)(size.width / data->scale),
   2.124 -                (int)(size.height / data->scale),
   2.125 -                1.0f, uimode, addRotation);
   2.126 -        }
   2.127 +        UIKit_AddDisplayMode(display, w, h, uimode, addRotation);
   2.128      }
   2.129  }
   2.130  
     3.1 --- a/src/video/uikit/SDL_uikitopengles.h	Mon Jul 14 16:50:25 2014 -0300
     3.2 +++ b/src/video/uikit/SDL_uikitopengles.h	Mon Jul 14 22:35:48 2014 -0300
     3.3 @@ -25,6 +25,8 @@
     3.4  
     3.5  extern int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window,
     3.6                                  SDL_GLContext context);
     3.7 +extern void UIKit_GL_GetDrawableSize(_THIS, SDL_Window * window,
     3.8 +                                     int * w, int * h);
     3.9  extern void UIKit_GL_SwapWindow(_THIS, SDL_Window * window);
    3.10  extern SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window);
    3.11  extern void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context);
     4.1 --- a/src/video/uikit/SDL_uikitopengles.m	Mon Jul 14 16:50:25 2014 -0300
     4.2 +++ b/src/video/uikit/SDL_uikitopengles.m	Mon Jul 14 22:35:48 2014 -0300
     4.3 @@ -49,7 +49,8 @@
     4.4  /*
     4.5      note that SDL_GL_Delete context makes it current without passing the window
     4.6  */
     4.7 -int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
     4.8 +int
     4.9 +UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context)
    4.10  {
    4.11      if (context) {
    4.12          SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
    4.13 @@ -62,6 +63,19 @@
    4.14      return 0;
    4.15  }
    4.16  
    4.17 +void UIKit_GL_GetDrawableSize(_THIS, SDL_Window * window, int * w, int * h)
    4.18 +{
    4.19 +    SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
    4.20 +
    4.21 +    if (w) {
    4.22 +        *w = data->view.backingWidth;
    4.23 +    }
    4.24 +    if (h) {
    4.25 +        *h = data->view.backingHeight;
    4.26 +    }
    4.27 +}
    4.28 +
    4.29 +
    4.30  int
    4.31  UIKit_GL_LoadLibrary(_THIS, const char *path)
    4.32  {
    4.33 @@ -96,15 +110,22 @@
    4.34       */
    4.35  }
    4.36  
    4.37 -SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window)
    4.38 +SDL_GLContext
    4.39 +UIKit_GL_CreateContext(_THIS, SDL_Window * window)
    4.40  {
    4.41      SDL_uikitopenglview *view;
    4.42      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    4.43 -    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    4.44 -    SDL_DisplayData *displaydata = display->driverdata;
    4.45 -    SDL_DisplayModeData *displaymodedata = display->current_mode.driverdata;
    4.46      UIWindow *uiwindow = data->uiwindow;
    4.47      EAGLSharegroup *share_group = nil;
    4.48 +    CGFloat scale = 1.0;
    4.49 +
    4.50 +    if (window->flags & SDL_WINDOW_ALLOW_HIGHDPI) {
    4.51 +        /* Set the scale to the natural scale factor of the screen - the backing
    4.52 +           dimensions of the OpenGL view will match the pixel dimensions of the
    4.53 +           screen rather than the dimensions in points.
    4.54 +         */
    4.55 +        scale = [uiwindow screen].scale;
    4.56 +    }
    4.57  
    4.58      if (_this->gl_config.share_with_current_context) {
    4.59          SDL_uikitopenglview *view = (SDL_uikitopenglview *) SDL_GL_GetCurrentContext();
    4.60 @@ -114,12 +135,12 @@
    4.61      /* construct our view, passing in SDL's OpenGL configuration data */
    4.62      CGRect frame;
    4.63      if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) {
    4.64 -        frame = [displaydata->uiscreen bounds];
    4.65 +        frame = [[uiwindow screen] bounds];
    4.66      } else {
    4.67 -        frame = [displaydata->uiscreen applicationFrame];
    4.68 +        frame = [[uiwindow screen] applicationFrame];
    4.69      }
    4.70      view = [[SDL_uikitopenglview alloc] initWithFrame: frame
    4.71 -                                    scale: displaymodedata->scale
    4.72 +                                    scale: scale
    4.73                                      retainBacking: _this->gl_config.retained_backing
    4.74                                      rBits: _this->gl_config.red_size
    4.75                                      gBits: _this->gl_config.green_size
    4.76 @@ -152,7 +173,7 @@
    4.77      }
    4.78  
    4.79      /* Make this window the current mouse focus for touch input */
    4.80 -    if (displaydata->uiscreen == [UIScreen mainScreen]) {
    4.81 +    if ([uiwindow screen] == [UIScreen mainScreen]) {
    4.82          SDL_SetMouseFocus(window);
    4.83          SDL_SetKeyboardFocus(window);
    4.84      }
    4.85 @@ -160,7 +181,8 @@
    4.86      return view;
    4.87  }
    4.88  
    4.89 -void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context)
    4.90 +void
    4.91 +UIKit_GL_DeleteContext(_THIS, SDL_GLContext context)
    4.92  {
    4.93      /* the delegate has retained the view, this will release him */
    4.94      SDL_uikitopenglview *view = (SDL_uikitopenglview *)context;
     5.1 --- a/src/video/uikit/SDL_uikitopenglview.h	Mon Jul 14 16:50:25 2014 -0300
     5.2 +++ b/src/video/uikit/SDL_uikitopenglview.h	Mon Jul 14 22:35:48 2014 -0300
     5.3 @@ -55,6 +55,10 @@
     5.4  
     5.5  @property (nonatomic, retain, readonly) EAGLContext *context;
     5.6  
     5.7 +/* The width and height of the drawable in pixels (as opposed to points.) */
     5.8 +@property (nonatomic, readonly) int backingWidth;
     5.9 +@property (nonatomic, readonly) int backingHeight;
    5.10 +
    5.11  - (void)swapBuffers;
    5.12  - (void)setCurrentContext;
    5.13  
     6.1 --- a/src/video/uikit/SDL_uikitopenglview.m	Mon Jul 14 16:50:25 2014 -0300
     6.2 +++ b/src/video/uikit/SDL_uikitopenglview.m	Mon Jul 14 22:35:48 2014 -0300
     6.3 @@ -32,6 +32,9 @@
     6.4  
     6.5  @synthesize context;
     6.6  
     6.7 +@synthesize backingWidth = backingWidth;
     6.8 +@synthesize backingHeight = backingHeight;
     6.9 +
    6.10  + (Class)layerClass
    6.11  {
    6.12      return [CAEAGLLayer class];
    6.13 @@ -74,7 +77,9 @@
    6.14  
    6.15          eaglLayer.opaque = YES;
    6.16          eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
    6.17 -                                        [NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking, colorFormat, kEAGLDrawablePropertyColorFormat, nil];
    6.18 +                                        [NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking,
    6.19 +                                        colorFormat, kEAGLDrawablePropertyColorFormat,
    6.20 +                                        nil];
    6.21  
    6.22          context = [[EAGLContext alloc] initWithAPI:api sharegroup:shareGroup];
    6.23          if (!context || ![EAGLContext setCurrentContext:context]) {
     7.1 --- a/src/video/uikit/SDL_uikitvideo.m	Mon Jul 14 16:50:25 2014 -0300
     7.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Mon Jul 14 22:35:48 2014 -0300
     7.3 @@ -93,12 +93,13 @@
     7.4  #endif
     7.5  
     7.6      /* OpenGL (ES) functions */
     7.7 -    device->GL_MakeCurrent        = UIKit_GL_MakeCurrent;
     7.8 -    device->GL_SwapWindow        = UIKit_GL_SwapWindow;
     7.9 +    device->GL_MakeCurrent      = UIKit_GL_MakeCurrent;
    7.10 +    device->GL_GetDrawableSize  = UIKit_GL_GetDrawableSize;
    7.11 +    device->GL_SwapWindow       = UIKit_GL_SwapWindow;
    7.12      device->GL_CreateContext    = UIKit_GL_CreateContext;
    7.13      device->GL_DeleteContext    = UIKit_GL_DeleteContext;
    7.14      device->GL_GetProcAddress   = UIKit_GL_GetProcAddress;
    7.15 -    device->GL_LoadLibrary        = UIKit_GL_LoadLibrary;
    7.16 +    device->GL_LoadLibrary      = UIKit_GL_LoadLibrary;
    7.17      device->free = UIKit_DeleteDevice;
    7.18  
    7.19      device->gl_config.accelerated = 1;
     8.1 --- a/src/video/uikit/SDL_uikitview.m	Mon Jul 14 16:50:25 2014 -0300
     8.2 +++ b/src/video/uikit/SDL_uikitview.m	Mon Jul 14 22:35:48 2014 -0300
     8.3 @@ -65,19 +65,12 @@
     8.4  {
     8.5      CGPoint point = [touch locationInView: self];
     8.6  
     8.7 -    /* Get the display scale and apply that to the input coordinates */
     8.8 -    SDL_Window *window = viewcontroller.window;
     8.9 -    SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    8.10 -    SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata;
    8.11 -
    8.12      if (normalize) {
    8.13          CGRect bounds = [self bounds];
    8.14          point.x /= bounds.size.width;
    8.15          point.y /= bounds.size.height;
    8.16 -    } else {
    8.17 -        point.x *= displaymodedata->scale;
    8.18 -        point.y *= displaymodedata->scale;
    8.19      }
    8.20 +
    8.21      return point;
    8.22  }
    8.23  
    8.24 @@ -360,7 +353,6 @@
    8.25      int height = view.keyboardHeight;
    8.26      int offsetx = 0;
    8.27      int offsety = 0;
    8.28 -    float scale = [UIScreen mainScreen].scale;
    8.29      if (height) {
    8.30          int sw,sh;
    8.31          SDL_GetWindowSize(window,&sw,&sh);
    8.32 @@ -382,9 +374,6 @@
    8.33          offsety = -offsety;
    8.34      }
    8.35  
    8.36 -    offsetx /= scale;
    8.37 -    offsety /= scale;
    8.38 -
    8.39      view.frame = CGRectMake(offsetx,offsety,view.frame.size.width,view.frame.size.height);
    8.40  }
    8.41  
    8.42 @@ -412,7 +401,6 @@
    8.43                          if (ui_orient == UIInterfaceOrientationLandscapeRight || ui_orient == UIInterfaceOrientationLandscapeLeft) {
    8.44                              height = keyboardSize.width;
    8.45                          }
    8.46 -                        height *= [UIScreen mainScreen].scale;
    8.47                          _uikit_keyboard_set_height(height);
    8.48                      }
    8.49       ];
     9.1 --- a/src/video/uikit/SDL_uikitviewcontroller.h	Mon Jul 14 16:50:25 2014 -0300
     9.2 +++ b/src/video/uikit/SDL_uikitviewcontroller.h	Mon Jul 14 22:35:48 2014 -0300
     9.3 @@ -28,7 +28,7 @@
     9.4      SDL_Window *window;
     9.5  }
     9.6  
     9.7 -@property (readwrite) SDL_Window *window;
     9.8 +@property (nonatomic, readwrite) SDL_Window *window;
     9.9  
    9.10  - (id)initWithSDLWindow:(SDL_Window *)_window;
    9.11  - (void)loadView;
    10.1 --- a/src/video/uikit/SDL_uikitviewcontroller.m	Mon Jul 14 16:50:25 2014 -0300
    10.2 +++ b/src/video/uikit/SDL_uikitviewcontroller.m	Mon Jul 14 22:35:48 2014 -0300
    10.3 @@ -56,15 +56,11 @@
    10.4  
    10.5  - (void)viewDidLayoutSubviews
    10.6  {
    10.7 -    if (self->window->flags & SDL_WINDOW_RESIZABLE) {
    10.8 -        SDL_WindowData *data = self->window->driverdata;
    10.9 -        SDL_VideoDisplay *display = SDL_GetDisplayForWindow(self->window);
   10.10 -        SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata;
   10.11 +    if (window->flags & SDL_WINDOW_RESIZABLE) {
   10.12 +        SDL_WindowData *data = window->driverdata;
   10.13          const CGSize size = data->view.bounds.size;
   10.14 -        int w, h;
   10.15 -
   10.16 -        w = (int)(size.width * displaymodedata->scale);
   10.17 -        h = (int)(size.height * displaymodedata->scale);
   10.18 +        int w = (int) size.width;
   10.19 +        int h = (int) size.height;
   10.20  
   10.21          SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h);
   10.22      }
    11.1 --- a/src/video/uikit/SDL_uikitwindow.m	Mon Jul 14 16:50:25 2014 -0300
    11.2 +++ b/src/video/uikit/SDL_uikitwindow.m	Mon Jul 14 22:35:48 2014 -0300
    11.3 @@ -47,7 +47,6 @@
    11.4  static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created)
    11.5  {
    11.6      SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window);
    11.7 -    SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata;
    11.8      SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
    11.9      SDL_WindowData *data;
   11.10  
   11.11 @@ -72,9 +71,9 @@
   11.12              bounds = [displaydata->uiscreen applicationFrame];
   11.13          }
   11.14  
   11.15 -        /* Get frame dimensions in pixels */
   11.16 -        int width = (int)(bounds.size.width * displaymodedata->scale);
   11.17 -        int height = (int)(bounds.size.height * displaymodedata->scale);
   11.18 +        /* Get frame dimensions */
   11.19 +        int width = (int) bounds.size.width;
   11.20 +        int height = (int) bounds.size.height;
   11.21  
   11.22          /* Make sure the width/height are oriented correctly */
   11.23          if (UIKit_IsDisplayLandscape(displaydata->uiscreen) != (width > height)) {
   11.24 @@ -191,8 +190,7 @@
   11.25  
   11.26      /* ignore the size user requested, and make a fullscreen window */
   11.27      /* !!! FIXME: can we have a smaller view? */
   11.28 -    UIWindow *uiwindow = [UIWindow alloc];
   11.29 -    uiwindow = [uiwindow initWithFrame:[data->uiscreen bounds]];
   11.30 +    UIWindow *uiwindow = [[UIWindow alloc] initWithFrame:[data->uiscreen bounds]];
   11.31  
   11.32      /* put the window on an external display if appropriate. This implicitly
   11.33       * does [uiwindow setframe:[uiscreen bounds]], so don't do it on the
   11.34 @@ -243,7 +241,6 @@
   11.35  UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen)
   11.36  {
   11.37      SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata;
   11.38 -    SDL_DisplayModeData *displaymodedata = (SDL_DisplayModeData *) display->current_mode.driverdata;
   11.39      UIWindow *uiwindow = ((SDL_WindowData *) window->driverdata)->uiwindow;
   11.40  
   11.41      if (fullscreen) {
   11.42 @@ -259,9 +256,9 @@
   11.43          bounds = [displaydata->uiscreen applicationFrame];
   11.44      }
   11.45  
   11.46 -    /* Get frame dimensions in pixels */
   11.47 -    int width = (int)(bounds.size.width * displaymodedata->scale);
   11.48 -    int height = (int)(bounds.size.height * displaymodedata->scale);
   11.49 +    /* Get frame dimensions */
   11.50 +    int width = (int) bounds.size.width;
   11.51 +    int height = (int) bounds.size.height;
   11.52  
   11.53      /* We can pick either width or height here and we'll rotate the
   11.54         screen to match, so we pick the closest to what we wanted.