Title: [89426] trunk
Revision
89426
Author
commit-qu...@webkit.org
Date
2011-06-22 06:49:45 -0700 (Wed, 22 Jun 2011)

Log Message

2011-06-22  Martin Robinson  <mrobin...@igalia.com>

        Reviewed by Adam Roben.

        [GTK] Implement pixel dump support for WebKitTestRunner
        https://bugs.webkit.org/show_bug.cgi?id=58242

        * GNUmakefile.am: Reference the new ImageDiff GNUmakefile.
2011-06-22  Martin Robinson  <mrobin...@igalia.com>

        Reviewed by Adam Roben.

        [GTK] Implement pixel dump support for WebKitTestRunner
        https://bugs.webkit.org/show_bug.cgi?id=58242

        * GNUmakefile.am: Added new Cairo specific image handling files to the build.
        * Shared/API/c/cairo/WKImageCairo.cpp: Copied from Source/WebKit2/Shared/cairo/ShareableBitmapCairo.cpp.
        (WKImageCreateCairoSurface): Added
        (WKImageCreateFromCairoSurface): Added
        * Shared/API/c/cairo/WKImageCairo.h: Copied from Source/WebKit2/Shared/cairo/ShareableBitmapCairo.cpp.
2011-06-22  Martin Robinson  <mrobin...@igalia.com>

        Reviewed by Adam Roben.

        [GTK] Implement pixel dump support for WebKitTestRunner
        https://bugs.webkit.org/show_bug.cgi?id=58242

        * DumpRenderTree/gtk/GNUmakefile.ImageDiff.am: Added.
        * GNUmakefile.am: Separate out the ImageDiff bits of the GNUmakefile.
        * Scripts/old-run-webkit-tests: Update to add support for the GTK+ port.
        * WebKitTestRunner/GNUmakefile.am: Added Cairo specific files to the build.
        * WebKitTestRunner/TestInvocation.cpp: Moved this code to the platform-independent
        file so that we can share it across platforms.
        (WTR::TestInvocation::compareActualHashToExpectedAndDumpResults):
        * WebKitTestRunner/TestInvocation.h: Updated method list.
        * WebKitTestRunner/cairo/TestInvocationCairo.cpp: Added Cairo implementation.
        * WebKitTestRunner/cg/TestInvocationCG.cpp:
        (WTR::TestInvocation::dumpPixelsAndCompareWithExpected): Updated to use new helper.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/ChangeLog (89425 => 89426)


--- trunk/ChangeLog	2011-06-22 13:34:59 UTC (rev 89425)
+++ trunk/ChangeLog	2011-06-22 13:49:45 UTC (rev 89426)
@@ -1,3 +1,12 @@
+2011-06-22  Martin Robinson  <mrobin...@igalia.com>
+
+        Reviewed by Adam Roben.
+
+        [GTK] Implement pixel dump support for WebKitTestRunner
+        https://bugs.webkit.org/show_bug.cgi?id=58242
+
+        * GNUmakefile.am: Reference the new ImageDiff GNUmakefile.
+
 2011-06-21  MORITA Hajime  <morr...@google.com>
 
         Unreviewed, rolling out r89401 and r89403.

Modified: trunk/GNUmakefile.am (89425 => 89426)


--- trunk/GNUmakefile.am	2011-06-22 13:34:59 UTC (rev 89425)
+++ trunk/GNUmakefile.am	2011-06-22 13:49:45 UTC (rev 89426)
@@ -197,6 +197,8 @@
 include Source/WebCore/bindings/gobject/GNUmakefile.am
 include Tools/GNUmakefile.am
 include Source/WebKit/gtk/po/GNUmakefile.am
+include Tools/DumpRenderTree/gtk/GNUmakefile.ImageDiff.am
+
 if ENABLE_WEBKIT2
 include Source/WebKit2/GNUmakefile.am
 include Tools/MiniBrowser/gtk/GNUmakefile.am

Modified: trunk/Source/WebKit2/ChangeLog (89425 => 89426)


