src/video/uikit/SDL_uikitmodes.m
author Alex Szpakowski <slime73@gmail.com>
Sun, 14 Sep 2014 17:04:54 -0300
branchiOS-improvements
changeset 9517 dbe19a0cad97
parent 9510 e19faa3b5d88
child 9525 64e3f446d6d7
permissions -rw-r--r--
Enabling highdpi mode on an iPhone 6 Plus should now create a 1080x1920 OpenGL view, rather than 1242x2208 (414x736@3x.)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
/*
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
  Simple DirectMedia Layer
8149
681eb46b8ac4 Fixed bug 2374 - Update copyright for 2014...
Sam Lantinga <slouken@libsdl.org>
parents: 8093
diff changeset
     3
  Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org>
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
  This software is provided 'as-is', without any express or implied
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
  warranty.  In no event will the authors be held liable for any damages
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
  arising from the use of this software.
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
  Permission is granted to anyone to use this software for any purpose,
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
  including commercial applications, and to alter it and redistribute it
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
  freely, subject to the following restrictions:
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
  1. The origin of this software must not be misrepresented; you must not
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
     claim that you wrote the original software. If you use this software
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
     in a product, an acknowledgment in the product documentation would be
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
     appreciated but is not required.
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
  2. Altered source versions must be plainly marked as such, and must not be
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
     misrepresented as being the original software.
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
  3. This notice may not be removed or altered from any source distribution.
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
*/
8093
b43765095a6f Make internal SDL sources include SDL_internal.h instead of SDL_config.h
Ryan C. Gordon <icculus@icculus.org>
parents: 7191
diff changeset
    21
#include "../../SDL_internal.h"
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
#if SDL_VIDEO_DRIVER_UIKIT
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
#include "SDL_assert.h"
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
#include "SDL_uikitmodes.h"
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    28
@implementation SDL_DisplayData
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    29
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    30
@synthesize uiscreen;
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    31
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    32
@end
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    33
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    34
@implementation SDL_DisplayModeData
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    35
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    36
@synthesize uiscreenmode;
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    37
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    38
@end
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    39
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
static int
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    42
UIKit_AllocateDisplayModeData(SDL_DisplayMode * mode,
9488
f15520430c94 Changed the way retina resolutions are handled in iOS.
Alex Szpakowski <slime73@gmail.com>
parents: 8891
diff changeset
    43
    UIScreenMode * uiscreenmode)
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    44
{
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    45
    SDL_DisplayModeData *data = nil;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
    46
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    47
    if (uiscreenmode != nil) {
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    48
        /* Allocate the display mode data */
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    49
        data = [[SDL_DisplayModeData alloc] init];
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    50
        if (!data) {
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
    51
            return SDL_OutOfMemory();
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    52
        }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
    53
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    54
        data.uiscreenmode = uiscreenmode;
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    55
    }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
    56
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    57
    mode->driverdata = (void *) CFBridgingRetain(data);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
    58
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    59
    return 0;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    60
}
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    61
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    62
static void
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    63
UIKit_FreeDisplayModeData(SDL_DisplayMode * mode)
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    64
{
8891
7b6472f1b7ba Fixed bug 2563 - Remove obsolete code for supporting iOS < 5
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
    65
    if (mode->driverdata != NULL) {
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
    66
        CFRelease(mode->driverdata);
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    67
        mode->driverdata = NULL;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    68
    }
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    69
}
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    70
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    71
static int
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    72
UIKit_AddSingleDisplayMode(SDL_VideoDisplay * display, int w, int h,
9488
f15520430c94 Changed the way retina resolutions are handled in iOS.
Alex Szpakowski <slime73@gmail.com>
parents: 8891
diff changeset
    73
    UIScreenMode * uiscreenmode)
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    74
{
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    75
    SDL_DisplayMode mode;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    76
    SDL_zero(mode);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
    77
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    78
    mode.format = SDL_PIXELFORMAT_ABGR8888;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    79
    mode.refresh_rate = 0;
9488
f15520430c94 Changed the way retina resolutions are handled in iOS.
Alex Szpakowski <slime73@gmail.com>
parents: 8891
diff changeset
    80
    if (UIKit_AllocateDisplayModeData(&mode, uiscreenmode) < 0) {
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    81
        return -1;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    82
    }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
    83
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    84
    mode.w = w;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    85
    mode.h = h;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    86
    if (SDL_AddDisplayMode(display, &mode)) {
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    87
        return 0;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    88
    } else {
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    89
        UIKit_FreeDisplayModeData(&mode);
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    90
        return -1;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    91
    }
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    92
}
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    93
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    94
static int
9488
f15520430c94 Changed the way retina resolutions are handled in iOS.
Alex Szpakowski <slime73@gmail.com>
parents: 8891
diff changeset
    95
