Title: [135935] trunk
Revision
135935
Author
commit-qu...@webkit.org
Date
2012-11-27 15:56:54 -0800 (Tue, 27 Nov 2012)

Log Message

[EFL][WK2] 3D pixel tests are failing
https://bugs.webkit.org/show_bug.cgi?id=102833

Patch by Yael Aharon <yael.aha...@intel.com> on 2012-11-27
Reviewed by Kenneth Rohde Christiansen.

Source/WebKit2:

Added an API for generating a snapshot, to be used from WebKitTestRunner.

* PlatformEfl.cmake:
* UIProcess/API/C/efl/WKView.cpp:
(WKViewGetSnapshot):
* UIProcess/API/C/efl/WKView.h:
* UIProcess/API/efl/EwkViewImpl.cpp:
(EwkViewImpl::onFaviconChanged):
(EwkViewImpl::takeSnapshot):
* UIProcess/API/efl/EwkViewImpl.h:
(EwkViewImpl):
* UIProcess/API/efl/SnapshotImageGL.cpp: Added.
(getImageFromCurrentTexture):
* UIProcess/API/efl/SnapshotImageGL.h: Added.

Tools:

Generate a snapshot of the view in the UI process instead of the web process.
We have to use Texture Mapper in order to correctly paint 3D transforms etc.

* WebKitTestRunner/TestInvocation.h:
(TestInvocation):
* WebKitTestRunner/cairo/TestInvocationCairo.cpp:
(WTR::writeFunction):
(WTR::paintRepaintRectOverlay):
(WTR):
(WTR::TestInvocation::forceRepaintDoneCallback):
(WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
* WebKitTestRunner/efl/PlatformWebViewEfl.cpp:
(WTR::PlatformWebView::windowSnapshotImage):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (135934 => 135935)


--- trunk/Source/WebKit2/ChangeLog	2012-11-27 23:45:13 UTC (rev 135934)
+++ trunk/Source/WebKit2/ChangeLog	2012-11-27 23:56:54 UTC (rev 135935)
@@ -1,3 +1,25 @@
+2012-11-27  Yael Aharon  <yael.aha...@intel.com>
+
+        [EFL][WK2] 3D pixel tests are failing
+        https://bugs.webkit.org/show_bug.cgi?id=102833
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Added an API for generating a snapshot, to be used from WebKitTestRunner.
+
+        * PlatformEfl.cmake:
+        * UIProcess/API/C/efl/WKView.cpp:
+        (WKViewGetSnapshot):
+        * UIProcess/API/C/efl/WKView.h:
+        * UIProcess/API/efl/EwkViewImpl.cpp:
+        (EwkViewImpl::onFaviconChanged):
+        (EwkViewImpl::takeSnapshot):
+        * UIProcess/API/efl/EwkViewImpl.h:
+        (EwkViewImpl):
+        * UIProcess/API/efl/SnapshotImageGL.cpp: Added.
+        (getImageFromCurrentTexture):
+        * UIProcess/API/efl/SnapshotImageGL.h: Added.
+
 2012-11-27  Tim Horton  <timothy_hor...@apple.com>
 
         PDFPlugin: Page scale factor should affect subframe PDFs

Modified: trunk/Source/WebKit2/PlatformEfl.cmake (135934 => 135935)


--- trunk/Source/WebKit2/PlatformEfl.cmake	2012-11-27 23:45:13 UTC (rev 135934)
+++ trunk/Source/WebKit2/PlatformEfl.cmake	2012-11-27 23:56:54 UTC (rev 135935)
@@ -44,6 +44,7 @@
     UIProcess/API/efl/EwkViewImpl.cpp
     UIProcess/API/efl/EvasGLContext.cpp
     UIProcess/API/efl/EvasGLSurface.cpp
+    UIProcess/API/efl/SnapshotImageGL.cpp
     UIProcess/API/efl/ewk_auth_request.cpp
     UIProcess/API/efl/ewk_back_forward_list.cpp
     UIProcess/API/efl/ewk_back_forward_list_item.cpp

Modified: trunk/Source/WebKit2/UIProcess/API/C/efl/WKView.cpp (135934 => 135935)


--- trunk/Source/WebKit2/UIProcess/API/C/efl/WKView.cpp	2012-11-27 23:45:13 UTC (rev 135934)
+++ trunk/Source/WebKit2/UIProcess/API/C/efl/WKView.cpp	2012-11-27 23:56:54 UTC (rev 135935)
@@ -42,3 +42,10 @@
 
     return viewImpl->wkPage();
 }
