Modified: trunk/Tools/ChangeLog (111451 => 111452)
--- trunk/Tools/ChangeLog 2012-03-20 22:24:25 UTC (rev 111451)
+++ trunk/Tools/ChangeLog 2012-03-20 22:32:34 UTC (rev 111452)
@@ -1,3 +1,20 @@
+2012-03-20 Tim Horton <[email protected]>
+
+ [mac] Restore color space switching code to run-webkit-tests
+ https://bugs.webkit.org/show_bug.cgi?id=80571
+ <rdar://problem/11008529>
+
+ Reviewed by Simon Fraser.
+
+ http://trac.webkit.org/changeset/111429 broke tools build on Snow Leopard.
+
+ Use the old CM* API on Snow Leopard, since CGDisplayCreateUUIDFromDisplayID
+ didn't exist until Lion.
+
+ * DumpRenderTree/mac/LayoutTestHelper.m:
+ (installLayoutTestColorProfile):
+ (restoreUserColorProfile):
+
2012-03-20 Adele Peterson <[email protected]>
Update the last test to use EXPECT_WK_STREQ.
Modified: trunk/Tools/DumpRenderTree/mac/LayoutTestHelper.m (111451 => 111452)
--- trunk/Tools/DumpRenderTree/mac/LayoutTestHelper.m 2012-03-20 22:24:25 UTC (rev 111451)
+++ trunk/Tools/DumpRenderTree/mac/LayoutTestHelper.m 2012-03-20 22:32:34 UTC (rev 111452)
@@ -40,6 +40,8 @@
// test script, so it can do the job for multiple DumpRenderTree while they are
// running layout tests.
+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
+
static CFURLRef sUserColorProfileURL;
static void installLayoutTestColorProfile()
@@ -110,6 +112,59 @@
CFRelease(profileInfo);
}
+#else // For Snow Leopard and before, use older CM* API.
+
+const char colorProfilePath[] = "/System/Library/ColorSync/Profiles/Generic RGB Profile.icc";
+
+CMProfileLocation initialColorProfileLocation; // The locType field is initialized to 0 which is the same as cmNoProfileBase.
+
+static void installLayoutTestColorProfile()
+{
+ // To make sure we get consistent colors (not dependent on the chosen color
+ // space of the main display), we force the generic RGB color profile.
+ // This causes a change the user can see.
+
+ const CMDeviceScope scope = { kCFPreferencesCurrentUser, kCFPreferencesCurrentHost };
+
+ CMProfileRef profile = ""
+ int error = CMGetProfileByAVID((CMDisplayIDType)kCGDirectMainDisplay, &profile);
+ if (!error) {
+ UInt32 size = sizeof(initialColorProfileLocation);
+ error = NCMGetProfileLocation(profile, &initialColorProfileLocation, &size);
+ CMCloseProfile(profile);
+ }
+ if (error) {
+ NSLog(@"Failed to get the current color profile. Many pixel tests may fail as a result. Error: %d", (int)error);
+ initialColorProfileLocation.locType = cmNoProfileBase;
+ return;
+ }
+
+ CMProfileLocation location;
+ location.locType = cmPathBasedProfile;
+ strncpy(location.u.pathLoc.path, colorProfilePath, sizeof(location.u.pathLoc.path));
+ error = CMSetDeviceProfile(cmDisplayDeviceClass, (CMDeviceID)kCGDirectMainDisplay, &scope, cmDefaultProfileID, &location);
+ if (error) {
+ NSLog(@"Failed install the GenericRGB color profile. Many pixel tests may fail as a result. Error: %d", (int)error);
+ initialColorProfileLocation.locType = cmNoProfileBase;
+ }
+}
+
+static void restoreUserColorProfile(void)
+{
+ // This is used as a signal handler, and thus the calls into ColorSync are unsafe.
+ // But we might as well try to restore the user's color profile, we're going down anyway...
+ if (initialColorProfileLocation.locType != cmNoProfileBase) {
+ const CMDeviceScope scope = { kCFPreferencesCurrentUser, kCFPreferencesCurrentHost };
+ int error = CMSetDeviceProfile(cmDisplayDeviceClass, (CMDeviceID)kCGDirectMainDisplay, &scope, cmDefaultProfileID, &initialColorProfileLocation);
+ if (error) {
+ NSLog(@"Failed to restore color profile, use System Preferences -> Displays -> Color to reset. Error: %d", (int)error);
+ }
+ initialColorProfileLocation.locType = cmNoProfileBase;
+ }
+}
+
+#endif
+
static void simpleSignalHandler(int sig)
{
// Try to restore the color profile and try to go down cleanly