--- trunk/Source/WebKit2/ChangeLog	2011-06-22 13:34:59 UTC (rev 89425)
+++ trunk/Source/WebKit2/ChangeLog	2011-06-22 13:49:45 UTC (rev 89426)
@@ -1,3 +1,16 @@
+2011-06-22  Martin Robinson  <mrobin...@igalia.com>
+
+        Reviewed by Adam Roben.
+
+        [GTK] Implement pixel dump support for WebKitTestRunner
+        https://bugs.webkit.org/show_bug.cgi?id=58242
+
+        * GNUmakefile.am: Added new Cairo specific image handling files to the build.
+        * Shared/API/c/cairo/WKImageCairo.cpp: Copied from Source/WebKit2/Shared/cairo/ShareableBitmapCairo.cpp.
+        (WKImageCreateCairoSurface): Added
+        (WKImageCreateFromCairoSurface): Added
+        * Shared/API/c/cairo/WKImageCairo.h: Copied from Source/WebKit2/Shared/cairo/ShareableBitmapCairo.cpp.
+
 2011-06-21  MORITA Hajime  <morr...@google.com>
 
         Unreviewed, rolling out r89401 and r89403.

Modified: trunk/Source/WebKit2/GNUmakefile.am (89425 => 89426)


--- trunk/Source/WebKit2/GNUmakefile.am	2011-06-22 13:34:59 UTC (rev 89425)
+++ trunk/Source/WebKit2/GNUmakefile.am	2011-06-22 13:49:45 UTC (rev 89426)
@@ -126,6 +126,8 @@
 	Source/WebKit2/PluginProcess/gtk/PluginControllerProxyGtk.cpp \
 	Source/WebKit2/PluginProcess/gtk/PluginProcessGtk.cpp \
 	Source/WebKit2/Shared/APIClient.h \
+	Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp \
+	Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h \
 	Source/WebKit2/Shared/API/c/gtk/WKBaseGtk.h \
 	Source/WebKit2/Shared/API/c/gtk/WKGraphicsContextGtk.h \
 	Source/WebKit2/Shared/API/c/gtk/WKGraphicsContextGtk.cpp \
@@ -189,8 +191,8 @@
 	Source/WebKit2/Shared/DrawingAreaInfo.h \
 	Source/WebKit2/Shared/EditorState.h \
 	Source/WebKit2/Shared/FontSmoothingLevel.h \
+	Source/WebKit2/Shared/cairo/LayerTreeContextCairo.cpp \
 	Source/WebKit2/Shared/cairo/ShareableBitmapCairo.cpp \
-	Source/WebKit2/Shared/cairo/LayerTreeContextCairo.cpp \
 	Source/WebKit2/Shared/gtk/NativeWebKeyboardEventGtk.cpp \
 	Source/WebKit2/Shared/gtk/NativeWebMouseEventGtk.cpp \
 	Source/WebKit2/Shared/gtk/NativeWebWheelEventGtk.cpp \

Copied: trunk/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp (from rev 89425, trunk/Tools/WebKitTestRunner/TestInvocation.h) (0 => 89426)


--- trunk/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.cpp	2011-06-22 13:49:45 UTC (rev 89426)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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 "WKImageCairo.h"
+
+#include "ShareableBitmap.h"
+#include "WKSharedAPICast.h"
+#include "WebImage.h"
+#include <WebCore/GraphicsContext.h>
+#include <WebCore/PlatformContextCairo.h>
+
+using namespace WebKit;
+using namespace WebCore;
+
+cairo_surface_t* WKImageCreateCairoSurface(WKImageRef imageRef)
+{
+    // We cannot pass a RefPtr through the API here, so we just leak the reference.
+    return toImpl(imageRef)->bitmap()->createCairoSurface().leakRef();
+}
+
+WKImageRef WKImageCreateFromCairoSurface(cairo_surface_t* surface, WKImageOptions options)
+{
+    IntSize imageSize(cairo_image_surface_get_width(surface), cairo_image_surface_get_height(surface));
+    RefPtr<WebImage> webImage = WebImage::create(imageSize, toImageOptions(options));
+    OwnPtr<GraphicsContext> graphicsContext = webImage->bitmap()->createGraphicsContext();
+
+    cairo_t* cr = graphicsContext->platformContext()->cr();
+    cairo_set_source_surface(cr, surface, 0, 0);
+    cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
+    cairo_rectangle(cr, 0, 0, imageSize.width(), imageSize.height());
+    cairo_fill(cr);
+
+    return toAPI(webImage.release().leakRef());
+}

Copied: trunk/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h (from rev 89425, trunk/Tools/WebKitTestRunner/gtk/TestInvocationGtk.cpp) (0 => 89426)


