Fixed bug 2696 - Mac: fix display mode refresh rate calculation

Alex Szpakowski

SDL's Cocoa backend uses the CGDisplayMode API to get refresh rate information about a display mode, but CGDisplayModeGetRefreshRate will return 0 on most non-CRT monitors.

The only way I know of to get correct refresh rate information in OS X is via the CoreVideo DisplayLink API.
I have attached a patch which tries to use the CVDisplayLinkGetNominalOutputVideoRefreshPeriod function if CGDisplayModeGetRefreshRate fails, which fixes display mode refresh rate information on the monitors I tested.

The CVDisplayLink API requires linking with the CoreVideo framework, and the patch updates the various build files to do so.
This commit is contained in:
Sam Lantinga 2014-08-23 10:47:50 -07:00
parent a79ed6cea2
commit 059579e48f
8 changed files with 144 additions and 5 deletions

View File

@ -970,6 +970,7 @@ elseif(APPLE)
set_source_files_properties(${EXTRA_SOURCES} PROPERTIES LANGUAGE C)
set(HAVE_SDL_FILE TRUE)
set(SDL_FRAMEWORK_COCOA 1)
set(SDL_FRAMEWORK_COREVIDEO 1)
else()
message_error("SDL_FILE must be enabled to build on MacOS X")
endif()
@ -1029,6 +1030,10 @@ elseif(APPLE)
endif()
# Actually load the frameworks at the end so we don't duplicate include.
if(SDL_FRAMEWORK_COREVIDEO)
find_library(COREVIDEO CoreVideo)
list(APPEND EXTRA_LIBS ${COREVIDEO})
endif()
if(SDL_FRAMEWORK_COCOA)
find_library(COCOA_LIBRARY Cocoa)
list(APPEND EXTRA_LIBS ${COCOA_LIBRARY})

View File

@ -810,6 +810,9 @@
DB31407217554B71006C0E22 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 007317C10858E15000B2BC32 /* Carbon.framework */; };
DB31408B17554D37006C0E22 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 00CFA89C106B4BA100758660 /* ForceFeedback.framework */; };
DB31408D17554D3C006C0E22 /* ForceFeedback.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 00CFA89C106B4BA100758660 /* ForceFeedback.framework */; };
FA73671D19A540EF004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73671C19A540EF004122E4 /* CoreVideo.framework */; };
FA73671E19A54140004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73671C19A540EF004122E4 /* CoreVideo.framework */; };
FA73671F19A54144004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73671C19A540EF004122E4 /* CoreVideo.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -1109,6 +1112,7 @@
F5A2EF3900C6A39A01000001 /* BUGS.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = BUGS.txt; path = ../../BUGS.txt; sourceTree = SOURCE_ROOT; };
F5A2EF3A00C6A3C201000001 /* README-macosx.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = "README-macosx.txt"; path = "../../README-macosx.txt"; sourceTree = SOURCE_ROOT; };
F5F81AD400D706B101000001 /* Readme SDL Developer.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; name = "Readme SDL Developer.txt"; path = "pkg-support/Readme SDL Developer.txt"; sourceTree = SOURCE_ROOT; };
FA73671C19A540EF004122E4 /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = /System/Library/Frameworks/CoreVideo.framework; sourceTree = "<absolute>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -1116,6 +1120,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73671D19A540EF004122E4 /* CoreVideo.framework in Frameworks */,
007317A20858DECD00B2BC32 /* AudioToolbox.framework in Frameworks */,
007317A30858DECD00B2BC32 /* AudioUnit.framework in Frameworks */,
007317A40858DECD00B2BC32 /* Cocoa.framework in Frameworks */,
@ -1131,6 +1136,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73671E19A54140004122E4 /* CoreVideo.framework in Frameworks */,
007317A90858DECD00B2BC32 /* AudioToolbox.framework in Frameworks */,
007317AA0858DECD00B2BC32 /* AudioUnit.framework in Frameworks */,
007317AB0858DECD00B2BC32 /* Cocoa.framework in Frameworks */,
@ -1145,6 +1151,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73671F19A54144004122E4 /* CoreVideo.framework in Frameworks */,
DB31406C17554B71006C0E22 /* AudioToolbox.framework in Frameworks */,
DB31406D17554B71006C0E22 /* AudioUnit.framework in Frameworks */,
DB31406E17554B71006C0E22 /* Cocoa.framework in Frameworks */,
@ -1738,6 +1745,7 @@
BEC562FE0761C0E800A33029 /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
FA73671C19A540EF004122E4 /* CoreVideo.framework */,
00D0D08310675DD9004B05EF /* CoreFoundation.framework */,
007317C10858E15000B2BC32 /* Carbon.framework */,
0073179B0858DECD00B2BC32 /* AudioToolbox.framework */,

