[webkit-changes] cvs commit: WebKitTools/DumpRenderTree
DumpRenderTree.m
Eric
eseidel at opensource.apple.com
Thu Dec 29 22:38:53 PST 2005
eseidel 05/12/29 22:38:53
Modified: . ChangeLog
DumpRenderTree DumpRenderTree.m
Log:
Bug #: 6155
Submitted by: eseidel
Reviewed by: darin
DumpRenderTree should set a consistent color profile while running
http://bugzilla.opendarwin.org/show_bug.cgi?id=6155
Creates consistent colormatched renderings on every test machine
using the only way possible with Tiger APIs: by setting the
system color profile on the test machine for the duration of the
tests. This will (unfortunately) cause colors to change while
running DumpRenderTree. This can also cause "permanent" color
changes to occur if DRT is to crash (SIGSEGV, etc.) while running.
This is far from ideal, but it's be best way we've found to deal
with the issue for now.
* DumpRenderTree/DumpRenderTree.m:
(restoreColorSpace):
(setDefaultColorProfileToRGB):
(main):
Revision Changes Path
1.134 +21 -0 WebKitTools/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebKitTools/ChangeLog,v
retrieving revision 1.133
retrieving revision 1.134
diff -u -r1.133 -r1.134
--- ChangeLog 22 Dec 2005 07:39:44 -0000 1.133
+++ ChangeLog 30 Dec 2005 06:38:52 -0000 1.134
@@ -1,3 +1,24 @@
+2005-12-30 Eric Seidel <eseidel at apple.com>
+
+ Reviewed by darin.
+
+ DumpRenderTree should set a consistent color profile while running
+ http://bugzilla.opendarwin.org/show_bug.cgi?id=6155
+
+ Creates consistent colormatched renderings on every test machine
+ using the only way possible with Tiger APIs: by setting the
+ system color profile on the test machine for the duration of the
+ tests. This will (unfortunately) cause colors to change while
+ running DumpRenderTree. This can also cause "permanent" color
+ changes to occur if DRT is to crash (SIGSEGV, etc.) while running.
+ This is far from ideal, but it's be best way we've found to deal
+ with the issue for now.
+
+ * DumpRenderTree/DumpRenderTree.m:
+ (restoreColorSpace):
+ (setDefaultColorProfileToRGB):
+ (main):
+
2005-12-20 Alexey Proskuryakov <ap at nypop.com>
Reviewed by Darin Adler.
1.22 +56 -4 WebKitTools/DumpRenderTree/DumpRenderTree.m
Index: DumpRenderTree.m
===================================================================
RCS file: /cvs/root/WebKitTools/DumpRenderTree/DumpRenderTree.m,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- DumpRenderTree.m 19 Dec 2005 19:56:25 -0000 1.21
+++ DumpRenderTree.m 30 Dec 2005 06:38:53 -0000 1.22
@@ -35,12 +35,12 @@
#import <WebKit/WebPreferences.h>
#import <WebKit/WebView.h>
-#import <Carbon/Carbon.h> // for GetCurrentEventTime()
-
-#import <objc/objc-runtime.h> // for class_poseAs
+#import <Carbon/Carbon.h> // for GetCurrentEventTime()
+#import <ApplicationServices/ApplicationServices.h> // for CMSetDefaultProfileBySpace
+#import <objc/objc-runtime.h> // for class_poseAs
#define COMMON_DIGEST_FOR_OPENSSL
-#import <CommonCrypto/CommonDigest.h> // for MD5 functions
+#import <CommonCrypto/CommonDigest.h> // for MD5 functions
#import <getopt.h>
@@ -83,6 +83,52 @@
static NSString *currentTest = nil;
static NSPasteboard *localPasteboard;
+static CMProfileRef currentColorProfile = 0;
+static void restoreColorSpace(int ignored)
+{
+ if (currentColorProfile) {
+ int error = CMSetDefaultProfileByUse(cmDisplayUse, currentColorProfile);
+ if (error)
+ fprintf(stderr, "Failed to retore previous color profile! You may need to open System Preferences : Displays : Color and manually restore your color settings. (Error: %i)", error);
+ currentColorProfile = 0;
+ }
+}
+
+static void setDefaultColorProfileToRGB(void)
+{
+ CMProfileRef genericProfile = [[NSColorSpace genericRGBColorSpace] colorSyncProfile];
+ CMProfileRef previousProfile;
+ int error = CMGetDefaultProfileByUse(cmDisplayUse, &previousProfile);
+ if (error) {
+ fprintf(stderr, "Failed to get current color profile. I will not be able to restore your current profile, thus I'm not changing it. Many pixel tests may fail as a result. (Error: %i)\n", error);
+ return;
+ }
+ if (previousProfile == genericProfile)
+ return;
+ CFStringRef previousProfileName;
+ CFStringRef genericProfileName;
+ CMCopyProfileDescriptionString(previousProfile, &previousProfileName);
+ CMCopyProfileDescriptionString(genericProfile, &genericProfileName);
+
+ fprintf(stderr, "\n\nWARNING: Temporarily changing your system color profile from \"%s\" to \"%s\".\n",
+ CFStringGetCStringPtr(previousProfileName, kCFStringEncodingMacRoman),
+ CFStringGetCStringPtr(genericProfileName, kCFStringEncodingMacRoman));
+ fprintf(stderr, "This allows the WebKit pixel-based regression tests to have consistent color values across all machines.\n");
+ fprintf(stderr, "The colors on your screen will change for the duration of the testing.\n\n");
+
+ if ((error = CMSetDefaultProfileByUse(cmDisplayUse, genericProfile)))
+ fprintf(stderr, "Failed to set color profile to \"%s\"! Many pixel tests will fail as a result. (Error: %i)",
+ CFStringGetCStringPtr(genericProfileName, kCFStringEncodingMacRoman), error);
+ else {
+ currentColorProfile = previousProfile;
+ signal(SIGINT, restoreColorSpace);
+ signal(SIGHUP, restoreColorSpace);
+ signal(SIGTERM, restoreColorSpace);
+ }
+ CFRelease(genericProfileName);
+ CFRelease(previousProfileName);
+}
+
int main(int argc, const char *argv[])
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
@@ -152,6 +198,9 @@
exit(1);
}
+ if (dumpPixels)
+ setDefaultColorProfileToRGB();
+
localPasteboard = [NSPasteboard pasteboardWithUniqueName];
WebView *webView = [[WebView alloc] initWithFrame:NSMakeRect(0, 0, width, height)];
@@ -199,6 +248,9 @@
[localPasteboard releaseGlobally];
localPasteboard = nil;
+ if (dumpPixels)
+ restoreColorSpace(0);
+
[pool release];
return 0;
More information about the webkit-changes
mailing list