Back out the following commits which are causing Dota 2 Exclusive Fullscreen to fail on AMD-based Macs. The details of why this is being reverted are at: https://bugzilla.libsdl.org/show_bug.cgi?id=3949
authorSam Lantinga <slouken@libsdl.org>
Wed, 08 Nov 2017 14:17:23 -0800
changeset 116967dc3cec9ac85
parent 11694 2ce56475ad57
child 11697 2b03795fbd49
Back out the following commits which are causing Dota 2 Exclusive Fullscreen to fail on AMD-based Macs. The details of why this is being reverted are at: https://bugzilla.libsdl.org/show_bug.cgi?id=3949

Alex Szpakowski <slime73@gmail.com> 2017-07-12 21:28 -0300
macOS: Expose more display modes on retina screens. Fixes an issue found in BZFlag.
http://hg.libsdl.org/SDL/rev/1e26564c7288

Alex Szpakowski <slime73@gmail.com> 2017-07-12 21:32 -0300
Fix a potential crash in macOS 10.7 and earlier.
http://hg.libsdl.org/SDL/rev/424607440631
src/video/cocoa/SDL_cocoamodes.m
     1.1 --- a/src/video/cocoa/SDL_cocoamodes.m	Tue Nov 07 09:10:32 2017 -0800
     1.2 +++ b/src/video/cocoa/SDL_cocoamodes.m	Wed Nov 08 14:17:23 2017 -0800
     1.3 @@ -100,47 +100,15 @@
     1.4  }
     1.5  
     1.6  static SDL_bool
     1.7 -GetDisplayMode(_THIS, CGDisplayModeRef vidmode, CFArrayRef modelist, CVDisplayLinkRef link, SDL_DisplayMode *mode)
     1.8 +GetDisplayMode(_THIS, CGDisplayModeRef vidmode, CVDisplayLinkRef link, SDL_DisplayMode *mode)
     1.9  {
    1.10      SDL_DisplayModeData *data;
    1.11 -    int width = (int) CGDisplayModeGetWidth(vidmode);
    1.12 -    int height = (int) CGDisplayModeGetHeight(vidmode);
    1.13 +    int width = 0;
    1.14 +    int height = 0;
    1.15      int bpp = 0;
    1.16      int refreshRate = 0;
    1.17      CFStringRef fmt;
    1.18  
    1.19 -    /* Ignore this mode if it's low-dpi (@1x) and we have a high-dpi mode in the
    1.20 -     * list with the same size in points.
    1.21 -     */
    1.22 -#ifdef MAC_OS_X_VERSION_10_8
    1.23 -    if (modelist != NULL && floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7) {
    1.24 -        int pixelW = (int) CGDisplayModeGetPixelWidth(vidmode);
    1.25 -        int pixelH = (int) CGDisplayModeGetPixelHeight(vidmode);
    1.26 -
    1.27 -        if (width == pixelW && height == pixelH) {
    1.28 -            CFIndex modescount = CFArrayGetCount(modelist);
    1.29 -
    1.30 -            for (int i = 0; i < modescount; i++) {
    1.31 -                CGDisplayModeRef othermode = (CGDisplayModeRef) CFArrayGetValueAtIndex(modelist, i);
    1.32 -
    1.33 -                if (CFEqual(vidmode, othermode)) {
    1.34 -                    continue;
    1.35 -                }
    1.36 -
    1.37 -                int otherW = (int) CGDisplayModeGetWidth(othermode);
    1.38 -                int otherH = (int) CGDisplayModeGetHeight(othermode);
    1.39 -
    1.40 -                int otherpixelW = (int) CGDisplayModeGetPixelWidth(othermode);
    1.41 -                int otherpixelH = (int) CGDisplayModeGetPixelHeight(othermode);
    1.42 -
    1.43 -                if (width == otherW && height == otherH && (otherpixelW != otherW || otherpixelH != otherH)) {
    1.44 -                    return SDL_FALSE;
    1.45 -                }
    1.46 -            }
    1.47 -        }
    1.48 -    }
    1.49 -#endif
    1.50 -
    1.51      data = (SDL_DisplayModeData *) SDL_malloc(sizeof(*data));
    1.52      if (!data) {
    1.53          return SDL_FALSE;
    1.54 @@ -148,6 +116,8 @@
    1.55      data->moderef = vidmode;
    1.56  
    1.57      fmt = CGDisplayModeCopyPixelEncoding(vidmode);
    1.58 +    width = (int) CGDisplayModeGetWidth(vidmode);
    1.59 +    height = (int) CGDisplayModeGetHeight(vidmode);
    1.60      refreshRate = (int) (CGDisplayModeGetRefreshRate(vidmode) + 0.5);
    1.61  
    1.62      if (CFStringCompare(fmt, CFSTR(IO32BitDirectPixels),
    1.63 @@ -273,7 +243,7 @@
    1.64              SDL_zero(display);
    1.65              /* this returns a stddup'ed string */
    1.66              display.name = (char *)Cocoa_GetDisplayName(displays[i]);
    1.67 -            if (!GetDisplayMode(_this, moderef, NULL, link, &mode)) {
    1.68 +            if (!GetDisplayMode(_this, moderef, link, &mode)) {
    1.69                  CVDisplayLinkRelease(link);
    1.70                  CGDisplayModeRelease(moderef);
    1.71                  SDL_free(display.name);
    1.72 @@ -370,32 +340,7 @@
    1.73  Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
    1.74  {
    1.75      SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata;
    1.76 -    CFDictionaryRef dict = NULL;
    1.77 -    CFArrayRef modes;
    1.78 -
    1.79 -    /* By default, CGDisplayCopyAllDisplayModes will only get a subset of the
    1.80 -     * system's available modes. For example on a 15" 2016 MBP, users can
    1.81 -     * choose 1920x1080@2x in System Preferences but it won't show up here,
    1.82 -     * unless we specify the option below.
    1.83 -     */
    1.84 -#ifdef MAC_OS_X_VERSION_10_8
    1.85 -    if (floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7) {
    1.86 -        const CFStringRef dictkeys[] = {kCGDisplayShowDuplicateLowResolutionModes};
    1.87 -        const CFBooleanRef dictvalues[] = {kCFBooleanTrue};
    1.88 -        dict = CFDictionaryCreate(NULL,
    1.89 -                                  (const void **)dictkeys,
    1.90 -                                  (const void **)dictvalues,
    1.91 -                                  1,
    1.92 -                                  &kCFCopyStringDictionaryKeyCallBacks,
    1.93 -                                  &kCFTypeDictionaryValueCallBacks);
    1.94 -    }
    1.95 -#endif
    1.96 -
    1.97 -    modes = CGDisplayCopyAllDisplayModes(data->display, dict);
    1.98 -
    1.99 -    if (dict != NULL) {
   1.100 -        CFRelease(dict);
   1.101 -    }
   1.102 +    CFArrayRef modes = CGDisplayCopyAllDisplayModes(data->display, NULL);
   1.103  
   1.104      if (modes) {
   1.105          CVDisplayLinkRef link = NULL;
   1.106 @@ -407,7 +352,7 @@
   1.107          for (i = 0; i < count; i++) {
   1.108              CGDisplayModeRef moderef = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i);
   1.109              SDL_DisplayMode mode;
   1.110 -            if (GetDisplayMode(_this, moderef, modes, link, &mode)) {
   1.111 +            if (GetDisplayMode(_this, moderef, link, &mode)) {
   1.112                  CGDisplayModeRetain(moderef);
   1.113                  SDL_AddDisplayMode(display, &mode);
   1.114              }