Title: [97082] trunk/Tools
Revision
97082
Author
simon.fra...@apple.com
Date
2011-10-10 14:02:05 -0700 (Mon, 10 Oct 2011)

Log Message

3D transforms are flattened in WebKit2 snapshots
https://bugs.webkit.org/show_bug.cgi?id=68276

Reviewed by Anders Carlsson.

The WKImage passed from the WebProcess when pixel dumping is created by painting compositing layers
flattened, which flattens 3D transforms. Instead, use CGWindowListCreateImage() to get a snapshot of
the window when doing pixel tests.

Also allow the window to auto-display, so that Core Animation layers are rendered, and animate.

* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: TestInvocationCG became a .mm file
* WebKitTestRunner/cg/TestInvocationCG.mm: Renamed from Tools/WebKitTestRunner/cg/TestInvocationCG.cpp.
(WTR::createBitmapCGContext): Utility function to create a bitmap context.
(WTR::computeMD5HashStringForContext):
(WTR::dumpBitmap):
(WTR::paintRepaintRectOverlay):
(WTR::TestInvocation::dumpPixelsAndCompareWithExpected): Use CGWindowListCreateImage() to
grap a snapshot of the window, rather than relying on the WKImage which was passed from the web process.
* WebKitTestRunner/mac/PlatformWebViewMac.mm:
(WTR::PlatformWebView::PlatformWebView): Remove the line that turned off autoDisplay for the NSWindow.
We need the window to autodisplay for Core Animation to render layers and start animations.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Tools/ChangeLog (97081 => 97082)


--- trunk/Tools/ChangeLog	2011-10-10 21:01:59 UTC (rev 97081)
+++ trunk/Tools/ChangeLog	2011-10-10 21:02:05 UTC (rev 97082)
@@ -1,5 +1,30 @@
 2011-10-10  Simon Fraser  <simon.fra...@apple.com>
 
+        3D transforms are flattened in WebKit2 snapshots
+        https://bugs.webkit.org/show_bug.cgi?id=68276
+
+        Reviewed by Anders Carlsson.
+        
+        The WKImage passed from the WebProcess when pixel dumping is created by painting compositing layers
+        flattened, which flattens 3D transforms. Instead, use CGWindowListCreateImage() to get a snapshot of
+        the window when doing pixel tests.
+        
+        Also allow the window to auto-display, so that Core Animation layers are rendered, and animate.
+
+        * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj: TestInvocationCG became a .mm file
+        * WebKitTestRunner/cg/TestInvocationCG.mm: Renamed from Tools/WebKitTestRunner/cg/TestInvocationCG.cpp.
+        (WTR::createBitmapCGContext): Utility function to create a bitmap context.
+        (WTR::computeMD5HashStringForContext):
+        (WTR::dumpBitmap):
+        (WTR::paintRepaintRectOverlay):
+        (WTR::TestInvocation::dumpPixelsAndCompareWithExpected): Use CGWindowListCreateImage() to
+        grap a snapshot of the window, rather than relying on the WKImage which was passed from the web process.
+        * WebKitTestRunner/mac/PlatformWebViewMac.mm:
+        (WTR::PlatformWebView::PlatformWebView): Remove the line that turned off autoDisplay for the NSWindow.
+        We need the window to autodisplay for Core Animation to render layers and start animations.
+
+2011-10-10  Simon Fraser  <simon.fra...@apple.com>
+
         WebKitTestRunner needs layoutTestController.setWindowIsKey
         https://bugs.webkit.org/show_bug.cgi?id=42688
 

Modified: trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj (97081 => 97082)


--- trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj	2011-10-10 21:01:59 UTC (rev 97081)
+++ trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj	2011-10-10 21:02:05 UTC (rev 97082)
@@ -54,7 +54,7 @@
 		BC8DAD7B1316D91000EC96FC /* InjectedBundleMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC8DAD771316D7B900EC96FC /* InjectedBundleMac.mm */; };
 		BC8FD8CA120E527F00F3E71A /* EventSendingController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC8FD8C9120E527F00F3E71A /* EventSendingController.cpp */; };
 		BC8FD8D2120E545B00F3E71A /* JSEventSendingController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC8FD8D0120E545B00F3E71A /* JSEventSendingController.cpp */; };