UIKit_AddDisplayMode(SDL_VideoDisplay * display, int w, int h,
6520
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
    96
                     UIScreenMode * uiscreenmode, SDL_bool addRotation)
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    97
{
9488
f15520430c94 Changed the way retina resolutions are handled in iOS.
Alex Szpakowski <slime73@gmail.com>
parents: 8891
diff changeset
    98
    if (UIKit_AddSingleDisplayMode(display, w, h, uiscreenmode) < 0) {
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    99
        return -1;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   100
    }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
   101
6520
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   102
    if (addRotation) {
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
   103
        /* Add the rotated version */
9488
f15520430c94 Changed the way retina resolutions are handled in iOS.
Alex Szpakowski <slime73@gmail.com>
parents: 8891
diff changeset
   104
        if (UIKit_AddSingleDisplayMode(display, h, w, uiscreenmode) < 0) {
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   105
            return -1;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   106
        }
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   107
    }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
   108
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   109
    return 0;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   110
}
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   111
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   112
static int
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   113
UIKit_AddDisplay(UIScreen *uiscreen)
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   114
{
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   115
    CGSize size = [uiscreen bounds].size;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   116
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
   117
    /* Make sure the width/height are oriented correctly */
6520
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   118
    if (UIKit_IsDisplayLandscape(uiscreen) != (size.width > size.height)) {
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   119
        CGFloat height = size.width;
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   120
        size.width = size.height;
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   121
        size.height = height;
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   122
    }
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   123
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   124
    SDL_VideoDisplay display;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   125
    SDL_DisplayMode mode;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   126
    SDL_zero(mode);
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   127
    mode.format = SDL_PIXELFORMAT_ABGR8888;
9488
f15520430c94 Changed the way retina resolutions are handled in iOS.
Alex Szpakowski <slime73@gmail.com>
parents: 8891
diff changeset
   128
    mode.w = (int) size.width;
f15520430c94 Changed the way retina resolutions are handled in iOS.
Alex Szpakowski <slime73@gmail.com>
parents: 8891
diff changeset
   129
    mode.h = (int) size.height;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
   130
9488
f15520430c94 Changed the way retina resolutions are handled in iOS.
Alex Szpakowski <slime73@gmail.com>
parents: 8891
diff changeset
   131
    UIScreenMode *uiscreenmode = [uiscreen currentMode];
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
   132
9488
f15520430c94 Changed the way retina resolutions are handled in iOS.
Alex Szpakowski <slime73@gmail.com>
parents: 8891
diff changeset
   133
    if (UIKit_AllocateDisplayModeData(&mode, uiscreenmode) < 0) {
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   134
        return -1;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   135
    }
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   136
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   137
    SDL_zero(display);
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   138
    display.desktop_mode = mode;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   139
    display.current_mode = mode;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   140
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   141
    /* Allocate the display data */
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   142
    SDL_DisplayData *data = [[SDL_DisplayData alloc] init];
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   143
    if (!data) {
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   144
        UIKit_FreeDisplayModeData(&display.desktop_mode);
7037
3fedf1f25b94 Make SDL_SetError and friends unconditionally return -1.
Ryan C. Gordon <icculus@icculus.org>
parents: 6885
diff changeset
   145
        return SDL_OutOfMemory();
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   146
    }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
   147
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   148
    data.uiscreen = uiscreen;
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
   149
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   150
    display.driverdata = (void *) CFBridgingRetain(data);
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   151
    SDL_AddVideoDisplay(&display);
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
   152
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   153
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   154
    return 0;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   155
}
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   156
6520
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   157
SDL_bool
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   158
UIKit_IsDisplayLandscape(UIScreen *uiscreen)
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   159
{
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   160
    if (uiscreen == [UIScreen mainScreen]) {
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   161
        return UIInterfaceOrientationIsLandscape([[UIApplication sharedApplication] statusBarOrientation]);
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   162
    } else {
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   163
        CGSize size = [uiscreen bounds].size;
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   164
        return (size.width > size.height);
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   165
    }
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   166
}
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   167
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   168
int
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   169
UIKit_InitModes(_THIS)
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   170
{
9506
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   171
    @autoreleasepool {
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   172
        for (UIScreen *uiscreen in [UIScreen screens]) {
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   173
            if (UIKit_AddDisplay(uiscreen) < 0) {
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   174
                return -1;
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   175
            }
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   176
        }
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   177
    }
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   178
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   179
    return 0;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   180
}
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   181
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   182
void
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   183
UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   184
{
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   185
    @autoreleasepool {
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   186
        SDL_DisplayData *data = (__bridge SDL_DisplayData *) display->driverdata;
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   187
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   188
        SDL_bool isLandscape = UIKit_IsDisplayLandscape(data.uiscreen);
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   189
        SDL_bool addRotation = (data.uiscreen == [UIScreen mainScreen]);
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   190
        CGFloat scale = data.uiscreen.scale;
6520
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   191
9517
dbe19a0cad97 Enabling highdpi mode on an iPhone 6 Plus should now create a 1080x1920 OpenGL view, rather than 1242x2208 (414x736@3x.)
Alex Szpakowski <slime73@gmail.com>
parents: 9510
diff changeset
   192
#ifdef __IPHONE_8_0
dbe19a0cad97 Enabling highdpi mode on an iPhone 6 Plus should now create a 1080x1920 OpenGL view, rather than 1242x2208 (414x736@3x.)
Alex Szpakowski <slime73@gmail.com>
parents: 9510
diff changeset
   193
        /* The UIScreenMode of an iPhone 6 Plus should be 1080x1920 rather than
dbe19a0cad97 Enabling highdpi mode on an iPhone 6 Plus should now create a 1080x1920 OpenGL view, rather than 1242x2208 (414x736@3x.)
Alex Szpakowski <slime73@gmail.com>
parents: 9510
diff changeset
   194
         * 1242x2208 (414x736@3x), so we should use the native scale. */
dbe19a0cad97 Enabling highdpi mode on an iPhone 6 Plus should now create a 1080x1920 OpenGL view, rather than 1242x2208 (414x736@3x.)
Alex Szpakowski <slime73@gmail.com>
parents: 9510
diff changeset
   195
        if ([data.uiscreen respondsToSelector:@selector(nativeScale)]) {
dbe19a0cad97 Enabling highdpi mode on an iPhone 6 Plus should now create a 1080x1920 OpenGL view, rather than 1242x2208 (414x736@3x.)
Alex Szpakowski <slime73@gmail.com>
parents: 9510
diff changeset
   196
            scale = data.uiscreen.nativeScale;
dbe19a0cad97 Enabling highdpi mode on an iPhone 6 Plus should now create a 1080x1920 OpenGL view, rather than 1242x2208 (414x736@3x.)
Alex Szpakowski <slime73@gmail.com>
parents: 9510
diff changeset
   197
        }
dbe19a0cad97 Enabling highdpi mode on an iPhone 6 Plus should now create a 1080x1920 OpenGL view, rather than 1242x2208 (414x736@3x.)
Alex Szpakowski <slime73@gmail.com>
parents: 9510
diff changeset
   198
#endif
dbe19a0cad97 Enabling highdpi mode on an iPhone 6 Plus should now create a 1080x1920 OpenGL view, rather than 1242x2208 (414x736@3x.)
Alex Szpakowski <slime73@gmail.com>
parents: 9510
diff changeset
   199
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   200
        for (UIScreenMode *uimode in [data.uiscreen availableModes]) {
9517
dbe19a0cad97 Enabling highdpi mode on an iPhone 6 Plus should now create a 1080x1920 OpenGL view, rather than 1242x2208 (414x736@3x.)
Alex Szpakowski <slime73@gmail.com>
parents: 9510
diff changeset
   201
            /* The size of a UIScreenMode is in pixels, but we deal exclusively
dbe19a0cad97 Enabling highdpi mode on an iPhone 6 Plus should now create a 1080x1920 OpenGL view, rather than 1242x2208 (414x736@3x.)
Alex Szpakowski <slime73@gmail.com>
parents: 9510
diff changeset
   202
             * in points (except in SDL_GL_GetDrawableSize.) */
dbe19a0cad97 Enabling highdpi mode on an iPhone 6 Plus should now create a 1080x1920 OpenGL view, rather than 1242x2208 (414x736@3x.)
Alex Szpakowski <slime73@gmail.com>
parents: 9510
diff changeset
   203
            int w = (int)(uimode.size.width / scale);
dbe19a0cad97 Enabling highdpi mode on an iPhone 6 Plus should now create a 1080x1920 OpenGL view, rather than 1242x2208 (414x736@3x.)
Alex Szpakowski <slime73@gmail.com>
parents: 9510
diff changeset
   204
            int h = (int)(uimode.size.height / scale);
6520
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   205
9506
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   206
            /* Make sure the width/height are oriented correctly */
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   207
            if (isLandscape != (w > h)) {
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   208
                int tmp = w;
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   209
                w = h;
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   210
                h = tmp;
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   211
            }
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   212
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   213
            /* Add the native screen resolution. */
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   214
            UIKit_AddDisplayMode(display, w, h, uimode, addRotation);
6520
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   215
        }
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
   216
    }
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   217
}
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   218
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   219
int
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   220
UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode)
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   221
{
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   222
    @autoreleasepool {
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   223
        SDL_DisplayData *data = (__bridge SDL_DisplayData *) display->driverdata;
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   224
        SDL_DisplayModeData *modedata = (__bridge SDL_DisplayModeData *)mode->driverdata;
6520
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   225
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   226
        [data.uiscreen setCurrentMode:modedata.uiscreenmode];
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   227
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   228
        if (data.uiscreen == [UIScreen mainScreen]) {
9506
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   229
            if (mode->w > mode->h) {
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   230
                if (!UIKit_IsDisplayLandscape(data.uiscreen)) {
9506
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   231
                    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO];
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   232
                }
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   233
            } else if (mode->w < mode->h) {
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   234
                if (UIKit_IsDisplayLandscape(data.uiscreen)) {
9506
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   235
                    [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   236
                }
6520
7a7726af31c1 Make sure mode width/height and status bar orientation match
Sam Lantinga <slouken@libsdl.org>
parents: 6518
diff changeset
   237
            }
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   238
        }
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   239
    }
8891
7b6472f1b7ba Fixed bug 2563 - Remove obsolete code for supporting iOS < 5
Sam Lantinga <slouken@libsdl.org>
parents: 8149
diff changeset
   240
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   241
    return 0;
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   242
}
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   243
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   244
void
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   245
UIKit_QuitModes(_THIS)
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   246
{
7191
75360622e65f File style cleanup for the SDL 2.0 release
Sam Lantinga <slouken@libsdl.org>
parents: 7037
diff changeset
   247
    /* Release Objective-C objects, so higher level doesn't free() them. */
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   248
    int i, j;
9506
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   249
    @autoreleasepool {
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   250
        for (i = 0; i < _this->num_displays; i++) {
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   251
            SDL_VideoDisplay *display = &_this->displays[i];
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   252
9506
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   253
            UIKit_FreeDisplayModeData(&display->desktop_mode);
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   254
            for (j = 0; j < display->num_display_modes; j++) {
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   255
                SDL_DisplayMode *mode = &display->display_modes[j];
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   256
                UIKit_FreeDisplayModeData(mode);
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   257
            }
18e3f94bd860 Added missing autorelease pool blocks in UIKit backend code. Fixes memory leak issues, especially in SDL_video.
Alex Szpakowski <slime73@gmail.com>
parents: 9488
diff changeset
   258
9510
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   259
            if (display->driverdata != NULL) {
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   260
                CFRelease(display->driverdata);
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   261
                display->driverdata = NULL;
e19faa3b5d88 Updated the iOS backend code to use Objective-C's automatic reference counting (ARC).
Alex Szpakowski <slime73@gmail.com>
parents: 9506
diff changeset
   262
            }
6518
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   263
        }
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   264
    }
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   265
}
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   266
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   267
#endif /* SDL_VIDEO_DRIVER_UIKIT */
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   268
42948831d16e Refactored the UIKit mode code into a separate file so it's cleaner and more consistent with other backends
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
   269
/* vi: set ts=4 sw=4 expandtab: */