+
+WKImageRef WKViewGetSnapshot(WKViewRef viewRef)
+{
+    EwkViewImpl* viewImpl = EwkViewImpl::fromEvasObject(toImpl(viewRef));
+
+    return viewImpl->takeSnapshot();
+}

Modified: trunk/Source/WebKit2/UIProcess/API/C/efl/WKView.h (135934 => 135935)


--- trunk/Source/WebKit2/UIProcess/API/C/efl/WKView.h	2012-11-27 23:45:13 UTC (rev 135934)
+++ trunk/Source/WebKit2/UIProcess/API/C/efl/WKView.h	2012-11-27 23:56:54 UTC (rev 135935)
@@ -34,6 +34,8 @@
 
 WK_EXPORT WKPageRef WKViewGetPage(WKViewRef view);
 
+WK_EXPORT WKImageRef WKViewGetSnapshot(WKViewRef viewRef);
+
 #ifdef __cplusplus
 }
 #endif

Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp (135934 => 135935)


--- trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp	2012-11-27 23:45:13 UTC (rev 135934)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp	2012-11-27 23:56:54 UTC (rev 135935)
@@ -35,11 +35,13 @@
 #include "PagePolicyClientEfl.h"
 #include "PageUIClientEfl.h"
 #include "ResourceLoadClientEfl.h"
+#include "SnapshotImageGL.h"
 #include "WKDictionary.h"
 #include "WKGeometry.h"
 #include "WKNumber.h"
 #include "WKString.h"
 #include "WebContext.h"
+#include "WebImage.h"
 #include "WebPageGroup.h"
 #include "WebPageProxy.h"
 #include "WebPopupMenuProxyEfl.h"
@@ -62,6 +64,7 @@
 #include <Edje.h>
 #include <WebCore/CairoUtilitiesEfl.h>
 #include <WebCore/Cursor.h>
+#include <WebKit2/WKImageCairo.h>
 
 #if ENABLE(VIBRATION)
 #include "VibrationClientEfl.h"
@@ -1012,3 +1015,22 @@
 
     viewImpl->informIconChange();
 }
+
+WKImageRef EwkViewImpl::takeSnapshot()
+{
+    Ewk_View_Smart_Data* sd = smartData();
+#if USE(ACCELERATED_COMPOSITING)
+    if (!m_isHardwareAccelerated)
+#endif
+        return WKImageCreateFromCairoSurface(createSurfaceForImage(sd->image).get(), 0);
+
+#if USE(ACCELERATED_COMPOSITING)
+    Evas_Native_Surface* nativeSurface = evas_object_image_native_surface_get(sd->image);
+    unsigned char* buffer = getImageFromCurrentTexture(sd->view.w, sd->view.h, nativeSurface->data.opengl.texture_id);
+    RefPtr<cairo_surface_t> surface = adoptRef(cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_ARGB32, sd->view.w, sd->view.h, sd->view.w * 4));
+    WKImageRef image = WKImageCreateFromCairoSurface(surface.get(), 0);
+    delete[] buffer;
+
+    return image;
+#endif
+}

Modified: trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h (135934 => 135935)


--- trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h	2012-11-27 23:45:13 UTC (rev 135934)
+++ trunk/Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h	2012-11-27 23:56:54 UTC (rev 135935)
@@ -215,6 +215,8 @@
     bool isHardwareAccelerated() const { return m_isHardwareAccelerated; }
     void setDrawsBackground(bool enable) { m_setDrawsBackground = enable; }
 
+    WKImageRef takeSnapshot();
+
 private:
     inline Ewk_View_Smart_Data* smartData() const;
     void displayTimerFired(WebCore::Timer<EwkViewImpl>*);

Added: trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp (0 => 135935)


--- trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.cpp	2012-11-27 23:56:54 UTC (rev 135935)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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 "SnapshotImageGL.h"
+
+#if USE(ACCELERATED_COMPOSITING)
+#if USE(OPENGL_ES_2)
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
+#else
+#include "OpenGLShims.h"
+#endif
+
+unsigned char* getImageFromCurrentTexture(int width, int height, int textureId)
+{
+    glBindTexture(GL_TEXTURE_2D, textureId);
+    unsigned char* buffer = new unsigned char[width * height * 4];
+    glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
+
+    // Textures are flipped on the Y axis, so we need to flip the image back.
+    unsigned tmp;
+    unsigned* buf = reinterpret_cast<unsigned*>(buffer);
+
+    for (int i = 0; i < height / 2; ++i) {
+        for (int j = 0; j < width; ++j) {
+            tmp = buf[i * width + j];
+            buf[i * width + j] = buf[(height - i - 1) * width + j];
+            buf[(height - i - 1) * width + j] = tmp;
+        }
+    }
+
+    return buffer;
+}
+
+#endif

Added: trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.h (0 => 135935)


--- trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/efl/SnapshotImageGL.h	2012-11-27 23:56:54 UTC (rev 135935)
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2012 Intel Corporation. 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.
+*/
+
+#ifndef SnapshotImageGL_h
+#define SnapshotImageGL_h
+
+#if USE(ACCELERATED_COMPOSITING)
+unsigned char* getImageFromCurrentTexture(int width, int height, int textureId);
+#endif
+
+#endif // SnapshotImageGL_h

Modified: trunk/Tools/ChangeLog (135934 => 135935)


--- trunk/Tools/ChangeLog	2012-11-27 23:45:13 UTC (rev 135934)
+++ trunk/Tools/ChangeLog	2012-11-27 23:56:54 UTC (rev 135935)
@@ -1,3 +1,24 @@
+2012-11-27  Yael Aharon  <yael.aha...@intel.com>
+
+        [EFL][WK2] 3D pixel tests are failing
+        https://bugs.webkit.org/show_bug.cgi?id=102833
+
+        Reviewed by Kenneth Rohde Christiansen.
+
+        Generate a snapshot of the view in the UI process instead of the web process.
+        We have to use Texture Mapper in order to correctly paint 3D transforms etc.
+
+        * WebKitTestRunner/TestInvocation.h:
+        (TestInvocation):
+        * WebKitTestRunner/cairo/TestInvocationCairo.cpp:
+        (WTR::writeFunction):
+        (WTR::paintRepaintRectOverlay):
+        (WTR):
+        (WTR::TestInvocation::forceRepaintDoneCallback):
+        (WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
+        * WebKitTestRunner/efl/PlatformWebViewEfl.cpp:
+        (WTR::PlatformWebView::windowSnapshotImage):
+
 2012-11-27  Adam Barth  <aba...@webkit.org>
 
         Make it possible to run performance tests on Chromium Android

Modified: trunk/Tools/WebKitTestRunner/TestInvocation.h (135934 => 135935)


--- trunk/Tools/WebKitTestRunner/TestInvocation.h	2012-11-27 23:45:13 UTC (rev 135934)
+++ trunk/Tools/WebKitTestRunner/TestInvocation.h	2012-11-27 23:56:54 UTC (rev 135935)
@@ -51,7 +51,7 @@
     void dumpPixelsAndCompareWithExpected(WKImageRef, WKArrayRef repaintRects);
     bool compareActualHashToExpectedAndDumpResults(const char[33]);
 
-#if PLATFORM(QT)
+#if PLATFORM(QT) || PLATFORM(EFL)
     static void forceRepaintDoneCallback(WKErrorRef, void* context);
     void forceRepaintDone();
 #endif

Modified: trunk/Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp (135934 => 135935)


--- trunk/Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp	2012-11-27 23:45:13 UTC (rev 135934)
+++ trunk/Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp	2012-11-27 23:56:54 UTC (rev 135935)
@@ -30,6 +30,8 @@
 #include "TestInvocation.h"
 
 #include "PixelDumpSupport.h"
+#include "PlatformWebView.h"
+#include "TestController.h"
 #include <WebKit2/WKImageCairo.h>
 #include <cairo/cairo.h>
 #include <cstdio>
@@ -61,7 +63,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)
+static cairo_status_t writeFunction(void* closure, const unsigned char* data, unsigned length)
 {
     Vector<unsigned char>* in = reinterpret_cast<Vector<unsigned char>*>(closure);
     in->append(data, length);
@@ -104,9 +106,37 @@
     cairo_destroy(context);
 }
 