-		BC9192051333E4F8003011DC /* TestInvocationCG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC9192041333E4F8003011DC /* TestInvocationCG.cpp */; };
+		BC9192051333E4F8003011DC /* TestInvocationCG.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC9192041333E4F8003011DC /* TestInvocationCG.mm */; };
 		BC952C0D11F3B965003398B4 /* JSWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC952C0C11F3B965003398B4 /* JSWrapper.cpp */; };
 		BC952F1F11F3C652003398B4 /* JSLayoutTestController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC952F1D11F3C652003398B4 /* JSLayoutTestController.cpp */; };
 		BCC997A411D3C8F60017BCA2 /* InjectedBundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCC997A011D3C8F60017BCA2 /* InjectedBundle.cpp */; };
@@ -138,7 +138,7 @@
 		BC8FD8CB120E52B000F3E71A /* EventSendingController.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = EventSendingController.idl; sourceTree = "<group>"; };
 		BC8FD8D0120E545B00F3E71A /* JSEventSendingController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = JSEventSendingController.cpp; path = DerivedSources/WebKitTestRunner/JSEventSendingController.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
 		BC8FD8D1120E545B00F3E71A /* JSEventSendingController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = JSEventSendingController.h; path = DerivedSources/WebKitTestRunner/JSEventSendingController.h; sourceTree = BUILT_PRODUCTS_DIR; };
-		BC9192041333E4F8003011DC /* TestInvocationCG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = TestInvocationCG.cpp; path = cg/TestInvocationCG.cpp; sourceTree = "<group>"; };
+		BC9192041333E4F8003011DC /* TestInvocationCG.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestInvocationCG.mm; path = cg/TestInvocationCG.mm; sourceTree = "<group>"; };
 		BC952C0B11F3B965003398B4 /* JSWrapper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWrapper.h; sourceTree = "<group>"; };
 		BC952C0C11F3B965003398B4 /* JSWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWrapper.cpp; sourceTree = "<group>"; };
 		BC952C0E11F3B97B003398B4 /* JSWrappable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSWrappable.h; sourceTree = "<group>"; };
@@ -327,7 +327,7 @@
 		BC9192021333E4CD003011DC /* cg */ = {
 			isa = PBXGroup;
 			children = (
-				BC9192041333E4F8003011DC /* TestInvocationCG.cpp */,
+				BC9192041333E4F8003011DC /* TestInvocationCG.mm */,
 			);
 			name = cg;
 			sourceTree = "<group>";
@@ -486,7 +486,7 @@
 				BC793431118F7F19005EA8E2 /* TestController.cpp in Sources */,
 				BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */,
 				BCD7D2F811921278006DB7EE /* TestInvocation.cpp in Sources */,
-				BC9192051333E4F8003011DC /* TestInvocationCG.cpp in Sources */,
+				BC9192051333E4F8003011DC /* TestInvocationCG.mm in Sources */,
 				5670B8281386FCA5002EB355 /* EventSenderProxy.mm in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;

Deleted: trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp (97081 => 97082)


--- trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp	2011-10-10 21:01:59 UTC (rev 97081)
+++ trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp	2011-10-10 21:02:05 UTC (rev 97082)
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2011 Apple Inc. 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 APPLE INC. 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 INC. 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 "config.h"
-#include "TestInvocation.h"
-
-#include "PixelDumpSupport.h"
-#include "PlatformWebView.h"
-#include "TestController.h"
-#include <ImageIO/CGImageDestination.h>
-#include <WebKit2/WKImageCG.h>
-#include <wtf/MD5.h>
-#include <wtf/RetainPtr.h>
-#include <wtf/StringExtras.h>
-
-#if PLATFORM(MAC)
-#include <LaunchServices/UTCoreTypes.h>
-#endif
-
-#if PLATFORM(WIN)
-static const CFStringRef kUTTypePNG = CFSTR("public.png");
-#endif
-
-namespace WTR {
-
-static CGContextRef createCGContextFromImage(WKImageRef wkImage)
-{
-    RetainPtr<CGImageRef> image(AdoptCF, WKImageCreateCGImage(wkImage));
-
-    size_t pixelsWide = CGImageGetWidth(image.get());
-    size_t pixelsHigh = CGImageGetHeight(image.get());
-    size_t rowBytes = (4 * pixelsWide + 63) & ~63;
-    void* buffer = calloc(pixelsHigh, rowBytes);
-
-    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
-    CGContextRef context = CGBitmapContextCreate(buffer, pixelsWide, pixelsHigh, 8, rowBytes, colorSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
-    CGColorSpaceRelease(colorSpace);
-    
-    CGContextDrawImage(context, CGRectMake(0, 0, pixelsWide, pixelsHigh), image.get());
-
-    return context;
-}
-
-void computeMD5HashStringForContext(CGContextRef bitmapContext, char hashString[33])
-{
-    ASSERT(CGBitmapContextGetBitsPerPixel(bitmapContext) == 32); // ImageDiff assumes 32 bit RGBA, we must as well.
-    size_t pixelsHigh = CGBitmapContextGetHeight(bitmapContext);
-    size_t pixelsWide = CGBitmapContextGetWidth(bitmapContext);
-    size_t bytesPerRow = CGBitmapContextGetBytesPerRow(bitmapContext);
-    
-    // We need to swap the bytes to ensure consistent hashes independently of endianness
-    MD5 md5;
-    unsigned char* bitmapData = static_cast<unsigned char*>(CGBitmapContextGetData(bitmapContext));
-#if PLATFORM(MAC)
-    if ((CGBitmapContextGetBitmapInfo(bitmapContext) & kCGBitmapByteOrderMask) == kCGBitmapByteOrder32Big) {
-        for (unsigned row = 0; row < pixelsHigh; row++) {
-            Vector<uint8_t> buffer(4 * pixelsWide);
-            for (unsigned column = 0; column < pixelsWide; column++)
-                buffer[column] = OSReadLittleInt32(bitmapData, 4 * column);
-            md5.addBytes(buffer);
-            bitmapData += bytesPerRow;
-        }
-    } else {
-#endif
-        for (unsigned row = 0; row < pixelsHigh; row++) {
-            md5.addBytes(bitmapData, 4 * pixelsWide);
-            bitmapData += bytesPerRow;
-        }
-#if PLATFORM(MAC)
-    }
-#endif
-
-    Vector<uint8_t, 16> hash;
-    md5.checksum(hash);
-    
-    hashString[0] = '\0';
-    for (int i = 0; i < 16; i++)
-        snprintf(hashString, 33, "%s%02x", hashString, hash[i]);
-}
-
-static void dumpBitmap(CGContextRef bitmapContext, const char* checksum)
-{
-    RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(bitmapContext));
-    RetainPtr<CFMutableDataRef> imageData(AdoptCF, CFDataCreateMutable(0, 0));
-    RetainPtr<CGImageDestinationRef> imageDest(AdoptCF, CGImageDestinationCreateWithData(imageData.get(), kUTTypePNG, 1, 0));
-    CGImageDestinationAddImage(imageDest.get(), image.get(), 0);
-    CGImageDestinationFinalize(imageDest.get());
-
-    const unsigned char* data = ""
-    const size_t dataLength = CFDataGetLength(imageData.get());
-
-    printPNG(data, dataLength, checksum);
-}
-
-static void paintRepaintRectOverlay(CGContextRef context, WKImageRef image, WKArrayRef repaintRects)
-{
-    WKSize imageSize = WKImageGetSize(image);
-
-    CGContextSaveGState(context);
-
-    // Using a transparency layer is easier than futzing with clipping.
-    CGContextBeginTransparencyLayer(context, 0);
-    
-    // Flip the context.
-    CGContextScaleCTM(context, 1, -1);
-    CGContextTranslateCTM(context, 0, -imageSize.height);
-    
-    CGContextSetRGBFillColor(context, 0, 0, 0, static_cast<CGFloat>(0.66));
-    CGContextFillRect(context, CGRectMake(0, 0, imageSize.width, imageSize.height));
-
-    // Clear the repaint rects.
-    size_t count = WKArrayGetSize(repaintRects);
-    for (size_t i = 0; i < count; ++i) {
-        WKRect rect = WKRectGetValue(static_cast<WKRectRef>(WKArrayGetItemAtIndex(repaintRects, i)));
-        CGRect cgRect = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
-        CGContextClearRect(context, cgRect);
-    }
-    
-    CGContextEndTransparencyLayer(context);
-    CGContextRestoreGState(context);
-}
-
-void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef image, WKArrayRef repaintRects)
-{
-    CGContextRef context = createCGContextFromImage(image);
-
-    // A non-null repaintRects array means we're doing a repaint test.
-    if (repaintRects)
-        paintRepaintRectOverlay(context, image, repaintRects);
-
-    char actualHash[33];
-    computeMD5HashStringForContext(context, actualHash);
-    if (!compareActualHashToExpectedAndDumpResults(actualHash))
-        dumpBitmap(context, actualHash);
-}
-
-} // namespace WTR

Copied: trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.mm (from rev 97081, trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp) (0 => 97082)


--- trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.mm	                        (rev 0)
+++ trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.mm	2011-10-10 21:02:05 UTC (rev 97082)
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2011 Apple Inc. 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 APPLE INC. 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 INC. 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 "config.h"
+#include "TestInvocation.h"
+
+#include "PixelDumpSupport.h"
+#include "PlatformWebView.h"
+#include "TestController.h"
+#include <ApplicationServices/ApplicationServices.h>
+#include <ImageIO/CGImageDestination.h>
+#include <WebKit2/WKImageCG.h>
+#include <wtf/MD5.h>
+#include <wtf/RetainPtr.h>
+#include <wtf/StringExtras.h>
+
+#if PLATFORM(MAC)
+#include <LaunchServices/UTCoreTypes.h>
+#endif
+
+#if PLATFORM(WIN)
+static const CFStringRef kUTTypePNG = CFSTR("public.png");
+#endif
+
+namespace WTR {
+
+static CGContextRef createBitmapCGContext(size_t width, size_t height)
+{
+    size_t rowBytes = (4 * width + 63) & ~63;
+    void* buffer = calloc(height, rowBytes);
+
+    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+    CGContextRef context = CGBitmapContextCreate(buffer, width, height, 8, rowBytes, colorSpace, kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Host);
+    CGColorSpaceRelease(colorSpace);
+    
+    return context;
+}
+
+void computeMD5HashStringForContext(CGContextRef bitmapContext, char hashString[33])
+{
+    ASSERT(CGBitmapContextGetBitsPerPixel(bitmapContext) == 32); // ImageDiff assumes 32 bit RGBA, we must as well.
+    size_t pixelsHigh = CGBitmapContextGetHeight(bitmapContext);
+    size_t pixelsWide = CGBitmapContextGetWidth(bitmapContext);
+    size_t bytesPerRow = CGBitmapContextGetBytesPerRow(bitmapContext);
+    
+    // We need to swap the bytes to ensure consistent hashes independently of endianness
+    MD5 md5;
+    unsigned char* bitmapData = static_cast<unsigned char*>(CGBitmapContextGetData(bitmapContext));
+#if PLATFORM(MAC)
+    if ((CGBitmapContextGetBitmapInfo(bitmapContext) & kCGBitmapByteOrderMask) == kCGBitmapByteOrder32Big) {
+        for (unsigned row = 0; row < pixelsHigh; row++) {
+            Vector<uint8_t> buffer(4 * pixelsWide);
+            for (unsigned column = 0; column < pixelsWide; column++)
+                buffer[column] = OSReadLittleInt32(bitmapData, 4 * column);
+            md5.addBytes(buffer);
+            bitmapData += bytesPerRow;
+        }
+    } else {
+#endif
+        for (unsigned row = 0; row < pixelsHigh; row++) {
+            md5.addBytes(bitmapData, 4 * pixelsWide);
+            bitmapData += bytesPerRow;
+        }
+#if PLATFORM(MAC)
+    }
+#endif
+
+    Vector<uint8_t, 16> hash;
+    md5.checksum(hash);
+    
+    hashString[0] = '\0';
+    for (int i = 0; i < 16; i++)
+        snprintf(hashString, 33, "%s%02x", hashString, hash[i]);
+}
+
+static void dumpBitmap(CGContextRef bitmapContext, const char* checksum)
+{
+    RetainPtr<CGImageRef> image(AdoptCF, CGBitmapContextCreateImage(bitmapContext));
+    RetainPtr<CFMutableDataRef> imageData(AdoptCF, CFDataCreateMutable(0, 0));
+    RetainPtr<CGImageDestinationRef> imageDest(AdoptCF, CGImageDestinationCreateWithData(imageData.get(), kUTTypePNG, 1, 0));
+    CGImageDestinationAddImage(imageDest.get(), image.get(), 0);
+    CGImageDestinationFinalize(imageDest.get());
+
+    const unsigned char* data = ""
+    const size_t dataLength = CFDataGetLength(imageData.get());
+
+    printPNG(data, dataLength, checksum);
+}
+
+static void paintRepaintRectOverlay(CGContextRef context, WKImageRef image, WKArrayRef repaintRects)
+{
+    WKSize imageSize = WKImageGetSize(image);
+
+    CGContextSaveGState(context);
+
+    // Using a transparency layer is easier than futzing with clipping.
+    CGContextBeginTransparencyLayer(context, 0);
+    
+    // Flip the context.
+    CGContextScaleCTM(context, 1, -1);
+    CGContextTranslateCTM(context, 0, -imageSize.height);
+    
+    CGContextSetRGBFillColor(context, 0, 0, 0, static_cast<CGFloat>(0.66));
+    CGContextFillRect(context, CGRectMake(0, 0, imageSize.width, imageSize.height));
+
+    // Clear the repaint rects.
+    size_t count = WKArrayGetSize(repaintRects);
+    for (size_t i = 0; i < count; ++i) {
+        WKRect rect = WKRectGetValue(static_cast<WKRectRef>(WKArrayGetItemAtIndex(repaintRects, i)));
+        CGRect cgRect = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
+        CGContextClearRect(context, cgRect);
+    }
+    
+    CGContextEndTransparencyLayer(context);
+    CGContextRestoreGState(context);
+}
+
+void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef image, WKArrayRef repaintRects)
+{
+    // We don't use the image passed from the WebProcess, because it doesn't correctly capture compositing layers. Instead, snapshot
+    // the window via CGWindowListCreateImage.
+    PlatformWebView* webView = TestController::shared().mainWebView();
+    [webView->platformView() display];
+    RetainPtr<CGImageRef> windowSnapshotImage(AdoptCF, CGWindowListCreateImage(CGRectNull, kCGWindowListOptionIncludingWindow, [webView->platformWindow() windowNumber], kCGWindowImageBoundsIgnoreFraming | kCGWindowImageShouldBeOpaque));
+
+    RetainPtr<CGContextRef> context(AdoptCF, createBitmapCGContext(CGImageGetWidth(windowSnapshotImage.get()), CGImageGetHeight(windowSnapshotImage.get())));
+    CGContextDrawImage(context.get(), CGRectMake(0, 0, CGImageGetWidth(windowSnapshotImage.get()), CGImageGetHeight(windowSnapshotImage.get())), windowSnapshotImage.get());
+
+    // A non-null repaintRects array means we're doing a repaint test.
+    if (repaintRects)
+        paintRepaintRectOverlay(context.get(), image, repaintRects);
+
+    char actualHash[33];
+    computeMD5HashStringForContext(context.get(), actualHash);
+    if (!compareActualHashToExpectedAndDumpResults(actualHash))
+        dumpBitmap(context.get(), actualHash);
+}
+
+} // namespace WTR

Modified: trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm (97081 => 97082)


--- trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm	2011-10-10 21:01:59 UTC (rev 97081)
+++ trunk/Tools/WebKitTestRunner/mac/PlatformWebViewMac.mm	2011-10-10 21:02:05 UTC (rev 97082)
@@ -54,7 +54,6 @@
     [m_window setColorSpace:[NSColorSpace genericRGBColorSpace]];
     [[m_window contentView] addSubview:m_view];
     [m_window orderBack:nil];
-    [m_window setAutodisplay:NO];
     [m_window setReleasedWhenClosed:NO];
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to