Fix for http://bugs.webkit.org/show_bug.cgi?id=16136
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Nov 2007 19:19:06 +0000 (19:19 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Nov 2007 19:19:06 +0000 (19:19 +0000)
        Use shared PixelDumpSupport for Mac DRT

        Reviewed by Adam Roben.

        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
        * DumpRenderTree/PixelDumpSupport.h: Copied from DumpRenderTree/win/PixelDumpSupport.h.
        * DumpRenderTree/cg/ImageDiffCG.cpp:
        * DumpRenderTree/cg/PixelDumpSupportCG.cpp:
        (drawSelectionRectIntoContext):
        (dumpWebViewAsPixelsAndCompareWithExpected):
        * DumpRenderTree/cg/PixelDumpSupportCG.h:
        * DumpRenderTree/mac/Configurations/Base.xcconfig:
        * DumpRenderTree/mac/DumpRenderTree.mm:
        (dump):
        * DumpRenderTree/mac/ImageDiff.m: Removed.
        * DumpRenderTree/mac/PixelDumpSupport.h: Removed.
        * DumpRenderTree/mac/PixelDumpSupport.mm: Removed.
        * DumpRenderTree/mac/PixelDumpSupportMac.mm: Copied from DumpRenderTree/mac/PixelDumpSupport.mm.
        (setDefaultColorProfileToRGB):
        (getBitmapContextFromWebView):
        (drawWebViewIntoContext):
        (repaintWithVerticalSweep):
        (repaintWithHorizontalSweep):
        (getSelectionRect):
        * DumpRenderTree/win/PixelDumpSupport.h: Removed.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28042 268f45cc-cd09-0410-ab3c-d52691b4dbfc

12 files changed:
WebKitTools/ChangeLog
WebKitTools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj
WebKitTools/DumpRenderTree/PixelDumpSupport.h [moved from WebKitTools/DumpRenderTree/win/PixelDumpSupport.h with 87% similarity]
WebKitTools/DumpRenderTree/cg/ImageDiffCG.cpp
WebKitTools/DumpRenderTree/cg/PixelDumpSupportCG.cpp
WebKitTools/DumpRenderTree/cg/PixelDumpSupportCG.h
WebKitTools/DumpRenderTree/mac/Configurations/Base.xcconfig
WebKitTools/DumpRenderTree/mac/DumpRenderTree.mm
WebKitTools/DumpRenderTree/mac/ImageDiff.m [deleted file]
WebKitTools/DumpRenderTree/mac/PixelDumpSupport.h [deleted file]
WebKitTools/DumpRenderTree/mac/PixelDumpSupport.mm [deleted file]
WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm [new file with mode: 0644]

index 7b432d5ab9d1f51223b3b53beaedbc57fb796be5..1088d2f34c20ec6856c259ea15f11e6d0dd075b8 100644 (file)
@@ -1,3 +1,32 @@
+2007-11-26  Sam Weinig  <sam@webkit.org>
+
+        Fix for http://bugs.webkit.org/show_bug.cgi?id=16136
+        Use shared PixelDumpSupport for Mac DRT
+
+        Reviewed by Adam Roben.
+
+        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+        * DumpRenderTree/PixelDumpSupport.h: Copied from DumpRenderTree/win/PixelDumpSupport.h.
+        * DumpRenderTree/cg/ImageDiffCG.cpp:
+        * DumpRenderTree/cg/PixelDumpSupportCG.cpp:
+        (drawSelectionRectIntoContext):
+        (dumpWebViewAsPixelsAndCompareWithExpected):
+        * DumpRenderTree/cg/PixelDumpSupportCG.h:
+        * DumpRenderTree/mac/Configurations/Base.xcconfig:
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (dump):
+        * DumpRenderTree/mac/ImageDiff.m: Removed.
+        * DumpRenderTree/mac/PixelDumpSupport.h: Removed.
+        * DumpRenderTree/mac/PixelDumpSupport.mm: Removed.
+        * DumpRenderTree/mac/PixelDumpSupportMac.mm: Copied from DumpRenderTree/mac/PixelDumpSupport.mm.
+        (setDefaultColorProfileToRGB):
+        (getBitmapContextFromWebView):
+        (drawWebViewIntoContext):
+        (repaintWithVerticalSweep):
+        (repaintWithHorizontalSweep):
+        (getSelectionRect):
+        * DumpRenderTree/win/PixelDumpSupport.h: Removed.
+
 2007-11-25  David D. Kilzer  <ddkilzer@webkit.org>
 
         Bug 16052: prepare-ChangeLog doesn't report deleted files
index 7921801b6df4f1b394911a035969f0a790f2acd0..b8f7a6de7f190b71b15ea45c37fa2d5791faca24 100644 (file)
@@ -43,9 +43,7 @@
                A8B91ADC0CF3B32F008F91FF /* DumpRenderTreeWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8B91AD90CF3B32F008F91FF /* DumpRenderTreeWindow.mm */; };
                A8B91AE00CF3B372008F91FF /* DumpRenderTreeWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = A8B91ADD0CF3B372008F91FF /* DumpRenderTreeWindow.h */; };
                A8B91AE20CF3B372008F91FF /* DumpRenderTreePasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = A8B91ADF0CF3B372008F91FF /* DumpRenderTreePasteboard.h */; };
-               A8B91BFA0CF522B4008F91FF /* PixelDumpSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = A8B91BF40CF522B4008F91FF /* PixelDumpSupport.h */; };
                A8B91BFB0CF522B4008F91FF /* JavaScriptThreading.h in Headers */ = {isa = PBXBuildFile; fileRef = A8B91BF50CF522B4008F91FF /* JavaScriptThreading.h */; };