View File

@ -555,6 +555,51 @@
DB89957918A19ABA0092407C /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 002A873910730675007319AE /* Carbon.framework */; };
DB89957A18A19ABA0092407C /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 003FA645093FFD41000C53B3 /* libSDL2.a */; };
DB89958418A19B130092407C /* testhotplug.c in Sources */ = {isa = PBXBuildFile; fileRef = DB89958318A19B130092407C /* testhotplug.c */; };
FA73672319A54A90004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73672819A54AB6004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73672919A54AB9004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73672A19A54AC0004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73672B19A54AC2004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73672C19A54AC5004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73672D19A54AC7004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73672E19A54ACA004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73672F19A54ACC004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73673019A54AD0004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73673119A54AD3004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73673219A54AD5004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73673319A54AD8004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73673419A54ADB004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73673519A54ADE004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73673619A54AE1004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73673719A54AE3004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73673819A54AE6004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73673919A54AE8004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73673A19A54AEB004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73673B19A54AED004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73673C19A54AF0004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73673D19A54AF3004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73673E19A54AF6004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73673F19A54AF8004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73674019A54AFB004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73674119A54AFE004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73674219A54B01004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73674319A54B04004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73674419A54B06004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73674519A54B09004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73674619A54B0B004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73674719A54B0F004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73674819A54B13004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73674919A54B16004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73674A19A54B19004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73674B19A54B1B004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73674C19A54B1F004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73674D19A54B22004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73674E19A54B25004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73674F19A54B28004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73675019A54B2B004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73675119A54B2F004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73675219A54B32004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
FA73675319A54B35004122E4 /* CoreVideo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA73672219A54A90004122E4 /* CoreVideo.framework */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -1141,6 +1186,7 @@
DB89957E18A19ABA0092407C /* testhotplug */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = testhotplug; sourceTree = BUILT_PRODUCTS_DIR; };
DB89958318A19B130092407C /* testhotplug.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testhotplug.c; path = ../../test/testhotplug.c; sourceTree = "<group>"; };
DBBC552C182831D700F3CA8D /* TestDropFile-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = "TestDropFile-Info.plist"; sourceTree = "<group>"; };
FA73672219A54A90004122E4 /* CoreVideo.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreVideo.framework; path = /System/Library/Frameworks/CoreVideo.framework; sourceTree = "<absolute>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -1148,6 +1194,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73672919A54AB9004122E4 /* CoreVideo.framework in Frameworks */,
0017957C10741F7900F5D044 /* Cocoa.framework in Frameworks */,
0017957D10741F7900F5D044 /* CoreAudio.framework in Frameworks */,
0017957E10741F7900F5D044 /* ForceFeedback.framework in Frameworks */,
@ -1164,6 +1211,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73672A19A54AC0004122E4 /* CoreVideo.framework in Frameworks */,
0017959D107421BF00F5D044 /* Cocoa.framework in Frameworks */,
0017959E107421BF00F5D044 /* CoreAudio.framework in Frameworks */,
0017959F107421BF00F5D044 /* ForceFeedback.framework in Frameworks */,
@ -1180,6 +1228,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73673319A54AD8004122E4 /* CoreVideo.framework in Frameworks */,
0017971110742F3200F5D044 /* Cocoa.framework in Frameworks */,
0017971210742F3200F5D044 /* CoreAudio.framework in Frameworks */,
0017971310742F3200F5D044 /* ForceFeedback.framework in Frameworks */,
@ -1197,6 +1246,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73673419A54ADB004122E4 /* CoreVideo.framework in Frameworks */,
00179738107430D600F5D044 /* Cocoa.framework in Frameworks */,
00179739107430D600F5D044 /* CoreAudio.framework in Frameworks */,
0017973A107430D600F5D044 /* ForceFeedback.framework in Frameworks */,
@ -1213,6 +1263,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73672B19A54AC2004122E4 /* CoreVideo.framework in Frameworks */,
0017975E107431B300F5D044 /* Cocoa.framework in Frameworks */,
0017975F107431B300F5D044 /* CoreAudio.framework in Frameworks */,
00179760107431B300F5D044 /* ForceFeedback.framework in Frameworks */,
@ -1230,6 +1281,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73673719A54AE3004122E4 /* CoreVideo.framework in Frameworks */,
0017977E107432AE00F5D044 /* Cocoa.framework in Frameworks */,
0017977F107432AE00F5D044 /* CoreAudio.framework in Frameworks */,
00179780107432AE00F5D044 /* ForceFeedback.framework in Frameworks */,
@ -1247,6 +1299,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73673819A54AE6004122E4 /* CoreVideo.framework in Frameworks */,
0017979E1074334C00F5D044 /* Cocoa.framework in Frameworks */,
0017979F1074334C00F5D044 /* CoreAudio.framework in Frameworks */,
001797A01074334C00F5D044 /* ForceFeedback.framework in Frameworks */,
@ -1264,6 +1317,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73673B19A54AED004122E4 /* CoreVideo.framework in Frameworks */,
001797C0107433C600F5D044 /* Cocoa.framework in Frameworks */,
001797C1107433C600F5D044 /* CoreAudio.framework in Frameworks */,
001797C2107433C600F5D044 /* ForceFeedback.framework in Frameworks */,
@ -1280,6 +1334,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73673E19A54AF6004122E4 /* CoreVideo.framework in Frameworks */,
001798021074355200F5D044 /* Cocoa.framework in Frameworks */,
001798031074355200F5D044 /* CoreAudio.framework in Frameworks */,
001798041074355200F5D044 /* ForceFeedback.framework in Frameworks */,
@ -1296,6 +1351,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73673F19A54AF8004122E4 /* CoreVideo.framework in Frameworks */,
001798841074392D00F5D044 /* Cocoa.framework in Frameworks */,
001798851074392D00F5D044 /* CoreAudio.framework in Frameworks */,
001798861074392D00F5D044 /* ForceFeedback.framework in Frameworks */,
@ -1312,6 +1368,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73674219A54B01004122E4 /* CoreVideo.framework in Frameworks */,
001798A5107439DF00F5D044 /* Cocoa.framework in Frameworks */,
001798A6107439DF00F5D044 /* CoreAudio.framework in Frameworks */,
001798A7107439DF00F5D044 /* ForceFeedback.framework in Frameworks */,
@ -1328,6 +1385,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73674619A54B0B004122E4 /* CoreVideo.framework in Frameworks */,
001798E210743BEC00F5D044 /* Cocoa.framework in Frameworks */,
001798E310743BEC00F5D044 /* CoreAudio.framework in Frameworks */,
001798E410743BEC00F5D044 /* ForceFeedback.framework in Frameworks */,
@ -1344,6 +1402,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73674C19A54B1F004122E4 /* CoreVideo.framework in Frameworks */,
0017990610743F1000F5D044 /* Cocoa.framework in Frameworks */,
0017990710743F1000F5D044 /* CoreAudio.framework in Frameworks */,
0017990810743F1000F5D044 /* ForceFeedback.framework in Frameworks */,
@ -1361,6 +1420,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73675219A54B32004122E4 /* CoreVideo.framework in Frameworks */,
0017992810743FB700F5D044 /* Cocoa.framework in Frameworks */,
0017992910743FB700F5D044 /* CoreAudio.framework in Frameworks */,
0017992A10743FB700F5D044 /* ForceFeedback.framework in Frameworks */,
@ -1378,6 +1438,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73672F19A54ACC004122E4 /* CoreVideo.framework in Frameworks */,
002F340B09CA1BFF00EBEB88 /* Cocoa.framework in Frameworks */,
002A866B10730548007319AE /* CoreAudio.framework in Frameworks */,
002A866C10730548007319AE /* ForceFeedback.framework in Frameworks */,
@ -1394,6 +1455,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73673619A54AE1004122E4 /* CoreVideo.framework in Frameworks */,
002F342A09CA1F0300EBEB88 /* Cocoa.framework in Frameworks */,
002A866210730547007319AE /* CoreAudio.framework in Frameworks */,
002A866310730547007319AE /* ForceFeedback.framework in Frameworks */,
@ -1410,6 +1472,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73674019A54AFB004122E4 /* CoreVideo.framework in Frameworks */,
002F344609CA1FB300EBEB88 /* Cocoa.framework in Frameworks */,
002A868010730549007319AE /* CoreAudio.framework in Frameworks */,
002A868110730549007319AE /* ForceFeedback.framework in Frameworks */,
@ -1426,6 +1489,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73674119A54AFE004122E4 /* CoreVideo.framework in Frameworks */,
002F346309CA204F00EBEB88 /* Cocoa.framework in Frameworks */,
002A868610730549007319AE /* CoreAudio.framework in Frameworks */,
002A868710730549007319AE /* ForceFeedback.framework in Frameworks */,
@ -1442,6 +1506,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73674B19A54B1B004122E4 /* CoreVideo.framework in Frameworks */,
DB166D7116A1CFB200A1396C /* AudioToolbox.framework in Frameworks */,
DB166D7216A1CFB200A1396C /* AudioUnit.framework in Frameworks */,
DB166D7316A1CFB200A1396C /* Carbon.framework in Frameworks */,
@ -1459,6 +1524,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73673119A54AD3004122E4 /* CoreVideo.framework in Frameworks */,
BBFC08C0164C6862003E6A99 /* Cocoa.framework in Frameworks */,
BBFC08C1164C6862003E6A99 /* CoreAudio.framework in Frameworks */,
BBFC08C2164C6862003E6A99 /* ForceFeedback.framework in Frameworks */,
@ -1475,6 +1541,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73672319A54A90004122E4 /* CoreVideo.framework in Frameworks */,
002F33C109CA188600EBEB88 /* Cocoa.framework in Frameworks */,
002A863010730405007319AE /* libSDL2.a in Frameworks */,
002A864D10730546007319AE /* CoreAudio.framework in Frameworks */,
@ -1491,6 +1558,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73672819A54AB6004122E4 /* CoreVideo.framework in Frameworks */,
002F33BF09CA188600EBEB88 /* Cocoa.framework in Frameworks */,
002A865310730547007319AE /* CoreAudio.framework in Frameworks */,
002A865410730547007319AE /* ForceFeedback.framework in Frameworks */,
@ -1507,6 +1575,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73672E19A54ACA004122E4 /* CoreVideo.framework in Frameworks */,
002F33BC09CA188600EBEB88 /* Cocoa.framework in Frameworks */,
002A866E10730548007319AE /* CoreAudio.framework in Frameworks */,
002A866F10730548007319AE /* ForceFeedback.framework in Frameworks */,
@ -1523,6 +1592,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73674F19A54B28004122E4 /* CoreVideo.framework in Frameworks */,
002F33B809CA188600EBEB88 /* Cocoa.framework in Frameworks */,
002A868F1073054A007319AE /* CoreAudio.framework in Frameworks */,
002A86901073054A007319AE /* ForceFeedback.framework in Frameworks */,
@ -1539,6 +1609,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73673919A54AE8004122E4 /* CoreVideo.framework in Frameworks */,
002F33B709CA188600EBEB88 /* Cocoa.framework in Frameworks */,
002A867410730548007319AE /* CoreAudio.framework in Frameworks */,
002A867510730548007319AE /* ForceFeedback.framework in Frameworks */,
@ -1555,6 +1626,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73673A19A54AEB004122E4 /* CoreVideo.framework in Frameworks */,
002F33B509CA188600EBEB88 /* Cocoa.framework in Frameworks */,
002A867710730548007319AE /* CoreAudio.framework in Frameworks */,
002A867810730548007319AE /* ForceFeedback.framework in Frameworks */,
@ -1571,6 +1643,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73673C19A54AF0004122E4 /* CoreVideo.framework in Frameworks */,
002F33B609CA188600EBEB88 /* Cocoa.framework in Frameworks */,
002A867A10730549007319AE /* CoreAudio.framework in Frameworks */,
002A867B10730549007319AE /* ForceFeedback.framework in Frameworks */,
@ -1587,6 +1660,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73674919A54B16004122E4 /* CoreVideo.framework in Frameworks */,
002F33B209CA188600EBEB88 /* Cocoa.framework in Frameworks */,
002A868910730549007319AE /* CoreAudio.framework in Frameworks */,
002A868A10730549007319AE /* ForceFeedback.framework in Frameworks */,
@ -1603,6 +1677,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73675019A54B2B004122E4 /* CoreVideo.framework in Frameworks */,
002F33B009CA188600EBEB88 /* Cocoa.framework in Frameworks */,
002A86981073054A007319AE /* CoreAudio.framework in Frameworks */,
002A86991073054A007319AE /* ForceFeedback.framework in Frameworks */,
@ -1619,6 +1694,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73675119A54B2F004122E4 /* CoreVideo.framework in Frameworks */,
002F33AF09CA188600EBEB88 /* Cocoa.framework in Frameworks */,
002A86951073054A007319AE /* CoreAudio.framework in Frameworks */,
002A86961073054A007319AE /* ForceFeedback.framework in Frameworks */,
@ -1635,6 +1711,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73675319A54B35004122E4 /* CoreVideo.framework in Frameworks */,
002F33AA09CA188600EBEB88 /* Cocoa.framework in Frameworks */,
002A864110730546007319AE /* CoreAudio.framework in Frameworks */,
002A864210730546007319AE /* ForceFeedback.framework in Frameworks */,
@ -1651,6 +1728,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73672C19A54AC5004122E4 /* CoreVideo.framework in Frameworks */,
DB0F48DD17CA51E5008798C5 /* Cocoa.framework in Frameworks */,
DB0F48DE17CA51E5008798C5 /* CoreAudio.framework in Frameworks */,
DB0F48DF17CA51E5008798C5 /* ForceFeedback.framework in Frameworks */,
@ -1667,6 +1745,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73673019A54AD0004122E4 /* CoreVideo.framework in Frameworks */,
DB0F48F317CA5212008798C5 /* Cocoa.framework in Frameworks */,
DB0F48F417CA5212008798C5 /* CoreAudio.framework in Frameworks */,
DB0F48F517CA5212008798C5 /* ForceFeedback.framework in Frameworks */,
@ -1690,6 +1769,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73673219A54AD5004122E4 /* CoreVideo.framework in Frameworks */,
DB166DB116A1D2F600A1396C /* Cocoa.framework in Frameworks */,
DB166DB216A1D2F600A1396C /* CoreAudio.framework in Frameworks */,
DB166DB316A1D2F600A1396C /* ForceFeedback.framework in Frameworks */,
@ -1706,6 +1786,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73673D19A54AF3004122E4 /* CoreVideo.framework in Frameworks */,
DB166DC816A1D36A00A1396C /* Cocoa.framework in Frameworks */,
DB166DC916A1D36A00A1396C /* CoreAudio.framework in Frameworks */,
DB166DCA16A1D36A00A1396C /* ForceFeedback.framework in Frameworks */,
@ -1722,6 +1803,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73674319A54B04004122E4 /* CoreVideo.framework in Frameworks */,
DB166DE016A1D50C00A1396C /* Cocoa.framework in Frameworks */,
DB166DE116A1D50C00A1396C /* CoreAudio.framework in Frameworks */,
DB166DE216A1D50C00A1396C /* ForceFeedback.framework in Frameworks */,
@ -1739,6 +1821,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73674419A54B06004122E4 /* CoreVideo.framework in Frameworks */,
DB166DF716A1D57C00A1396C /* Cocoa.framework in Frameworks */,
DB166DF816A1D57C00A1396C /* CoreAudio.framework in Frameworks */,
DB166DF916A1D57C00A1396C /* ForceFeedback.framework in Frameworks */,
@ -1756,6 +1839,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73674519A54B09004122E4 /* CoreVideo.framework in Frameworks */,
DB166E0E16A1D5AD00A1396C /* Cocoa.framework in Frameworks */,
DB166E0F16A1D5AD00A1396C /* CoreAudio.framework in Frameworks */,
DB166E1016A1D5AD00A1396C /* ForceFeedback.framework in Frameworks */,
@ -1773,6 +1857,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73674719A54B0F004122E4 /* CoreVideo.framework in Frameworks */,
DB166E2B16A1D64D00A1396C /* Cocoa.framework in Frameworks */,
DB166E2C16A1D64D00A1396C /* CoreAudio.framework in Frameworks */,
DB166E2D16A1D64D00A1396C /* ForceFeedback.framework in Frameworks */,
@ -1789,6 +1874,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73674819A54B13004122E4 /* CoreVideo.framework in Frameworks */,
DB166E4116A1D69000A1396C /* Cocoa.framework in Frameworks */,
DB166E4216A1D69000A1396C /* CoreAudio.framework in Frameworks */,
DB166E4316A1D69000A1396C /* ForceFeedback.framework in Frameworks */,
@ -1806,6 +1892,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73674A19A54B19004122E4 /* CoreVideo.framework in Frameworks */,
DB166E5B16A1D6F300A1396C /* Cocoa.framework in Frameworks */,
DB166E5C16A1D6F300A1396C /* CoreAudio.framework in Frameworks */,
DB166E5D16A1D6F300A1396C /* ForceFeedback.framework in Frameworks */,
@ -1822,6 +1909,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73674D19A54B22004122E4 /* CoreVideo.framework in Frameworks */,
DB166E7116A1D78400A1396C /* Cocoa.framework in Frameworks */,
DB166E7216A1D78400A1396C /* CoreAudio.framework in Frameworks */,
DB166E7316A1D78400A1396C /* ForceFeedback.framework in Frameworks */,
@ -1838,6 +1926,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73674E19A54B25004122E4 /* CoreVideo.framework in Frameworks */,
DB166E8416A1D78C00A1396C /* Cocoa.framework in Frameworks */,
DB166E8516A1D78C00A1396C /* CoreAudio.framework in Frameworks */,
DB166E8616A1D78C00A1396C /* ForceFeedback.framework in Frameworks */,
@ -1854,6 +1943,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73672D19A54AC7004122E4 /* CoreVideo.framework in Frameworks */,
DB445EEA18184B7000B306B0 /* Cocoa.framework in Frameworks */,
DB445EEB18184B7000B306B0 /* CoreAudio.framework in Frameworks */,
DB445EEC18184B7000B306B0 /* ForceFeedback.framework in Frameworks */,
@ -1871,6 +1961,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
FA73673519A54ADE004122E4 /* CoreVideo.framework in Frameworks */,
DB89957118A19ABA0092407C /* Cocoa.framework in Frameworks */,
DB89957218A19ABA0092407C /* CoreAudio.framework in Frameworks */,
DB89957318A19ABA0092407C /* ForceFeedback.framework in Frameworks */,
@ -1889,6 +1980,7 @@
002F33A209CA183B00EBEB88 /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
FA73672219A54A90004122E4 /* CoreVideo.framework */,
002A869F10730593007319AE /* AudioToolbox.framework */,
002A871410730623007319AE /* AudioUnit.framework */,
002A873910730675007319AE /* Carbon.framework */,

