Skip to content

Commit d8c67e7

Browse files
[EFL][WK2] 3D pixel tests are failing
https://bugs.webkit.org/show_bug.cgi?id=102833 Patch by Yael Aharon <[email protected]> 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): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@135935 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent acaceda commit d8c67e7

File tree

12 files changed

+212
-5
lines changed

12 files changed

+212
-5
lines changed

Source/WebKit2/ChangeLog

+22
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1+
2012-11-27 Yael Aharon <[email protected]>
2+
3+
[EFL][WK2] 3D pixel tests are failing
4+
https://bugs.webkit.org/show_bug.cgi?id=102833
5+
6+
Reviewed by Kenneth Rohde Christiansen.
7+
8+
Added an API for generating a snapshot, to be used from WebKitTestRunner.
9+
10+
* PlatformEfl.cmake:
11+
* UIProcess/API/C/efl/WKView.cpp:
12+
(WKViewGetSnapshot):
13+
* UIProcess/API/C/efl/WKView.h:
14+
* UIProcess/API/efl/EwkViewImpl.cpp:
15+
(EwkViewImpl::onFaviconChanged):
16+
(EwkViewImpl::takeSnapshot):
17+
* UIProcess/API/efl/EwkViewImpl.h:
18+
(EwkViewImpl):
19+
* UIProcess/API/efl/SnapshotImageGL.cpp: Added.
20+
(getImageFromCurrentTexture):
21+
* UIProcess/API/efl/SnapshotImageGL.h: Added.
22+
123
2012-11-27 Tim Horton <[email protected]>
224

325
PDFPlugin: Page scale factor should affect subframe PDFs

Source/WebKit2/PlatformEfl.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ LIST(APPEND WebKit2_SOURCES
4444
UIProcess/API/efl/EwkViewImpl.cpp
4545
UIProcess/API/efl/EvasGLContext.cpp
4646
UIProcess/API/efl/EvasGLSurface.cpp
47+
UIProcess/API/efl/SnapshotImageGL.cpp
4748
UIProcess/API/efl/ewk_auth_request.cpp
4849
UIProcess/API/efl/ewk_back_forward_list.cpp
4950
UIProcess/API/efl/ewk_back_forward_list_item.cpp

Source/WebKit2/UIProcess/API/C/efl/WKView.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,10 @@ WKPageRef WKViewGetPage(WKViewRef viewRef)
4242

4343
return viewImpl->wkPage();
4444
}
45+
46+
WKImageRef WKViewGetSnapshot(WKViewRef viewRef)
47+
{
48+
EwkViewImpl* viewImpl = EwkViewImpl::fromEvasObject(toImpl(viewRef));
49+
50+
return viewImpl->takeSnapshot();
51+
}

Source/WebKit2/UIProcess/API/C/efl/WKView.h

+2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ WK_EXPORT WKViewRef WKViewCreateWithFixedLayout(Evas* canvas, WKContextRef conte
3434

3535
WK_EXPORT WKPageRef WKViewGetPage(WKViewRef view);
3636

37+
WK_EXPORT WKImageRef WKViewGetSnapshot(WKViewRef viewRef);
38+
3739
#ifdef __cplusplus
3840
}
3941
#endif

Source/WebKit2/UIProcess/API/efl/EwkViewImpl.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@
3535
#include "PagePolicyClientEfl.h"
3636
#include "PageUIClientEfl.h"
3737
#include "ResourceLoadClientEfl.h"
38+
#include "SnapshotImageGL.h"
3839
#include "WKDictionary.h"
3940
#include "WKGeometry.h"
4041
#include "WKNumber.h"
4142
#include "WKString.h"
4243
#include "WebContext.h"
44+
#include "WebImage.h"
4345
#include "WebPageGroup.h"
4446
#include "WebPageProxy.h"
4547
#include "WebPopupMenuProxyEfl.h"
@@ -62,6 +64,7 @@
6264
#include <Edje.h>
6365
#include <WebCore/CairoUtilitiesEfl.h>
6466
#include <WebCore/Cursor.h>
67+
#include <WebKit2/WKImageCairo.h>
6568

6669
#if ENABLE(VIBRATION)
6770
#include "VibrationClientEfl.h"
@@ -1012,3 +1015,22 @@ void EwkViewImpl::onFaviconChanged(const char* pageURL, void* eventInfo)
10121015