-               A8B91BFC0CF522B4008F91FF /* PixelDumpSupport.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8B91BF60CF522B4008F91FF /* PixelDumpSupport.mm */; settings = {COMPILER_FLAGS = "-Wno-deprecated-declarations"; }; };
                A8B91BFD0CF522B4008F91FF /* CheckedMalloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8B91BF70CF522B4008F91FF /* CheckedMalloc.cpp */; };
                A8B91BFE0CF522B4008F91FF /* JavaScriptThreading.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8B91BF80CF522B4008F91FF /* JavaScriptThreading.cpp */; };
                A8B91BFF0CF522B4008F91FF /* CheckedMalloc.h in Headers */ = {isa = PBXBuildFile; fileRef = A8B91BF90CF522B4008F91FF /* CheckedMalloc.h */; };
                BCA18B7E0C9B08F100114369 /* ObjCPlugin.m in Sources */ = {isa = PBXBuildFile; fileRef = BCA18B770C9B08F100114369 /* ObjCPlugin.m */; };
                BCA18B7F0C9B08F100114369 /* ObjCPluginFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA18B780C9B08F100114369 /* ObjCPluginFunction.h */; };
                BCA18B800C9B08F100114369 /* ObjCPluginFunction.m in Sources */ = {isa = PBXBuildFile; fileRef = BCA18B790C9B08F100114369 /* ObjCPluginFunction.m */; };
-               BCA18B9C0C9B09B400114369 /* ImageDiff.m in Sources */ = {isa = PBXBuildFile; fileRef = BCA18B750C9B08F100114369 /* ImageDiff.m */; };
                BCA18C0B0C9B59EF00114369 /* DumpRenderTreeMac.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA18C0A0C9B59EF00114369 /* DumpRenderTreeMac.h */; };
                BCA18C470C9B5B9400114369 /* DumpRenderTree.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCA18C460C9B5B9400114369 /* DumpRenderTree.mm */; settings = {COMPILER_FLAGS = "-Wno-deprecated-declarations"; }; };
+               BCB284C70CFA83C4007E533E /* PixelDumpSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB2848A0CFA820F007E533E /* PixelDumpSupport.h */; };
+               BCB284CD0CFA83C8007E533E /* PixelDumpSupportCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB284880CFA8202007E533E /* PixelDumpSupportCG.cpp */; };
+               BCB284D00CFA83CC007E533E /* PixelDumpSupportCG.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB284890CFA8202007E533E /* PixelDumpSupportCG.h */; };
+               BCB284D60CFA83D1007E533E /* PixelDumpSupportMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BCB2848C0CFA8221007E533E /* PixelDumpSupportMac.mm */; };
+               BCB284F60CFA84F8007E533E /* ImageDiffCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCB284F30CFA84F2007E533E /* ImageDiffCG.cpp */; };
                BCF6C6500C98E9C000AC063E /* GCController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCF6C64F0C98E9C000AC063E /* GCController.cpp */; };
 /* End PBXBuildFile section */
 
                A8B91AD90CF3B32F008F91FF /* DumpRenderTreeWindow.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = DumpRenderTreeWindow.mm; path = mac/DumpRenderTreeWindow.mm; sourceTree = "<group>"; };
                A8B91ADD0CF3B372008F91FF /* DumpRenderTreeWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DumpRenderTreeWindow.h; path = mac/DumpRenderTreeWindow.h; sourceTree = "<group>"; };
                A8B91ADF0CF3B372008F91FF /* DumpRenderTreePasteboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DumpRenderTreePasteboard.h; path = mac/DumpRenderTreePasteboard.h; sourceTree = "<group>"; };
-               A8B91BF40CF522B4008F91FF /* PixelDumpSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PixelDumpSupport.h; path = mac/PixelDumpSupport.h; sourceTree = "<group>"; };
                A8B91BF50CF522B4008F91FF /* JavaScriptThreading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JavaScriptThreading.h; path = mac/JavaScriptThreading.h; sourceTree = "<group>"; };
-               A8B91BF60CF522B4008F91FF /* PixelDumpSupport.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PixelDumpSupport.mm; path = mac/PixelDumpSupport.mm; sourceTree = "<group>"; };
                A8B91BF70CF522B4008F91FF /* CheckedMalloc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CheckedMalloc.cpp; path = mac/CheckedMalloc.cpp; sourceTree = "<group>"; };
                A8B91BF80CF522B4008F91FF /* JavaScriptThreading.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JavaScriptThreading.cpp; path = mac/JavaScriptThreading.cpp; sourceTree = "<group>"; };
                A8B91BF90CF522B4008F91FF /* CheckedMalloc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CheckedMalloc.h; path = mac/CheckedMalloc.h; sourceTree = "<group>"; };
                BCA18B6E0C9B08DB00114369 /* NavigationController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = NavigationController.m; path = mac/NavigationController.m; sourceTree = "<group>"; };
                BCA18B730C9B08F100114369 /* DumpRenderTreeDraggingInfo.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = DumpRenderTreeDraggingInfo.h; path = mac/DumpRenderTreeDraggingInfo.h; sourceTree = "<group>"; };
                BCA18B740C9B08F100114369 /* DumpRenderTreeDraggingInfo.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = DumpRenderTreeDraggingInfo.mm; path = mac/DumpRenderTreeDraggingInfo.mm; sourceTree = "<group>"; };
-               BCA18B750C9B08F100114369 /* ImageDiff.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = ImageDiff.m; path = mac/ImageDiff.m; sourceTree = "<group>"; };
                BCA18B760C9B08F100114369 /* ObjCPlugin.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ObjCPlugin.h; path = mac/ObjCPlugin.h; sourceTree = "<group>"; };
                BCA18B770C9B08F100114369 /* ObjCPlugin.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = ObjCPlugin.m; path = mac/ObjCPlugin.m; sourceTree = "<group>"; };
                BCA18B780C9B08F100114369 /* ObjCPluginFunction.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = ObjCPluginFunction.h; path = mac/ObjCPluginFunction.h; sourceTree = "<group>"; };
                BCB282F40CFA7450007E533E /* DebugRelease.xcconfig */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xcconfig; name = DebugRelease.xcconfig; path = mac/Configurations/DebugRelease.xcconfig; sourceTree = "<group>"; };
                BCB283D80CFA7AFD007E533E /* ImageDiff.xcconfig */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xcconfig; name = ImageDiff.xcconfig; path = mac/Configurations/ImageDiff.xcconfig; sourceTree = "<group>"; };
                BCB283DE0CFA7C20007E533E /* TestNetscapePlugIn.xcconfig */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xcconfig; name = TestNetscapePlugIn.xcconfig; path = mac/Configurations/TestNetscapePlugIn.xcconfig; sourceTree = "<group>"; };
