src/video/uikit/SDL_uikitvideo.m
changeset 6009 fb5fa3561ca9
parent 6007 0e647f56751d
child 6013 b253cc3c4276
     1.1 --- a/src/video/uikit/SDL_uikitvideo.m	Wed Sep 28 21:03:05 2011 +0200
     1.2 +++ b/src/video/uikit/SDL_uikitvideo.m	Wed Sep 28 21:13:09 2011 +0200
     1.3 @@ -118,32 +118,6 @@
     1.4  
     1.5  */
     1.6  
     1.7 -static CGSize
     1.8 -UIKit_ForcePortrait(const CGSize size)
     1.9 -{
    1.10 -    CGSize retval;
    1.11 -    if (size.width < size.height) { // portrait
    1.12 -        retval = size;
    1.13 -    } else {  // landscape
    1.14 -        retval.width = size.height;
    1.15 -        retval.height = size.width;
    1.16 -    }
    1.17 -    return retval;
    1.18 -}
    1.19 -
    1.20 -static CGSize
    1.21 -UIKit_ForceLandscape(const CGSize size)
    1.22 -{
    1.23 -    CGSize retval;
    1.24 -    if (size.width > size.height) { // landscape
    1.25 -        retval = size;
    1.26 -    } else {  // portrait
    1.27 -        retval.width = size.height;
    1.28 -        retval.height = size.width;
    1.29 -    }
    1.30 -    return retval;
    1.31 -}
    1.32 -
    1.33  static void
    1.34  UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
    1.35  {
    1.36 @@ -156,18 +130,19 @@
    1.37      if (!SDL_UIKit_supports_multiple_displays) {
    1.38          const CGRect rect = [uiscreen bounds];
    1.39          mode.format = SDL_PIXELFORMAT_ABGR8888;
    1.40 +        mode.refresh_rate = 0;
    1.41 +        mode.driverdata = NULL;
    1.42 +
    1.43          mode.w = (int) rect.size.width;
    1.44          mode.h = (int) rect.size.height;
    1.45 -        mode.refresh_rate = 0;
    1.46 -        mode.driverdata = NULL;
    1.47          SDL_AddDisplayMode(display, &mode);
    1.48 +
    1.49          mode.w = (int) rect.size.height;  // swap the orientation, add again.
    1.50          mode.h = (int) rect.size.width;
    1.51          SDL_AddDisplayMode(display, &mode);
    1.52          return;
    1.53      }
    1.54  
    1.55 -    const BOOL ismain = (uiscreen == [UIScreen mainScreen]);
    1.56      const NSArray *modes = [uiscreen availableModes];
    1.57      for (UIScreenMode *uimode in [uiscreen availableModes]) {
    1.58          CGSize size = [uimode size];
    1.59 @@ -177,20 +152,12 @@
    1.60          mode.w = (int) size.width;
    1.61          mode.h = (int) size.height;
    1.62          if (SDL_AddDisplayMode(display, &mode))
    1.63 -            [uimode retain];
    1.64 +            [uimode retain];        // retain is needed because of mode.driverdata
    1.65  
    1.66 -        if (ismain) {
    1.67 -            // Add the mode twice, flipped to portrait and landscape.
    1.68 -            //  SDL_AddDisplayMode() will ignore duplicates.
    1.69 -            size = UIKit_ForcePortrait([uimode size]);
    1.70 -            mode.w = (int) size.width;
    1.71 -            mode.h = (int) size.height;
    1.72 -            if (SDL_AddDisplayMode(display, &mode))
    1.73 -                [uimode retain];
    1.74 -
    1.75 -            size = UIKit_ForceLandscape(size);
    1.76 -            mode.w = (int) size.width;
    1.77 -            mode.h = (int) size.height;
    1.78 +        if (uiscreen == [UIScreen mainScreen]) {
    1.79 +            // Add the mode with swapped width/height
    1.80 +            mode.w = (int) size.height;
    1.81 +            mode.h = (int) size.width;
    1.82              if (SDL_AddDisplayMode(display, &mode))
    1.83                  [uimode retain];
    1.84          }
    1.85 @@ -239,8 +206,8 @@
    1.86          // Just give 'em the whole main screen.
    1.87          UIScreen *uiscreen = [UIScreen mainScreen];
    1.88          UIScreenMode *uiscreenmode = [uiscreen currentMode];
    1.89 -        const CGRect rect = [uiscreen bounds];
    1.90 -        UIKit_AddDisplay(uiscreen, uiscreenmode, (int)rect.size.width, (int)rect.size.height);
    1.91 +        const CGSize size = [uiscreen bounds].size;
    1.92 +        UIKit_AddDisplay(uiscreen, uiscreenmode, (int)size.width, (int)size.height);
    1.93      } else {
    1.94          for (UIScreen *uiscreen in [UIScreen screens]) {
    1.95              // the main screen is the first element in the array.