10131016
viewImpl->informIconChange();
10141017
}
1018+
1019+
WKImageRef EwkViewImpl::takeSnapshot()
1020+
{
1021+
Ewk_View_Smart_Data* sd = smartData();
1022+
#if USE(ACCELERATED_COMPOSITING)
1023+
if (!m_isHardwareAccelerated)
1024+
#endif
1025+
return WKImageCreateFromCairoSurface(createSurfaceForImage(sd->image).get(), 0);
1026+
1027+
#if USE(ACCELERATED_COMPOSITING)
1028+
Evas_Native_Surface* nativeSurface = evas_object_image_native_surface_get(sd->image);
1029+
unsigned char* buffer = getImageFromCurrentTexture(sd->view.w, sd->view.h, nativeSurface->data.opengl.texture_id);
1030+
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));
1031+
WKImageRef image = WKImageCreateFromCairoSurface(surface.get(), 0);
1032+
delete[] buffer;
1033+
1034+
return image;
1035+
#endif
1036+
}

Source/WebKit2/UIProcess/API/efl/EwkViewImpl.h

+2
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,8 @@ class EwkViewImpl {
215215
bool isHardwareAccelerated() const { return m_isHardwareAccelerated; }
216216
void setDrawsBackground(bool enable) { m_setDrawsBackground = enable; }
217217

218+
WKImageRef takeSnapshot();
219+
218220
private:
219221
inline Ewk_View_Smart_Data* smartData() const;
220222
void displayTimerFired(WebCore::Timer<EwkViewImpl>*);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright (C) 2012 Intel Corporation. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
* THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#include "config.h"
27+
#include "SnapshotImageGL.h"
28+
29+
#if USE(ACCELERATED_COMPOSITING)
30+
#if USE(OPENGL_ES_2)
31+
#include <GLES2/gl2.h>
32+
#include <GLES2/gl2ext.h>
33+
#else
34+
#include "OpenGLShims.h"
35+
#endif
36+
37+
unsigned char* getImageFromCurrentTexture(int width, int height, int textureId)
38+
{
39+
glBindTexture(GL_TEXTURE_2D, textureId);
40+
unsigned char* buffer = new unsigned char[width * height * 4];
41+
glReadPixels(0, 0, width, height, GL_BGRA, GL_UNSIGNED_BYTE, buffer);
42+
43+
// Textures are flipped on the Y axis, so we need to flip the image back.
44+
unsigned tmp;
45+
unsigned* buf = reinterpret_cast<unsigned*>(buffer);
46+
47+
for (int i = 0; i < height / 2; ++i) {
48+
for (int j = 0; j < width; ++j) {
49+
tmp = buf[i * width + j];
50+
buf[i * width + j] = buf[(height - i - 1) * width + j];
51+
buf[(height - i - 1) * width + j] = tmp;
52+
}
53+
}
54+
55+
return buffer;
56+
}
57+
58+
#endif
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright (C) 2012 Intel Corporation. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15+
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23+
* THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#ifndef SnapshotImageGL_h
27+
#define SnapshotImageGL_h
28+
29+
#if USE(ACCELERATED_COMPOSITING)
30+
unsigned char* getImageFromCurrentTexture(int width, int height, int textureId);
31+
#endif
32+
33+
#endif // SnapshotImageGL_h

Tools/ChangeLog

+21
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
2012-11-27 Yael Aharon <[email protected]>
2+
3+
[EFL][WK2] 3D pixel tests are failing
4+
https://bugs.webkit.org/show_bug.cgi?id=102833
5+
6+
Reviewed by Kenneth Rohde Christiansen.
7+
8+
Generate a snapshot of the view in the UI process instead of the web process.
9+
We have to use Texture Mapper in order to correctly paint 3D transforms etc.
10+
11+
* WebKitTestRunner/TestInvocation.h:
12+
(TestInvocation):
13+
* WebKitTestRunner/cairo/TestInvocationCairo.cpp:
14+
(WTR::writeFunction):
15+
(WTR::paintRepaintRectOverlay):
16+
(WTR):
17+
(WTR::TestInvocation::forceRepaintDoneCallback):
18+
(WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
19+
* WebKitTestRunner/efl/PlatformWebViewEfl.cpp:
20+
(WTR::PlatformWebView::windowSnapshotImage):
21+
122
2012-11-27 Adam Barth <[email protected]>
223

324
Make it possible to run performance tests on Chromium Android

Tools/WebKitTestRunner/TestInvocation.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class TestInvocation {
5151
void dumpPixelsAndCompareWithExpected(WKImageRef, WKArrayRef repaintRects);
5252
bool compareActualHashToExpectedAndDumpResults(const char[33]);
5353

54-
#if PLATFORM(QT)
54+
#if PLATFORM(QT) || PLATFORM(EFL)
5555
static void forceRepaintDoneCallback(WKErrorRef, void* context);
5656
void forceRepaintDone();
5757
#endif

Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp

+31-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include "TestInvocation.h"
3131

3232
#include "PixelDumpSupport.h"
33+
#include "PlatformWebView.h"
34+
#include "TestController.h"
3335
#include <WebKit2/WKImageCairo.h>
3436
#include <cairo/cairo.h>
3537
#include <cstdio>
@@ -61,7 +63,7 @@ void computeMD5HashStringForCairoSurface(cairo_surface_t* surface, char hashStri
6163
hash[8], hash[9], hash[10], hash[11], hash[12], hash[13], hash[14], hash[15]);
6264
}
6365

64-
static cairo_status_t writeFunction(void* closure, const unsigned char* data, unsigned int length)
66+
static cairo_status_t writeFunction(void* closure, const unsigned char* data, unsigned length)
6567
{
6668
Vector<unsigned char>* in = reinterpret_cast<Vector<unsigned char>*>(closure);
6769
in->append(data, length);
@@ -104,9 +106,37 @@ static void paintRepaintRectOverlay(cairo_surface_t* surface, WKArrayRef repaint
104106
cairo_destroy(context);
105107
}
106108

109+
#if PLATFORM(EFL)
110+
void TestInvocation::forceRepaintDoneCallback(WKErrorRef, void *context)
111+
{
112+
static_cast<TestInvocation*>(context)->m_gotRepaint = true;
113+
TestController::shared().notifyDone();
114+
}
115+
#endif
116+
107117
void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef wkImage, WKArrayRef repaintRects)
108118
{
119+
#if USE(ACCELERATED_COMPOSITING) && PLATFORM(EFL)
120+
UNUSED_PARAM(wkImage);
121+
122+
cairo_surface_t* surface;
123+
124+
WKPageRef page = TestController::shared().mainWebView()->page();
125+
WKPageForceRepaint(page, this, &forceRepaintDoneCallback);
126+
127+
TestController::shared().runUntil(m_gotRepaint, TestController::ShortTimeout);
128+
129+
if (!m_gotRepaint) {
130+
m_error = true;
131+
m_errorMessage = "Timed out waiting for repaint\n";
132+
m_webProcessIsUnrensponsive = true;
133+
return;
134+
}
135+
136+
surface = WKImageCreateCairoSurface(TestController::shared().mainWebView()->windowSnapshotImage().get());
137+
#else
109138
cairo_surface_t* surface = WKImageCreateCairoSurface(wkImage);
139+
#endif
110140

111141
if (repaintRects)
112142
paintRepaintRectOverlay(surface, repaintRects);

Tools/WebKitTestRunner/efl/PlatformWebViewEfl.cpp

+12-3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
#include "EWebKit2.h"
2525
#include "WebKit2/WKAPICast.h"
2626
#include <Ecore_Evas.h>
27+
#include <WebCore/RefPtrCairo.h>
28+
#include <WebKit2/WKImageCairo.h>
29+
#include <cairo.h>
2730

2831
using namespace WebKit;
2932

@@ -124,9 +127,15 @@ void PlatformWebView::makeWebViewFirstResponder()
124127

125128
WKRetainPtr<WKImageRef> PlatformWebView::windowSnapshotImage()
126129
{
127-
// FIXME: implement to capture pixels in the UI process,
128-
// which may be necessary to capture things like 3D transforms.
129-
return 0;
130+
Ecore_Evas* ee = ecore_evas_ecore_evas_get(evas_object_evas_get(m_view));
131+
ASSERT(ee);
132+
133+
int width;
134+
int height;
135+
ecore_evas_geometry_get(ee, 0, 0, &width, &height);
136+
ASSERT(width > 0 && height > 0);
137+
138+
return adoptWK(WKViewGetSnapshot(toAPI(m_view)));
130139
}
131140

132141
bool PlatformWebView::viewSupportsOptions(WKDictionaryRef options) const

0 commit comments

Comments
 (0)