+               BCB284880CFA8202007E533E /* PixelDumpSupportCG.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 30; name = PixelDumpSupportCG.cpp; path = cg/PixelDumpSupportCG.cpp; sourceTree = "<group>"; };
+               BCB284890CFA8202007E533E /* PixelDumpSupportCG.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = PixelDumpSupportCG.h; path = cg/PixelDumpSupportCG.h; sourceTree = "<group>"; };
+               BCB2848A0CFA820F007E533E /* PixelDumpSupport.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PixelDumpSupport.h; sourceTree = "<group>"; };
+               BCB2848C0CFA8221007E533E /* PixelDumpSupportMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = PixelDumpSupportMac.mm; path = mac/PixelDumpSupportMac.mm; sourceTree = "<group>"; };
+               BCB284B20CFA82CB007E533E /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; };
+               BCB284F30CFA84F2007E533E /* ImageDiffCG.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ImageDiffCG.cpp; path = cg/ImageDiffCG.cpp; sourceTree = "<group>"; };
                BCF6C64F0C98E9C000AC063E /* GCController.cpp */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 30; path = GCController.cpp; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
                08FB7794FE84155DC02AAC07 /* DumpRenderTree */ = {
                        isa = PBXGroup;
                        children = (
+                               32A70AAB03705E1F00C91783 /* DumpRenderTreePrefix.h */,
                                1422A2750AF6F4BD00E1A883 /* Delegates */,
                                1422A2690AF6F45200E1A883 /* Controllers */,
-                               32A70AAB03705E1F00C91783 /* DumpRenderTreePrefix.h */,
+                               BCB284870CFA81ED007E533E /* PixelDump */,
                                A803FF7409CAAD08009B2A37 /* DumpRenderTree.h */,
                                BCA18C460C9B5B9400114369 /* DumpRenderTree.mm */,
                                A8B91BF70CF522B4008F91FF /* CheckedMalloc.cpp */,
                                A8B91BF90CF522B4008F91FF /* CheckedMalloc.h */,
                                A8B91BF80CF522B4008F91FF /* JavaScriptThreading.cpp */,
                                A8B91BF50CF522B4008F91FF /* JavaScriptThreading.h */,
-                               A8B91BF40CF522B4008F91FF /* PixelDumpSupport.h */,
-                               A8B91BF60CF522B4008F91FF /* PixelDumpSupport.mm */,
                                BCA18C0A0C9B59EF00114369 /* DumpRenderTreeMac.h */,
                                BCA18B730C9B08F100114369 /* DumpRenderTreeDraggingInfo.h */,
                                BCA18B740C9B08F100114369 /* DumpRenderTreeDraggingInfo.mm */,
-                               BCA18B750C9B08F100114369 /* ImageDiff.m */,
                                BC9D90210C97472D0099A4A3 /* WorkQueue.cpp */,
                                BC9D90220C97472E0099A4A3 /* WorkQueue.h */,
                                BC9D90230C97472E0099A4A3 /* WorkQueueItem.h */,
                A803FF6409CAACC1009B2A37 /* Frameworks */ = {
                        isa = PBXGroup;
                        children = (
-                               9335435F03D75502008635CE /* WebKit.framework */,
+                               BCB284B20CFA82CB007E533E /* ApplicationServices.framework */,
+                               AE8257EF08D22389000507AB /* Carbon.framework */,
+                               A84F608908B136DA00E9745F /* Cocoa.framework */,
                                A817090308B164D300CCB9FB /* JavaScriptCore.framework */,
                                B5A752A108AF5D1F00138E45 /* QuartzCore.framework */,
-                               A84F608908B136DA00E9745F /* Cocoa.framework */,
-                               AE8257EF08D22389000507AB /* Carbon.framework */,
+                               9335435F03D75502008635CE /* WebKit.framework */,
                        );
                        name = Frameworks;
                        sourceTree = "<group>";
                        name = Configurations;
                        sourceTree = "<group>";
                };
+               BCB284870CFA81ED007E533E /* PixelDump */ = {
+                       isa = PBXGroup;
+                       children = (
+                               BCB284F30CFA84F2007E533E /* ImageDiffCG.cpp */,
+                               BCB2848A0CFA820F007E533E /* PixelDumpSupport.h */,
+                               BCB284880CFA8202007E533E /* PixelDumpSupportCG.cpp */,
+                               BCB284890CFA8202007E533E /* PixelDumpSupportCG.h */,
+                               BCB2848C0CFA8221007E533E /* PixelDumpSupportMac.mm */,
+                       );
+                       name = PixelDump;
+                       sourceTree = "<group>";
+               };
 /* End PBXGroup section */
 
 /* Begin PBXHeadersBuildPhase section */
                                BC9D90260C97472E0099A4A3 /* WorkQueueItem.h in Headers */,
                                A8B91AE00CF3B372008F91FF /* DumpRenderTreeWindow.h in Headers */,
                                A8B91AE20CF3B372008F91FF /* DumpRenderTreePasteboard.h in Headers */,
-                               A8B91BFA0CF522B4008F91FF /* PixelDumpSupport.h in Headers */,
                                A8B91BFB0CF522B4008F91FF /* JavaScriptThreading.h in Headers */,
                                A8B91BFF0CF522B4008F91FF /* CheckedMalloc.h in Headers */,
+                               BCB284C70CFA83C4007E533E /* PixelDumpSupport.h in Headers */,
+                               BCB284D00CFA83CC007E533E /* PixelDumpSupportCG.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                BCA18B260C9B015C00114369 /* WorkQueueItemMac.mm in Sources */,
                                A8B91ADA0CF3B32F008F91FF /* DumpRenderTreePasteboard.m in Sources */,
                                A8B91ADC0CF3B32F008F91FF /* DumpRenderTreeWindow.mm in Sources */,
-                               A8B91BFC0CF522B4008F91FF /* PixelDumpSupport.mm in Sources */,
                                A8B91BFD0CF522B4008F91FF /* CheckedMalloc.cpp in Sources */,
                                A8B91BFE0CF522B4008F91FF /* JavaScriptThreading.cpp in Sources */,
+                               BCB284CD0CFA83C8007E533E /* PixelDumpSupportCG.cpp in Sources */,
+                               BCB284D60CFA83D1007E533E /* PixelDumpSupportMac.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                        isa = PBXSourcesBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
-                               BCA18B9C0C9B09B400114369 /* ImageDiff.m in Sources */,
+                               BCB284F60CFA84F8007E533E /* ImageDiffCG.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
similarity index 87%
rename from WebKitTools/DumpRenderTree/win/PixelDumpSupport.h
rename to WebKitTools/DumpRenderTree/PixelDumpSupport.h
index 523c00a62d4e1e5933211336332f16898d0bbfcc..3214d04981f623960d8716772c13e68c56b85177 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Apple, Inc. All rights reserved.
+ * Copyright (C) 2007 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #ifndef PixelDumpSupport_h
 #define PixelDumpSupport_h
 
-// FIXME: This file should move out of the win/ subdirectory.
-
 void dumpWebViewAsPixelsAndCompareWithExpected(const char* currentTest, bool forceAllTestsToDumpPixels);
 
+// Can be used as a signal handler
+void restoreColorSpace(int ignored);
+
+// May change your color space, requiring a call to restoreColorSpace
+void initializeColorSpaceAndScreeBufferForPixelTests();
+
 #endif // PixelDumpSupport_h
index e1892ed3f9cab30a9d2aed053e095f5a5c03e6a4..068f73d7073515bd5db42f329da780d9d00e4da4 100644 (file)
 #include <io.h>
 #endif
 
+#if PLATFORM(MAC)
+#include <LaunchServices/UTCoreTypes.h>
+#endif
+
+#ifndef CGFLOAT_DEFINED
+#ifdef __LP64__
+typedef double CGFloat;
+#else
+typedef float CGFloat;
+#endif
+#define CGFLOAT_DEFINED 1
+#endif
+
 using namespace std;
 
+#if PLATFORM(WIN)
 static const CFStringRef kUTTypePNG = CFSTR("public.png");
+#endif
 
 static RetainPtr<CGImageRef> createImageFromStdin(int bytesRemaining)
 {
index 2e7d79b86943e7bdc2ac88bcec45fc1ba63c685b..a132b04a0a70f78b7fd182c31ef9c06649ecec80 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2006, 2007 Apple, Inc. All rights reserved.
+ * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
  *           (C) 2007 Graham Dennis (graham.dennis@gmail.com)
  *           (C) 2007 Eric Seidel <eric@webkit.org>
  *
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "DumpRenderTree.h"
 #include "PixelDumpSupportCG.h"
 
+#include "LayoutTestController.h"
 #include <ImageIO/CGImageDestination.h>
 #include <wtf/Assertions.h>
 #include <wtf/RetainPtr.h>
 #if PLATFORM(WIN)
 #include "MD5.h"
 #elif PLATFORM(MAC)
+#include <LaunchServices/UTCoreTypes.h>
 #define COMMON_DIGEST_FOR_OPENSSL
 #include <CommonCrypto/CommonDigest.h>
 #endif
 
+#if PLATFORM(WIN)
 static const CFStringRef kUTTypePNG = CFSTR("public.png");
+#endif
 
 static void printPNG(CGImageRef image)
 {
@@ -80,10 +85,32 @@ static void getMD5HashStringForBitmap(CGContextRef bitmap, char string[33])
         snprintf(string, 33, "%s%02x", string, hash[i]);
 }
 
+void drawSelectionRectIntoContext(CGContextRef context, CGRect rect)
+{
+    const CGFloat redColor[4] = { 1.0, 0.0, 0.0, 0.0 };
+
+    CGContextSaveGState(context);
+    CGContextSetStrokeColor(context, redColor);
+    CGContextStrokeRect(context, rect);
+    CGContextRestoreGState(context);
+}
+
 void dumpWebViewAsPixelsAndCompareWithExpected(const char* /*currentTest*/, bool /*forceAllTestsToDumpPixels*/)
 {
     RetainPtr<CGContextRef> context = getBitmapContextFromWebView();
 
+#if PLATFORM(MAC)
+    if (!layoutTestController->testRepaint())
+        drawWebViewIntoContext(context.get());
+    else if (!layoutTestController->testRepaintSweepHorizontally())
+        repaintWithVerticalSweep(context.get());
+    else
+        repaintWithHorizontalSweep(context.get());
+
+    if (layoutTestController->dumpSelectionRect())
+        drawSelectionRectIntoContext(context.get(), getSelectionRect());
+#endif
+
     // Compute the actual hash to compare to the expected image's hash.
     char actualHash[33];
     getMD5HashStringForBitmap(context.get(), actualHash);
index d443d137ff23bd1a5687e0badbc58ca25681e5bc..a3e0e08ea0c6577f7f59903e75eede03e968998f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2006, 2007 Apple, Inc. All rights reserved.
+ * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
  *           (C) 2007 Graham Dennis (graham.dennis@gmail.com)
  *           (C) 2007 Eric Seidel <eric@webkit.org>
  *
 #ifndef PixelDumpSupportCG_h
 #define PixelDumpSupportCG_h
 
-#include <wtf/Platform.h>
 #include <wtf/RetainPtr.h>
 
+#ifndef CGFLOAT_DEFINED
+#ifdef __LP64__
+typedef double CGFloat;
+#else
+typedef float CGFloat;
+#endif
+#define CGFLOAT_DEFINED 1
+#endif
+
 typedef struct CGContext* CGContextRef;
+struct CGRect;
 
 RetainPtr<CGContextRef> getBitmapContextFromWebView();
+CGRect getSelectionRect();
+
+void drawWebViewIntoContext(CGContextRef);
+void repaintWithVerticalSweep(CGContextRef);
+void repaintWithHorizontalSweep(CGContextRef);
+void drawSelectionRectIntoContext(CGContextRef, CGRect);
 
 #endif // PixelDumpSupportCG_h
index d5aa4338c3190d247389648cad5da6d995a696b0..4855fe62c6edc8edb206118b58d3914816d838eb 100644 (file)
@@ -1,5 +1,5 @@
 HEADER_SEARCH_PATHS = ForwardingHeaders
-FRAMEWORK_SEARCH_PATHS = $(SYSTEM_LIBRARY_DIR)/Frameworks/Quartz.framework/Frameworks
+FRAMEWORK_SEARCH_PATHS = $(SYSTEM_LIBRARY_DIR)/Frameworks/Quartz.framework/Frameworks $(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Frameworks
 DEBUG_INFORMATION_FORMAT = dwarf
 PREBINDING = NO
 GCC_C_LANGUAGE_STANDARD = gnu99
index 076593e3adab5f9232700154f5ea1648f33b3875..d81f93462b45e2bb56b91025eb40f50c57eec4f0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2006, 2007 Apple, Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
  *           (C) 2007 Graham Dennis (graham.dennis@gmail.com)
  *
  * Redistribution and use in source and binary forms, with or without
@@ -764,7 +764,7 @@ void dump()
     }
     
     if (dumpPixels)
-        dumpWebViewAsPixelsAndCompareWithExpected(currentTest, dumpAllPixels);
+        dumpWebViewAsPixelsAndCompareWithExpected([currentTest UTF8String], dumpAllPixels);
 
     fflush(stdout);
 
diff --git a/WebKitTools/DumpRenderTree/mac/ImageDiff.m b/WebKitTools/DumpRenderTree/mac/ImageDiff.m
deleted file mode 100644 (file)
index e485b7d..0000000
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (C) 2005 Apple Computer, Inc.  All rights reserved.
- * Copyright (C) 2005 Ben La Monica <ben.lamonica@gmail.com>.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#import <Foundation/Foundation.h>
-#import <QuartzCore/CoreImage.h>
-#import <AppKit/NSBitmapImageRep.h>
-#import <AppKit/NSGraphicsContext.h>
-#import <AppKit/NSCIImageRep.h>
-
-#import <getopt.h>
-
-/* prototypes */
-int main(int argc, const char *argv[]);
-CGImageRef createImageFromStdin(int imageSize);
-void compareImages(CGImageRef actualBitmap, CGImageRef baselineImage, unsigned threshold);
-NSBitmapImageRep *getDifferenceBitmap(CGImageRef actualBitmap, CGImageRef baselineImage);
-float computePercentageDifferent(NSBitmapImageRep *diffBitmap, unsigned threshold);
-
-
-int main(int argc, const char *argv[])
-{
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-    unsigned threshold = 0;
-
-    struct option options[] = {
-        {"threshold", required_argument, NULL, 't'},
-        {NULL, 0, NULL, 0}
-    };
-
-    int option;
-    while ((option = getopt_long(argc, (char * const *)argv, "", options, NULL)) != -1) {
-        switch (option) {
-        case 't':
-            threshold = strtol(optarg, NULL, 0);
-            break;
-        case '?':   // unknown or ambiguous option
-        case ':':   // missing argument
-            exit(1);
-            break;
-        }
-    }
-    
-    char buffer[2048];
-    CGImageRef actualImage = nil;
-    CGImageRef baselineImage = nil;
-
-    NSAutoreleasePool *innerPool = [[NSAutoreleasePool alloc] init];
-    while (fgets(buffer, sizeof(buffer), stdin)) {
-        // remove the CR
-        char *newLineCharacter = strchr(buffer, '\n');
-        if (newLineCharacter) {
-            *newLineCharacter = '\0';
-        }
-        
-        if (strncmp("Content-length: ", buffer, 16) == 0) {
-            strtok(buffer, " ");
-            int imageSize = strtol(strtok(NULL, " "), NULL, 10);
-
-            if(imageSize > 0 && actualImage == nil) 
-                actualImage = createImageFromStdin(imageSize);
-            else if (imageSize > 0 && baselineImage == nil)
-                baselineImage = createImageFromStdin(imageSize);
-            else
-                fputs("error, image size must be specified.\n", stdout);
-        }
-
-        if (actualImage != nil && baselineImage != nil) {
-            compareImages(actualImage, baselineImage, threshold);
-            CGImageRelease(actualImage);
-            CGImageRelease(baselineImage);
-            actualImage = nil;
-            baselineImage = nil;
-            [innerPool release];
-            innerPool = [[NSAutoreleasePool alloc] init];
-        }
-        
-        fflush(stdout);
-    }
-    [innerPool release];
-    
-    [pool release];
-    return 0;
-}
-
-CGImageRef createImageFromStdin(int bytesRemaining)
-{
-    unsigned char buffer[2048];
-    NSMutableData *data = [[NSMutableData alloc] initWithCapacity:bytesRemaining];
-    
-    int bytesRead = 0;
-    while (bytesRemaining > 0) {
-        bytesRead = (bytesRemaining > 2048 ? 2048 : bytesRemaining);
-        fread(buffer, bytesRead, 1, stdin);
-        [data appendBytes:buffer length:bytesRead];
-        bytesRemaining -= bytesRead;
-    }
-    CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((CFDataRef)data);
-    CGImageRef image = CGImageCreateWithPNGDataProvider(dataProvider, NULL, NO, kCGRenderingIntentDefault);
-    [data release];
-    CGDataProviderRelease(dataProvider);
-    
-    return image; 
-}
-
-void compareImages(CGImageRef actualBitmap, CGImageRef baselineBitmap, unsigned threshold)
-{
-    // prepare the difference blend to check for pixel variations
-    NSBitmapImageRep *diffBitmap = getDifferenceBitmap(actualBitmap, baselineBitmap);
-            
-    float percentage = computePercentageDifferent(diffBitmap, threshold);
-    
-    percentage = (float)((int)(percentage * 100.0f)) / 100.0f; // round to 2 decimal places
-    
-    // send message to let them know if an image was wrong
-    if (percentage > 0.0) {
-        // since the diff might actually show something, send it to stdout
-        NSData *diffPNGData = [diffBitmap representationUsingType:NSPNGFileType properties:nil];
-        fprintf(stdout, "Content-length: %d\n", [diffPNGData length]);
-        fwrite([diffPNGData bytes], [diffPNGData length], 1, stdout);
-        fprintf(stdout, "diff: %01.2f%% failed\n", percentage);
-    } else
-        fprintf(stdout, "diff: %01.2f%% passed\n", percentage);
-}
-
-NSBitmapImageRep *getDifferenceBitmap(CGImageRef testBitmap, CGImageRef referenceBitmap)
-{
-    // we must have both images to take diff
-    if (testBitmap == nil || referenceBitmap == nil)
-        return nil;
-
-    NSBitmapImageRep *diffBitmap = [NSBitmapImageRep alloc];
-    [diffBitmap initWithBitmapDataPlanes:NULL
-                              pixelsWide:CGImageGetWidth(testBitmap)
-                              pixelsHigh:CGImageGetHeight(testBitmap)
-                           bitsPerSample:CGImageGetBitsPerComponent(testBitmap)
-                         samplesPerPixel:CGImageGetBitsPerPixel(testBitmap) / CGImageGetBitsPerComponent(testBitmap)
-                                hasAlpha:YES
-                                isPlanar:NO
-                          colorSpaceName:NSCalibratedRGBColorSpace
-                            bitmapFormat:0
-                             bytesPerRow:CGImageGetBytesPerRow(testBitmap)
-                            bitsPerPixel:CGImageGetBitsPerPixel(testBitmap)
-    ];
-
-    NSGraphicsContext *nsContext = [NSGraphicsContext graphicsContextWithBitmapImageRep:diffBitmap];
-    CGContextRef cgContext = [nsContext graphicsPort];
-    CGContextSetBlendMode(cgContext, kCGBlendModeNormal);
-    CGContextDrawImage(cgContext, CGRectMake(0, 0, CGImageGetWidth(testBitmap), CGImageGetHeight(testBitmap)), testBitmap);
-    CGContextSetBlendMode(cgContext, kCGBlendModeDifference);
-    CGContextDrawImage(cgContext, CGRectMake(0, 0, CGImageGetWidth(referenceBitmap), CGImageGetHeight(referenceBitmap)), referenceBitmap);
-
-    return [diffBitmap autorelease];
-}
-
-/**
- * Counts the number of non-black pixels, and returns the percentage
- * of non-black pixels to total pixels in the image.
- */
-float computePercentageDifferent(NSBitmapImageRep *diffBitmap, unsigned threshold)
-{
-    // if diffBiatmap is nil, then there was an error, and it didn't match.
-    if (diffBitmap == nil)
-        return 100.0f;
-    
-    unsigned bitmapFormat = [diffBitmap bitmapFormat];
-    assert(!(bitmapFormat & NSAlphaFirstBitmapFormat));
-    assert(!(bitmapFormat & NSFloatingPointSamplesBitmapFormat));
-    
-    unsigned pixelsHigh = [diffBitmap pixelsHigh];
-    unsigned pixelsWide = [diffBitmap pixelsWide];
-    unsigned bytesPerRow = [diffBitmap bytesPerRow];
-    unsigned char *pixelRowData = [diffBitmap bitmapData];
-    unsigned differences = 0;
-    
-    // NOTE: This may not be safe when switching between ENDIAN types
-    for (unsigned row = 0; row < pixelsHigh; row++) {
-        for (unsigned col = 0; col < (pixelsWide * 4); col += 4) {
-            unsigned char* red = pixelRowData + col;
-            unsigned char* green = red + 1;
-            unsigned char* blue = red + 2;
-            unsigned distance = *red + *green + *blue;
-            if (distance > threshold) {
-                differences++;
-                // shift the pixels towards white to make them more visible
-                *red = MIN(UCHAR_MAX, *red + 100);
-                *green = MIN(UCHAR_MAX, *green + 100);
-                *blue = MIN(UCHAR_MAX, *blue + 100);
-            }
-        }
-        pixelRowData += bytesPerRow;
-    }
-    
-    float totalPixels = pixelsHigh * pixelsWide;
-    return (differences * 100.f) / totalPixels;
-}
diff --git a/WebKitTools/DumpRenderTree/mac/PixelDumpSupport.h b/WebKitTools/DumpRenderTree/mac/PixelDumpSupport.h
deleted file mode 100644 (file)
index 13d734d..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007 Apple, Inc.  All rights reserved.
- *           (C) 2007 Graham Dennis (graham.dennis@gmail.com)
- *           (C) 2007 Eric Seidel <eric@webkit.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-// can be used as a signal handler
-void restoreColorSpace(int ignored);
-
-// may change your color space, requiring a call to restoreColorSpace
-void initializeColorSpaceAndScreeBufferForPixelTests();
-
-// a poor abstraction, parts of this should be in this file, and parts should not
-void dumpWebViewAsPixelsAndCompareWithExpected(NSString *currentTest, bool forceAllTestsToDumpPixels);
diff --git a/WebKitTools/DumpRenderTree/mac/PixelDumpSupport.mm b/WebKitTools/DumpRenderTree/mac/PixelDumpSupport.mm
deleted file mode 100644 (file)
index 78ead00..0000000
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2007 Apple, Inc.  All rights reserved.
- *           (C) 2007 Graham Dennis (graham.dennis@gmail.com)
- *           (C) 2007 Eric Seidel <eric@webkit.org>
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer. 
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution. 
- * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission. 
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-#import "PixelDumpSupport.h"
-
-#import "DumpRenderTree.h"
-#import "LayoutTestController.h"
-
-#import <AppKit/AppKit.h>
-#import <ApplicationServices/ApplicationServices.h> // for CMSetDefaultProfileBySpace
-#import <WebKit/WebKit.h>
-#import <WebKit/WebDocumentPrivate.h>
-
-#import <unistd.h> // Tiger seems to need this for F_OK
-
-#define COMMON_DIGEST_FOR_OPENSSL
-#import <CommonCrypto/CommonDigest.h>               // for MD5 functions
-
-static unsigned char* screenCaptureBuffer;
-
-static CMProfileRef currentColorProfile = 0;
-static CGColorSpaceRef sharedColorSpace;
-
-void restoreColorSpace(int ignored)
-{
-    // 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 (currentColorProfile) {
-        // This call is deprecated in Leopard, but there appears to be no replacement.
-        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()
-{
-    CMProfileRef genericProfile = (CMProfileRef)[[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;
-    char previousProfileNameString[1024];
-    char genericProfileNameString[1024];
-    CMCopyProfileDescriptionString(previousProfile, &previousProfileName);
-    CMCopyProfileDescriptionString(genericProfile, &genericProfileName);
-    CFStringGetCString(previousProfileName, previousProfileNameString, sizeof(previousProfileNameString), kCFStringEncodingUTF8);
-    CFStringGetCString(genericProfileName, genericProfileNameString, sizeof(previousProfileNameString), kCFStringEncodingUTF8);
-    CFRelease(genericProfileName);
-    CFRelease(previousProfileName);
-    
-    fprintf(stderr, "\n\nWARNING: Temporarily changing your system color profile from \"%s\" to \"%s\".\n", previousProfileNameString, genericProfileNameString);
-    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)",
-            genericProfileNameString, error);
-    else {
-        currentColorProfile = previousProfile;
-        signal(SIGINT, restoreColorSpace);
-        signal(SIGHUP, restoreColorSpace);
-        signal(SIGTERM, restoreColorSpace);
-    }
-}
-
-void initializeColorSpaceAndScreeBufferForPixelTests()
-{
-    setDefaultColorProfileToRGB();
-    screenCaptureBuffer = (unsigned char *)malloc(maxViewHeight * maxViewWidth * 4);
-    sharedColorSpace = CGColorSpaceCreateDeviceRGB();
-}
-
-/* Hashes a bitmap and returns a text string for comparison and saving to a file */
-static NSString *md5HashStringForBitmap(CGImageRef bitmap)
-{
-    MD5_CTX md5Context;
-    unsigned char hash[16];
-    
-    unsigned bitsPerPixel = CGImageGetBitsPerPixel(bitmap);
-    assert(bitsPerPixel == 32); // ImageDiff assumes 32 bit RGBA, we must as well.
-    unsigned bytesPerPixel = bitsPerPixel / 8;
-    unsigned pixelsHigh = CGImageGetHeight(bitmap);
-    unsigned pixelsWide = CGImageGetWidth(bitmap);
-    unsigned bytesPerRow = CGImageGetBytesPerRow(bitmap);
-    assert(bytesPerRow >= (pixelsWide * bytesPerPixel));
-    
-    MD5_Init(&md5Context);
-    unsigned char *bitmapData = screenCaptureBuffer;
-    for (unsigned row = 0; row < pixelsHigh; row++) {
-        MD5_Update(&md5Context, bitmapData, pixelsWide * bytesPerPixel);
-        bitmapData += bytesPerRow;
-    }
-    MD5_Final(hash, &md5Context);
-    
-    char hex[33] = "";
-    for (int i = 0; i < 16; i++) {
-        snprintf(hex, 33, "%s%02x", hex, hash[i]);
-    }
-    
-    return [NSString stringWithUTF8String:hex];
-}
-
-void dumpWebViewAsPixelsAndCompareWithExpected(NSString* currentTest, bool forceAllTestsToDumpPixels)
-{
-    if (!layoutTestController->dumpAsText() && !layoutTestController->dumpDOMAsWebArchive() && !layoutTestController->dumpSourceAsWebArchive()) {
-        // grab a bitmap from the view
-        WebView* view = [mainFrame webView];
-        NSSize webViewSize = [view frame].size;
-        
-        CGContextRef cgContext = CGBitmapContextCreate(screenCaptureBuffer, static_cast<size_t>(webViewSize.width), static_cast<size_t>(webViewSize.height), 8, static_cast<size_t>(webViewSize.width) * 4, sharedColorSpace, kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedLast);
-        
-        NSGraphicsContext* savedContext = [[[NSGraphicsContext currentContext] retain] autorelease];
-        NSGraphicsContext* nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:cgContext flipped:NO];
-        [NSGraphicsContext setCurrentContext:nsContext];
-        
-        if (!layoutTestController->testRepaint()) {
-            NSBitmapImageRep *imageRep;
-            [view displayIfNeeded];
-            [view lockFocus];
-            imageRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:[view frame]];
-            [view unlockFocus];
-            [imageRep draw];
-            [imageRep release];
-        } else if (!layoutTestController->testRepaintSweepHorizontally()) {
-            NSRect line = NSMakeRect(0, 0, webViewSize.width, 1);
-            while (line.origin.y < webViewSize.height) {
-                [view displayRectIgnoringOpacity:line inContext:nsContext];
-                line.origin.y++;
-            }
-        } else {
-            NSRect column = NSMakeRect(0, 0, 1, webViewSize.height);
-            while (column.origin.x < webViewSize.width) {
-                [view displayRectIgnoringOpacity:column inContext:nsContext];
-                column.origin.x++;
-            }
-        }
-        if (layoutTestController->dumpSelectionRect()) {
-            NSView *documentView = [[mainFrame frameView] documentView];
-            if ([documentView conformsToProtocol:@protocol(WebDocumentSelection)]) {
-                [[NSColor redColor] set];
-                [NSBezierPath strokeRect:[documentView convertRect:[(id <WebDocumentSelection>)documentView selectionRect] fromView:nil]];
-            }
-        }
-        
-        [NSGraphicsContext setCurrentContext:savedContext];
-        
-        CGImageRef bitmapImage = CGBitmapContextCreateImage(cgContext);
-        CGContextRelease(cgContext);
-        
-        // compute the actual hash to compare to the expected image's hash
-        NSString *actualHash = md5HashStringForBitmap(bitmapImage);
-        printf("\nActualHash: %s\n", [actualHash UTF8String]);
-        
-        BOOL dumpImage;
-        if (forceAllTestsToDumpPixels)
-            dumpImage = YES;
-        else {
-            // FIXME: It's unfortunate that we hardcode the file naming scheme here.
-            // At one time, the perl script had all the knowledge about file layout.
-            // Some day we should restore that setup by passing in more parameters to this tool
-            // or returning more information from the tool to the perl script
-            NSString *baseTestPath = [currentTest stringByDeletingPathExtension];
-            NSString *baselineHashPath = [baseTestPath stringByAppendingString:@"-expected.checksum"];
-            NSString *baselineHash = [NSString stringWithContentsOfFile:baselineHashPath encoding:NSUTF8StringEncoding error:nil];
-            NSString *baselineImagePath = [baseTestPath stringByAppendingString:@"-expected.png"];
-            
-            printf("BaselineHash: %s\n", [baselineHash UTF8String]);
-            
-            /// send the image to stdout if the hash mismatches or if there's no file in the file system
-            dumpImage = ![baselineHash isEqualToString:actualHash] || access([baselineImagePath fileSystemRepresentation], F_OK) != 0;
-        }
-        
-        if (dumpImage) {
-            CFMutableDataRef imageData = CFDataCreateMutable(0, 0);
-            CGImageDestinationRef imageDest = CGImageDestinationCreateWithData(imageData, CFSTR("public.png"), 1, 0);
-            CGImageDestinationAddImage(imageDest, bitmapImage, 0);
-            CGImageDestinationFinalize(imageDest);
-            CFRelease(imageDest);
-            printf("Content-length: %lu\n", CFDataGetLength(imageData));
-            fwrite(CFDataGetBytePtr(imageData), 1, CFDataGetLength(imageData), stdout);
-            CFRelease(imageData);
-        }
-        
-        CGImageRelease(bitmapImage);
-    }
-    
-    printf("#EOF\n");
-}
diff --git a/WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm b/WebKitTools/DumpRenderTree/mac/PixelDumpSupportMac.mm
new file mode 100644 (file)
index 0000000..80bb167
--- /dev/null
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2005, 2006, 2007 Apple Inc. All rights reserved.
+ *           (C) 2007 Graham Dennis (graham.dennis@gmail.com)
+ *           (C) 2007 Eric Seidel <eric@webkit.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "DumpRenderTree.h" 
+#include "PixelDumpSupport.h"
+#include "PixelDumpSupportCG.h"
+
+#include "LayoutTestController.h"
+#include <CoreGraphics/CGBitmapContext.h>
+#include <wtf/Assertions.h>
+#include <wtf/RetainPtr.h>
+
+#import <WebKit/WebDocumentPrivate.h>
+#import <WebKit/WebKit.h>
+
+static unsigned char* screenCaptureBuffer;
+
+static CMProfileRef currentColorProfile = 0;
+static CGColorSpaceRef sharedColorSpace;
+
+void restoreColorSpace(int ignored)
+{
+    // 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 (currentColorProfile) {
+        // This call is deprecated in Leopard, but there appears to be no replacement.
+        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()
+{
+    CMProfileRef genericProfile = (CMProfileRef)[[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;
+    char previousProfileNameString[1024];
+    char genericProfileNameString[1024];
+    CMCopyProfileDescriptionString(previousProfile, &previousProfileName);
+    CMCopyProfileDescriptionString(genericProfile, &genericProfileName);
+    CFStringGetCString(previousProfileName, previousProfileNameString, sizeof(previousProfileNameString), kCFStringEncodingUTF8);
+    CFStringGetCString(genericProfileName, genericProfileNameString, sizeof(previousProfileNameString), kCFStringEncodingUTF8);
+    CFRelease(previousProfileName);
+    CFRelease(genericProfileName);
+
+    fprintf(stderr, "\n\nWARNING: Temporarily changing your system color profile from \"%s\" to \"%s\".\n", previousProfileNameString, genericProfileNameString);
+    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)",
+            genericProfileNameString, error);
+    } else {
+        currentColorProfile = previousProfile;
+        signal(SIGINT, restoreColorSpace);
+        signal(SIGHUP, restoreColorSpace);
+        signal(SIGTERM, restoreColorSpace);
+    }
+}
+
+void initializeColorSpaceAndScreeBufferForPixelTests()
+{
+    setDefaultColorProfileToRGB();
+    screenCaptureBuffer = (unsigned char *)malloc(maxViewHeight * maxViewWidth * 4);
+    sharedColorSpace = CGColorSpaceCreateDeviceRGB();
+}
+
+// Declared in PixelDumpSupportCG.h
+
+RetainPtr<CGContextRef> getBitmapContextFromWebView()
+{
+    NSSize webViewSize = [[mainFrame webView] frame].size;
+    return RetainPtr<CGContextRef>(AdoptCF, CGBitmapContextCreate(screenCaptureBuffer, static_cast<size_t>(webViewSize.width), static_cast<size_t>(webViewSize.height), 8, static_cast<size_t>(webViewSize.width) * 4, sharedColorSpace, kCGBitmapByteOrder32Host | kCGImageAlphaPremultipliedLast));
+}
+
+void drawWebViewIntoContext(CGContextRef context)
+{
+    RetainPtr<NSGraphicsContext> savedContext = [NSGraphicsContext currentContext];
+
+    NSGraphicsContext* nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO];
+    [NSGraphicsContext setCurrentContext:nsContext];
+
+    WebView* view = [mainFrame webView];
+    [view displayIfNeeded];
+    [view lockFocus];
+    NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithFocusedViewRect:[view frame]];
+    [view unlockFocus];
+    [imageRep draw];
+    [imageRep release];
+
+    [NSGraphicsContext setCurrentContext:savedContext.get()];
+}
+
+void repaintWithVerticalSweep(CGContextRef context)
+{
+    RetainPtr<NSGraphicsContext> savedContext = [NSGraphicsContext currentContext];
+
+    NSGraphicsContext* nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO];
+    [NSGraphicsContext setCurrentContext:nsContext];
+
+    WebView *view = [mainFrame webView];
+    NSSize webViewSize = [view frame].size;
+    for (NSRect line = NSMakeRect(0, 0, webViewSize.width, 1); line.origin.y < webViewSize.height; line.origin.y++)
+        [view displayRectIgnoringOpacity:line inContext:nsContext];
+
+    [NSGraphicsContext setCurrentContext:savedContext.get()];
+}
+
+void repaintWithHorizontalSweep(CGContextRef context)
+{
+    RetainPtr<NSGraphicsContext> savedContext = [NSGraphicsContext currentContext];
+
+    NSGraphicsContext* nsContext = [NSGraphicsContext graphicsContextWithGraphicsPort:context flipped:NO];
+    [NSGraphicsContext setCurrentContext:nsContext];
+
+    WebView *view = [mainFrame webView];
+    NSSize webViewSize = [view frame].size;
+    for (NSRect column = NSMakeRect(0, 0, 1, webViewSize.height); column.origin.x < webViewSize.width; column.origin.x++)
+        [view displayRectIgnoringOpacity:column inContext:nsContext];
+
+    [NSGraphicsContext setCurrentContext:savedContext.get()];
+}
+
+CGRect getSelectionRect()
+{
+    NSView *documentView = [[mainFrame frameView] documentView];
+    if ([documentView conformsToProtocol:@protocol(WebDocumentSelection)]) {
+        NSRect rect = [documentView convertRect:[(id <WebDocumentSelection>)documentView selectionRect] fromView:nil];
+        return CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
+    }
+
+    ASSERT_NOT_REACHED();
+    return CGRectZero;
+}