+#if PLATFORM(EFL)
+void TestInvocation::forceRepaintDoneCallback(WKErrorRef, void *context)
+{
+    static_cast<TestInvocation*>(context)->m_gotRepaint = true;
+    TestController::shared().notifyDone();
+}
+#endif
+
 void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef wkImage, WKArrayRef repaintRects)
 {
+#if USE(ACCELERATED_COMPOSITING) && PLATFORM(EFL)
+    UNUSED_PARAM(wkImage);
+
+    cairo_surface_t* surface;
+
+    WKPageRef page = TestController::shared().mainWebView()->page();
+    WKPageForceRepaint(page, this, &forceRepaintDoneCallback);
+
+    TestController::shared().runUntil(m_gotRepaint, TestController::ShortTimeout);
+
+    if (!m_gotRepaint) {
+        m_error = true;
+        m_errorMessage = "Timed out waiting for repaint\n";
+        m_webProcessIsUnrensponsive = true;
+        return;
+    }
+
+    surface = WKImageCreateCairoSurface(TestController::shared().mainWebView()->windowSnapshotImage().get());
+#else
     cairo_surface_t* surface = WKImageCreateCairoSurface(wkImage);
+#endif
 
     if (repaintRects)
         paintRepaintRectOverlay(surface, repaintRects);

Modified: trunk/Tools/WebKitTestRunner/efl/PlatformWebViewEfl.cpp (135934 => 135935)


--- trunk/Tools/WebKitTestRunner/efl/PlatformWebViewEfl.cpp	2012-11-27 23:45:13 UTC (rev 135934)
+++ trunk/Tools/WebKitTestRunner/efl/PlatformWebViewEfl.cpp	2012-11-27 23:56:54 UTC (rev 135935)
@@ -24,6 +24,9 @@
 #include "EWebKit2.h"
 #include "WebKit2/WKAPICast.h"
 #include <Ecore_Evas.h>
+#include <WebCore/RefPtrCairo.h>
+#include <WebKit2/WKImageCairo.h>
+#include <cairo.h>
 
 using namespace WebKit;
 
@@ -124,9 +127,15 @@
 
 WKRetainPtr<WKImageRef> PlatformWebView::windowSnapshotImage()
 {
-    // FIXME: implement to capture pixels in the UI process,
-    // which may be necessary to capture things like 3D transforms.
-    return 0;
+    Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_view));
+    ASSERT(ee);
+
+    int width;
+    int height;
+    ecore_evas_geometry_get(ee, 0, 0, &width, &height);
+    ASSERT(width > 0 && height > 0);
+
+    return adoptWK(WKViewGetSnapshot(toAPI(m_view)));
 }
 
 bool PlatformWebView::viewSupportsOptions(WKDictionaryRef options) const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to