Title: [124612] trunk/Tools
Revision
124612
Author
[email protected]
Date
2012-08-03 07:39:50 -0700 (Fri, 03 Aug 2012)

Log Message

[chromium mac] DumpRenderTree compile fails with warning/error in LayoutTestHelper.mm with 10.7sdk
https://bugs.webkit.org/show_bug.cgi?id=92820

Reviewed by Jochen Eisinger.

When building with the 10.7 SDK, use newer functions to switch color
profiles. Note that these newer functions aren't available on 10.6,
but we don't intend to ship DRT to users, and no bots that currently
build with the 10.7 SDK ship their binaries to 10.6 testers.

The new code was copied from Apple's DRT/mac/LayoutTestHelper.m.

* DumpRenderTree/chromium/LayoutTestHelper.mm:
(installLayoutTestColorProfile):
(restoreUserColorProfile):
(saveCurrentColorProfile):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (124611 => 124612)


--- trunk/Tools/ChangeLog	2012-08-03 14:37:37 UTC (rev 124611)
+++ trunk/Tools/ChangeLog	2012-08-03 14:39:50 UTC (rev 124612)
@@ -1,3 +1,22 @@
+2012-08-03  Nico Weber  <[email protected]>
+
+        [chromium mac] DumpRenderTree compile fails with warning/error in LayoutTestHelper.mm with 10.7sdk
+        https://bugs.webkit.org/show_bug.cgi?id=92820
+
+        Reviewed by Jochen Eisinger.
+
+        When building with the 10.7 SDK, use newer functions to switch color
+        profiles. Note that these newer functions aren't available on 10.6,
+        but we don't intend to ship DRT to users, and no bots that currently
+        build with the 10.7 SDK ship their binaries to 10.6 testers.
+
+        The new code was copied from Apple's DRT/mac/LayoutTestHelper.m.
+
+        * DumpRenderTree/chromium/LayoutTestHelper.mm:
+        (installLayoutTestColorProfile):
+        (restoreUserColorProfile):
+        (saveCurrentColorProfile):
+
 2012-08-03  Benjamin Poulain  <[email protected]>
 
         StringImpl created from literal should be BufferInternal

Modified: trunk/Tools/DumpRenderTree/chromium/LayoutTestHelper.mm (124611 => 124612)


--- trunk/Tools/DumpRenderTree/chromium/LayoutTestHelper.mm	2012-08-03 14:37:37 UTC (rev 124611)
+++ trunk/Tools/DumpRenderTree/chromium/LayoutTestHelper.mm	2012-08-03 14:39:50 UTC (rev 124612)
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2010 Google Inc. All rights reserved.
+ * Copyright (C) 2012 Apple Inc.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions are
@@ -40,13 +41,97 @@
 
 namespace {
 
+#if defined(MAC_OS_X_VERSION_10_7) && MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
+
+CFURLRef sUserColorProfileURL;
+
+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.
+    
+    CFUUIDRef mainDisplayID = CGDisplayCreateUUIDFromDisplayID(CGMainDisplayID());
+    
+    if (!sUserColorProfileURL) {
+        CFDictionaryRef deviceInfo = ColorSyncDeviceCopyDeviceInfo(kColorSyncDisplayDeviceClass, mainDisplayID);
+
+        if (!deviceInfo) {
+            NSLog(@"No display attached to system; not setting main display's color profile.");
+            CFRelease(mainDisplayID);
+            return;
+        }
+
+        CFDictionaryRef profileInfo = (CFDictionaryRef)CFDictionaryGetValue(deviceInfo, kColorSyncCustomProfiles);
+        if (profileInfo) {
+            sUserColorProfileURL = (CFURLRef)CFDictionaryGetValue(profileInfo, CFSTR("1"));
+            CFRetain(sUserColorProfileURL);
+        } else {
+            profileInfo = (CFDictionaryRef)CFDictionaryGetValue(deviceInfo, kColorSyncFactoryProfiles);
+            CFDictionaryRef factoryProfile = (CFDictionaryRef)CFDictionaryGetValue(profileInfo, CFSTR("1"));
+            sUserColorProfileURL = (CFURLRef)CFDictionaryGetValue(factoryProfile, kColorSyncDeviceProfileURL);
+            CFRetain(sUserColorProfileURL);
+        }
+        
+        CFRelease(deviceInfo);
+    }
+
+    ColorSyncProfileRef genericRGBProfile = ColorSyncProfileCreateWithName(kColorSyncGenericRGBProfile);
+    CFErrorRef error;
+    CFURLRef profileURL = ColorSyncProfileGetURL(genericRGBProfile, &error);
+    if (!profileURL) {
+        NSLog(@"Failed to get URL of Generic RGB color profile! Many pixel tests may fail as a result. Error: %@", error);
+        
+        if (sUserColorProfileURL) {
+            CFRelease(sUserColorProfileURL);
+            sUserColorProfileURL = 0;
+        }
+        
+        CFRelease(genericRGBProfile);
+        CFRelease(mainDisplayID);
+        return;
+    }
+        
+    CFMutableDictionaryRef profileInfo = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    CFDictionarySetValue(profileInfo, kColorSyncDeviceDefaultProfileID, profileURL);
+    
+    if (!ColorSyncDeviceSetCustomProfiles(kColorSyncDisplayDeviceClass, mainDisplayID, profileInfo)) {
+        NSLog(@"Failed to set color profile for main display! Many pixel tests may fail as a result.");
+        
+        if (sUserColorProfileURL) {
+            CFRelease(sUserColorProfileURL);
+            sUserColorProfileURL = 0;
+        }
+    }
+    
+    CFRelease(profileInfo);
+    CFRelease(genericRGBProfile);
+    CFRelease(mainDisplayID);
+}
+
+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 (!sUserColorProfileURL)
+        return;
+    
+    CFUUIDRef mainDisplayID = CGDisplayCreateUUIDFromDisplayID(CGMainDisplayID());
+    CFMutableDictionaryRef profileInfo = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+    CFDictionarySetValue(profileInfo, kColorSyncDeviceDefaultProfileID, sUserColorProfileURL);
+    ColorSyncDeviceSetCustomProfiles(kColorSyncDisplayDeviceClass, mainDisplayID, profileInfo);
+    CFRelease(mainDisplayID);
+    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.
 
-} // namespace
-
-static void installLayoutTestColorProfile()
+void installLayoutTestColorProfile()
 {
     // To make sure we get consistent colors (not dependent on the Main display),
     // we force the generic rgb color profile.  This cases a change the user can
@@ -76,7 +161,7 @@
     }
 }
 
-static void restoreUserColorProfile(void)
+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...
@@ -90,13 +175,17 @@
     }
 }
 
-static void simpleSignalHandler(int sig)
+#endif
+
+void simpleSignalHandler(int sig)
 {
     // Try to restore the color profile and try to go down cleanly
     restoreUserColorProfile();
     exit(128 + sig);
 }
 
+} // namespace
+
 int main(int argc, char* argv[])
 {
     NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to