1
configure vendored
View File

@ -23338,6 +23338,7 @@ $as_echo "#define SDL_TIMER_UNIX 1" >>confdefs.h
# The Mac OS X platform requires special setup.
EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lobjc"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreVideo"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"

View File

@ -3215,6 +3215,7 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
# The Mac OS X platform requires special setup.
EXTRA_CFLAGS="$EXTRA_CFLAGS -fpascal-strings"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lobjc"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreVideo"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Cocoa"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,Carbon"
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,IOKit"

View File

@ -17,6 +17,7 @@ tests on that platform.
The Mac OS X projects currently have reliance on the following dependencies:
-CoreVideo.framework
-AudioToolbox.framework
-AudioUnit.framework
-Cocoa.framework

View File

@ -213,6 +213,7 @@ SDL_project "SDL2"
}
SDL_links
{
"CoreVideo.framework",
"AudioToolbox.framework",
"AudioUnit.framework",
"Cocoa.framework",

View File

@ -27,6 +27,10 @@
/* We need this for IODisplayCreateInfoDictionary and kIODisplayOnlyPreferredName */
#include <IOKit/graphics/IOGraphicsLib.h>
/* We need this for CVDisplayLinkGetNominalOutputVideoRefreshPeriod */
#include <CoreVideo/CVBase.h>
#include <CoreVideo/CVDisplayLink.h>
/* we need this for ShowMenuBar() and HideMenuBar(). */
#include <Carbon/Carbon.h>
@ -114,7 +118,7 @@ CG_SetError(const char *prefix, CGDisplayErr result)
}
static SDL_bool
GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
GetDisplayMode(_THIS, const void *moderef, CVDisplayLinkRef link, SDL_DisplayMode *mode)
{
SDL_DisplayModeData *data;
long width = 0;
@ -133,7 +137,7 @@ GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
CFStringRef fmt = CGDisplayModeCopyPixelEncoding(vidmode);
width = (long) CGDisplayModeGetWidth(vidmode);
height = (long) CGDisplayModeGetHeight(vidmode);
refreshRate = (long) CGDisplayModeGetRefreshRate(vidmode);
refreshRate = (long) (CGDisplayModeGetRefreshRate(vidmode) + 0.5);
if (CFStringCompare(fmt, CFSTR(IO32BitDirectPixels),
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
@ -141,6 +145,9 @@ GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
} else if (CFStringCompare(fmt, CFSTR(IO16BitDirectPixels),
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
bpp = 16;
} else if (CFStringCompare(fmt, CFSTR(kIO30BitDirectPixels),
kCFCompareCaseInsensitive) == kCFCompareEqualTo) {
bpp = 30;
} else {
bpp = 0; /* ignore 8-bit and such for now. */
}
@ -151,6 +158,7 @@ GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
if (!IS_SNOW_LEOPARD_OR_LATER()) {
CFNumberRef number;
double refresh;
CFDictionaryRef vidmode = (CFDictionaryRef) moderef;
number = CFDictionaryGetValue(vidmode, kCGDisplayWidth);
CFNumberGetValue(number, kCFNumberLongType, &width);
@ -159,15 +167,27 @@ GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode)
number = CFDictionaryGetValue(vidmode, kCGDisplayBitsPerPixel);
CFNumberGetValue(number, kCFNumberLongType, &bpp);
number = CFDictionaryGetValue(vidmode, kCGDisplayRefreshRate);
CFNumberGetValue(number, kCFNumberLongType, &refreshRate);
CFNumberGetValue(number, kCFNumberDoubleType, &refresh);
refreshRate = (long) (refresh + 0.5);
}
#endif
/* CGDisplayModeGetRefreshRate returns 0 for many non-CRT displays. */
if (refreshRate == 0 && link != NULL) {
CVTime time = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link);
if ((time.flags & kCVTimeIsIndefinite) == 0 && time.timeValue != 0) {
refreshRate = (long) ((time.timeScale / (double) time.timeValue) + 0.5);
}
}
mode->format = SDL_PIXELFORMAT_UNKNOWN;
switch (bpp) {
case 16:
mode->format = SDL_PIXELFORMAT_ARGB1555;
break;
case 30:
mode->format = SDL_PIXELFORMAT_ARGB2101010;
break;
case 32:
mode->format = SDL_PIXELFORMAT_ARGB8888;
break;
@ -241,6 +261,7 @@ Cocoa_InitModes(_THIS)
SDL_DisplayData *displaydata;
SDL_DisplayMode mode;
const void *moderef = NULL;
CVDisplayLinkRef link = NULL;
if (pass == 0) {
if (!CGDisplayIsMain(displays[i])) {
@ -277,16 +298,21 @@ Cocoa_InitModes(_THIS)
}
displaydata->display = displays[i];
CVDisplayLinkCreateWithCGDisplay(displays[i], &link);
SDL_zero(display);
/* this returns a stddup'ed string */
display.name = (char *)Cocoa_GetDisplayName(displays[i]);
if (!GetDisplayMode (_this, moderef, &mode)) {
if (!GetDisplayMode(_this, moderef, link, &mode)) {
CVDisplayLinkRelease(link);
Cocoa_ReleaseDisplayMode(_this, moderef);
SDL_free(display.name);
SDL_free(displaydata);
continue;
}
CVDisplayLinkRelease(link);
display.desktop_mode = mode;
display.current_mode = mode;
display.driverdata = displaydata;
@ -328,13 +354,16 @@ Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
#endif
if (modes) {
CVDisplayLinkRef link = NULL;
const CFIndex count = CFArrayGetCount(modes);
CFIndex i;
CVDisplayLinkCreateWithCGDisplay(data->display, &link);
for (i = 0; i < count; i++) {
const void *moderef = CFArrayGetValueAtIndex(modes, i);
SDL_DisplayMode mode;
if (GetDisplayMode(_this, moderef, &mode)) {
if (GetDisplayMode(_this, moderef, link, &mode)) {
if (IS_SNOW_LEOPARD_OR_LATER()) {
CGDisplayModeRetain((CGDisplayModeRef) moderef);
}
@ -342,6 +371,7 @@ Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display)
}
}
CVDisplayLinkRelease(link);
Cocoa_ReleaseDisplayModeList(_this, modes);
}
}