--- trunk/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h	                        (rev 0)
+++ trunk/Source/WebKit2/Shared/API/c/cairo/WKImageCairo.h	2011-06-22 13:49:45 UTC (rev 89426)
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2011 Igalia S.L.
+ *
+ * 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.
+ */
+
+#ifndef WKImageCairo_h
+#define WKImageCairo_h
+
+#include <WebKit2/WKBase.h>
+#include <WebKit2/WKImage.h>
+
+typedef _cairo_surface cairo_surface_t;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT cairo_surface_t* WKImageCreateCairoSurface(WKImageRef image);
+
+WK_EXPORT WKImageRef WKImageCreateFromCairoSurface(cairo_surface_t* surface, WKImageOptions options);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* WKImageCairo_h */

Modified: trunk/Tools/ChangeLog (89425 => 89426)


--- trunk/Tools/ChangeLog	2011-06-22 13:34:59 UTC (rev 89425)
+++ trunk/Tools/ChangeLog	2011-06-22 13:49:45 UTC (rev 89426)
@@ -1,3 +1,22 @@
+2011-06-22  Martin Robinson  <mrobin...@igalia.com>
+
+        Reviewed by Adam Roben.
+
+        [GTK] Implement pixel dump support for WebKitTestRunner
+        https://bugs.webkit.org/show_bug.cgi?id=58242
+
+        * DumpRenderTree/gtk/GNUmakefile.ImageDiff.am: Added.
+        * GNUmakefile.am: Separate out the ImageDiff bits of the GNUmakefile.
+        * Scripts/old-run-webkit-tests: Update to add support for the GTK+ port.
+        * WebKitTestRunner/GNUmakefile.am: Added Cairo specific files to the build.
+        * WebKitTestRunner/TestInvocation.cpp: Moved this code to the platform-independent
+        file so that we can share it across platforms.
+        (WTR::TestInvocation::compareActualHashToExpectedAndDumpResults):
+        * WebKitTestRunner/TestInvocation.h: Updated method list.
+        * WebKitTestRunner/cairo/TestInvocationCairo.cpp: Added Cairo implementation.
+        * WebKitTestRunner/cg/TestInvocationCG.cpp:
+        (WTR::TestInvocation::dumpPixelsAndCompareWithExpected): Updated to use new helper.
+
 2011-06-22  Sheriff Bot  <webkit.review....@gmail.com>
 
         Unreviewed, rolling out r89414.

Added: trunk/Tools/DumpRenderTree/gtk/GNUmakefile.ImageDiff.am (0 => 89426)


--- trunk/Tools/DumpRenderTree/gtk/GNUmakefile.ImageDiff.am	                        (rev 0)
+++ trunk/Tools/DumpRenderTree/gtk/GNUmakefile.ImageDiff.am	2011-06-22 13:49:45 UTC (rev 89426)
@@ -0,0 +1,28 @@
+noinst_PROGRAMS += \
+	Programs/ImageDiff
+
+Programs_ImageDiff_CPPFLAGS = $(global_cppflags)
+
+Programs_ImageDiff_SOURCES = \
+   Tools/DumpRenderTree/gtk/ImageDiff.cpp
+
+Programs_ImageDiff_CXXFLAGS = \
+   $(global_cxxflags) \
+   $(global_cppflags) \
+   $(Programs_ImageDiff_CFLAGS)
+
+Programs_ImageDiff_CFLAGS = \
+   -fno-strict-aliasing \
+   $(global_cflags) \
+   $(GLOBALDEPS_CFLAGS) \
+   $(GTK_CFLAGS)
+
+Programs_ImageDiff_LDADD = \
+   $(GTK_LIBS)
+
+Programs_ImageDiff_LDFLAGS = \
+   -no-fast-install \
+   -no-install
+
+CLEANFILES += \
+	Programs/ImageDiff

Modified: trunk/Tools/GNUmakefile.am (89425 => 89426)


--- trunk/Tools/GNUmakefile.am	2011-06-22 13:34:59 UTC (rev 89425)
+++ trunk/Tools/GNUmakefile.am	2011-06-22 13:49:45 UTC (rev 89426)
@@ -1,7 +1,6 @@
 noinst_PROGRAMS += \
 	Programs/DumpRenderTree \
-	Programs/GtkLauncher \
-	Programs/ImageDiff
+	Programs/GtkLauncher
 
 if ENABLE_WEBKIT2
 noinst_PROGRAMS += \
@@ -205,35 +204,10 @@
 	-no-fast-install \
 	-no-install
 
