Changeset 104745 in webkit
- Timestamp:
- Jan 11, 2012 2:10:18 PM (12 years ago)
- Location:
- trunk/Tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r104740 r104745 1 2012-01-11 Jochen Eisinger <jochen@chromium.org> 2 3 [Chromium] mimic the (old) behavior of the mac port for (re)setting the color profile 4 https://bugs.webkit.org/show_bug.cgi?id=75618 5 6 Eventually, we should get away from setting the display's color profile, as the mac port is doing now. 7 8 Reviewed by Tony Chang. 9 10 * DumpRenderTree/chromium/LayoutTestHelper.mm: 11 (installLayoutTestColorProfile): 12 (restoreUserColorProfile): 13 (main): 14 1 15 2012-01-11 Dirk Pranke <dpranke@chromium.org> 2 16 -
trunk/Tools/DumpRenderTree/chromium/LayoutTestHelper.mm
r57690 r104745 39 39 // running layout tests. 40 40 41 static CMProfileRef userColorProfile = 0; 41 namespace { 42 42 43 static void saveCurrentColorProfile() 44 { 45 CGDirectDisplayID displayID = CGMainDisplayID(); 46 CMProfileRef previousProfile; 47 CMError error = CMGetProfileByAVID((UInt32)displayID, &previousProfile); 48 if (error) { 49 NSLog(@"failed to get the current color profile, pixmaps won't match. " 50 @"Error: %d", (int)error); 51 } else { 52 userColorProfile = previousProfile; 53 } 54 } 43 const char colorProfilePath[] = "/System/Library/ColorSync/Profiles/Generic RGB Profile.icc"; 44 45 CMProfileLocation initialColorProfileLocation; // The locType field is initialized to 0 which is the same as cmNoProfileBase. 46 47 } // namespace 55 48 56 49 static void installLayoutTestColorProfile() … … 59 52 // we force the generic rgb color profile. This cases a change the user can 60 53 // see. 54 const CMDeviceScope scope = { kCFPreferencesCurrentUser, kCFPreferencesCurrentHost }; 61 55 62 CGDirectDisplayID displayID = CGMainDisplayID(); 63 NSColorSpace* genericSpace = [NSColorSpace genericRGBColorSpace]; 64 CMProfileRef genericProfile = (CMProfileRef)[genericSpace colorSyncProfile]; 65 CMError error = CMSetProfileByAVID((UInt32)displayID, genericProfile); 56 CMProfileRef profile = 0; 57 int error = CMGetProfileByAVID((CMDisplayIDType)kCGDirectMainDisplay, &profile); 58 if (!error) { 59 UInt32 size = sizeof(initialColorProfileLocation); 60 error = NCMGetProfileLocation(profile, &initialColorProfileLocation, &size); 61 CMCloseProfile(profile); 62 } 66 63 if (error) { 67 NSLog(@"failed install the generic color profile, pixmaps won't match. " 68 @"Error: %d", (int)error); 64 NSLog(@"failed to get the current color profile, pixmaps won't match. Error: %d", (int)error); 65 initialColorProfileLocation.locType = cmNoProfileBase; 66 return; 67 } 68 69 CMProfileLocation location; 70 location.locType = cmPathBasedProfile; 71 strncpy(location.u.pathLoc.path, colorProfilePath, sizeof(location.u.pathLoc.path)); 72 error = CMSetDeviceProfile(cmDisplayDeviceClass, (CMDeviceID)kCGDirectMainDisplay, &scope, cmDefaultProfileID, &location); 73 if (error) { 74 NSLog(@"failed install the generic color profile, pixmaps won't match. Error: %d", (int)error); 75 initialColorProfileLocation.locType = cmNoProfileBase; 69 76 } 70 77 } … … 72 79 static void restoreUserColorProfile(void) 73 80 { 74 if (!userColorProfile) 75 return; 76 CGDirectDisplayID displayID = CGMainDisplayID(); 77 CMError error = CMSetProfileByAVID((UInt32)displayID, userColorProfile); 78 CMCloseProfile(userColorProfile); 79 if (error) { 80 NSLog(@"Failed to restore color profile, use System Preferences -> " 81 @"Displays -> Color to reset. Error: %d", (int)error); 81 // This is used as a signal handler, and thus the calls into ColorSync are unsafe. 82 // But we might as well try to restore the user's color profile, we're going down anyway... 83 if (initialColorProfileLocation.locType != cmNoProfileBase) { 84 const CMDeviceScope scope = { kCFPreferencesCurrentUser, kCFPreferencesCurrentHost }; 85 int error = CMSetDeviceProfile(cmDisplayDeviceClass, (CMDeviceID)kCGDirectMainDisplay, &scope, cmDefaultProfileID, &initialColorProfileLocation); 86 if (error) { 87 NSLog(@"Failed to restore color profile, use System Preferences -> Displays -> Color to reset. Error: %d", (int)error); 88 } 89 initialColorProfileLocation.locType = cmNoProfileBase; 82 90 } 83 userColorProfile = 0;84 91 } 85 92 … … 101 108 102 109 // Save off the current profile, and then install the layout test profile. 103 saveCurrentColorProfile();104 110 installLayoutTestColorProfile(); 105 111
Note: See TracChangeset
for help on using the changeset viewer.