-# ImageDiff
-Programs_ImageDiff_CPPFLAGS = $(global_cppflags)
-
-Programs_ImageDiff_SOURCES = \
-   Tools/DumpRenderTree/gtk/ImageDiff.cpp
-
-Programs_ImageDiff_CXXFLAGS = \
-   $(global_cxxflags) \
-   $(global_cppflags) \
-   $(Programs_ImageDiff_CFLAGS)
-
-Programs_ImageDiff_CFLAGS = \
-   -fno-strict-aliasing \
-   $(global_cflags) \
-   $(GLOBALDEPS_CFLAGS) \
-   $(GTK_CFLAGS)
-
-Programs_ImageDiff_LDADD = \
-   $(GTK_LIBS)
-
-Programs_ImageDiff_LDFLAGS = \
-   -no-fast-install \
-   -no-install
-
 # clean target
 CLEANFILES += \
 	Programs/DumpRenderTree \
-	Programs/GtkLauncher \
-	Programs/ImageDiff
+	Programs/GtkLauncher
 
 if ENABLE_WEBKIT2
 CLEANFILES += \

Modified: trunk/Tools/WebKitTestRunner/GNUmakefile.am (89425 => 89426)


--- trunk/Tools/WebKitTestRunner/GNUmakefile.am	2011-06-22 13:34:59 UTC (rev 89425)
+++ trunk/Tools/WebKitTestRunner/GNUmakefile.am	2011-06-22 13:49:45 UTC (rev 89426)
@@ -12,7 +12,7 @@
 	Tools/WebKitTestRunner/gtk/main.cpp \
 	Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp \
 	Tools/WebKitTestRunner/gtk/TestControllerGtk.cpp \
-	Tools/WebKitTestRunner/gtk/TestInvocationGtk.cpp \
+	Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp \
 	Tools/WebKitTestRunner/PlatformWebView.h \
 	Tools/WebKitTestRunner/StringFunctions.h \
 	Tools/WebKitTestRunner/TestController.cpp \

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.cpp (89425 => 89426)


--- trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2011-06-22 13:34:59 UTC (rev 89425)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.cpp	2011-06-22 13:49:45 UTC (rev 89426)
@@ -174,6 +174,21 @@
     fflush(stderr);
 }
 
+bool TestInvocation::compareActualHashToExpectedAndDumpResults(const char actualHash[33])
+{
+    // Compute the hash of the bitmap context pixels
+    fprintf(stdout, "\nActualHash: %s\n", actualHash);
+
+    if (!m_expectedPixelHash.length())
+        return false;
+
+    ASSERT(m_expectedPixelHash.length() == 32);
+    fprintf(stdout, "\nExpectedHash: %s\n", m_expectedPixelHash.c_str());
+
+    // FIXME: Do case insensitive compare.
+    return m_expectedPixelHash == actualHash;
+}
+
 void TestInvocation::didReceiveMessageFromInjectedBundle(WKStringRef messageName, WKTypeRef messageBody)
 {
     if (WKStringIsEqualToUTF8CString(messageName, "Error")) {

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.h (89425 => 89426)


--- trunk/Tools/WebKitTestRunner/TestInvocation.h	2011-06-22 13:34:59 UTC (rev 89425)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.h	2011-06-22 13:49:45 UTC (rev 89426)
@@ -47,6 +47,7 @@
 private:
     void dump(const char*, bool singleEOF = false);
     void dumpPixelsAndCompareWithExpected(WKImageRef);
+    bool compareActualHashToExpectedAndDumpResults(const char[33]);
     
     WKRetainPtr<WKURLRef> m_url;
     std::string m_pathOrURL;

Modified: trunk/Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp (89425 => 89426)


--- trunk/Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp	2011-06-22 13:34:59 UTC (rev 89425)
+++ trunk/Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp	2011-06-22 13:49:45 UTC (rev 89426)
@@ -1,6 +1,7 @@
 /*
- * Copyright (C) 2011 Apple Inc. All rights reserved.
- * Copyright (C) 2011 Brent Fulgham <bfulg...@webkit.org>. All rights reserved.
+ * Copyright (C) 2009 Apple Inc. All rights reserved.
+ *           (C) 2011 Brent Fulgham <bfulg...@webkit.org>. All rights reserved.
+ *           (C) 2010, 2011 Igalia S.L
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -27,12 +28,75 @@
 #include "config.h"
 #include "TestInvocation.h"
 
+#include <WebKit2/WKImageCairo.h>
+#include <cairo/cairo.h>
+#include <cstdio>
+#include <wtf/Assertions.h>
+#include <wtf/MD5.h>
+
 namespace WTR {
 
-void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef image)
+void computeMD5HashStringForCairoSurface(cairo_surface_t* surface, char hashString[33])
 {
-    // FIXME: This stub should be replaced with a Cairo implementation
-    // of the pixel dumping and comparison routines.
+    ASSERT(cairo_image_surface_get_format(surface) == CAIRO_FORMAT_ARGB32); // ImageDiff assumes 32 bit RGBA, we must as well.
+
+    size_t pixelsHigh = cairo_image_surface_get_height(surface);
+    size_t pixelsWide = cairo_image_surface_get_width(surface);
+    size_t bytesPerRow = cairo_image_surface_get_stride(surface);
+
+    MD5 md5Context;
+    unsigned char* bitmapData = static_cast<unsigned char*>(cairo_image_surface_get_data(surface));
+    for (size_t row = 0; row < pixelsHigh; ++row) {
+        md5Context.addBytes(bitmapData, 4 * pixelsWide);
+        bitmapData += bytesPerRow;
+    }
+    Vector<uint8_t, 16> hash;
+    md5Context.checksum(hash);
+
+    snprintf(hashString, 33, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
+        hash[0], hash[1], hash[2], hash[3], hash[4], hash[5], hash[6], hash[7],
+        hash[8], hash[9], hash[10], hash[11], hash[12], hash[13], hash[14], hash[15]);
 }
 
+static cairo_status_t writeFunction(void* closure, const unsigned char* data, unsigned int length)
+{
+    Vector<unsigned char>* in = reinterpret_cast<Vector<unsigned char>*>(closure);
+    in->append(data, length);
+    return CAIRO_STATUS_SUCCESS;
+}
+
+static void dumpBitmap(cairo_surface_t* surface)
+{
+    Vector<unsigned char> pixelData;
+    cairo_surface_write_to_png_stream(surface, writeFunction, &pixelData);
+    const size_t dataLength = pixelData.size();
+    const unsigned char* data = ""
+
+    printf("Content-Type: %s\n", "image/png");
+    printf("Content-Length: %lu\n", static_cast<unsigned long>(dataLength));
+
+    const size_t bytesToWriteInOneChunk = 1 << 15;
+    size_t dataRemainingToWrite = dataLength;
+    while (dataRemainingToWrite) {
+        size_t bytesToWriteInThisChunk = std::min(dataRemainingToWrite, bytesToWriteInOneChunk);
+        size_t bytesWritten = fwrite(data, 1, bytesToWriteInThisChunk, stdout);
+        if (bytesWritten != bytesToWriteInThisChunk)
+            break;
+        dataRemainingToWrite -= bytesWritten;
+        data += bytesWritten;
+    }
+}
+
+void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef wkImage)
+{
+    cairo_surface_t* surface = WKImageCreateCairoSurface(wkImage);
+
+    char actualHash[33];
+    computeMD5HashStringForCairoSurface(surface, actualHash);
+    if (!compareActualHashToExpectedAndDumpResults(actualHash))
+        dumpBitmap(surface);
+
+    cairo_surface_destroy(surface);
+}
+
 } // namespace WTR

Modified: trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp (89425 => 89426)


--- trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp	2011-06-22 13:34:59 UTC (rev 89425)
+++ trunk/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp	2011-06-22 13:49:45 UTC (rev 89426)
@@ -130,24 +130,9 @@
 {
     CGContextRef context = createCGContextFromImage(image);
 
-    // Compute the hash of the bitmap context pixels
     char actualHash[33];
     computeMD5HashStringForContext(context, actualHash);
-    fprintf(stdout, "\nActualHash: %s\n", actualHash);
-
-    // Check the computed hash against the expected one and dump image on mismatch
-    bool hashesMatch = false;
-    if (m_expectedPixelHash.length() > 0) {
-        ASSERT(m_expectedPixelHash.length() == 32);
-
-        fprintf(stdout, "\nExpectedHash: %s\n", m_expectedPixelHash.c_str());
-
-        // FIXME: Do case insensitive compare.
-        if (m_expectedPixelHash == actualHash)
-            hashesMatch = true;
-    }
-
-    if (!hashesMatch)
+    if (!compareActualHashToExpectedAndDumpResults(actualHash))
         dumpBitmap(context);
 }
 

Deleted: trunk/Tools/WebKitTestRunner/gtk/TestInvocationGtk.cpp (89425 => 89426)


--- trunk/Tools/WebKitTestRunner/gtk/TestInvocationGtk.cpp	2011-06-22 13:34:59 UTC (rev 89425)
+++ trunk/Tools/WebKitTestRunner/gtk/TestInvocationGtk.cpp	2011-06-22 13:49:45 UTC (rev 89426)
@@ -1,35 +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"
-
-namespace WTR {
-
-void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef image)
-{
-}
-
-} // namespace WTR
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to