Skip to content

Commit ee4f57d

Browse files
[GTK] Should have the ability to output composited contents during layout testing
https://bugs.webkit.org/show_bug.cgi?id=131864 Reviewed by Philippe Normand. * WebKitTestRunner/cairo/TestInvocationCairo.cpp: (WTR::TestInvocation::dumpPixelsAndCompareWithExpected): Add a path that paints the widget contents to an image surface. We run the main loop a bit to match the implementation from WebKit1 and EFL. * WebKitTestRunner/gtk/PlatformWebViewGtk.cpp: (WTR::PlatformWebView::windowSnapshotImage): Use the new UI-process path on GTK+. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@167643 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent d00f536 commit ee4f57d

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

Tools/ChangeLog

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
2014-04-21 Martin Robinson <[email protected]>
2+
3+
[GTK] Should have the ability to output composited contents during layout testing
4+
https://bugs.webkit.org/show_bug.cgi?id=131864
5+
6+
Reviewed by Philippe Normand.
7+
8+
* WebKitTestRunner/cairo/TestInvocationCairo.cpp:
9+
(WTR::TestInvocation::dumpPixelsAndCompareWithExpected): Add a path that paints the widget contents
10+
to an image surface. We run the main loop a bit to match the implementation from WebKit1 and EFL.
11+
* WebKitTestRunner/gtk/PlatformWebViewGtk.cpp:
12+
(WTR::PlatformWebView::windowSnapshotImage): Use the new UI-process path on GTK+.
13+
114
2014-04-21 Sam Weinig <[email protected]>
215

316
Attempt to fix the tests.

Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static void paintRepaintRectOverlay(cairo_surface_t* surface, WKArrayRef repaint
108108

109109
void TestInvocation::dumpPixelsAndCompareWithExpected(WKImageRef wkImage, WKArrayRef repaintRects)
110110
{
111-
#if PLATFORM(EFL)
111+
#if PLATFORM(EFL) || PLATFORM(GTK)
112112
UNUSED_PARAM(wkImage);
113113
cairo_surface_t* surface = WKImageCreateCairoSurface(TestController::shared().mainWebView()->windowSnapshotImage().get());
114114
#else

Tools/WebKitTestRunner/gtk/PlatformWebViewGtk.cpp

+17-3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "config.h"
2929
#include "PlatformWebView.h"
3030

31+
#include <WebKit2/WKImageCairo.h>
3132
#include <WebKit2/WKViewPrivate.h>
3233
#include <gtk/gtk.h>
3334

@@ -120,9 +121,22 @@ void PlatformWebView::changeWindowScaleIfNeeded(float)
120121

121122
WKRetainPtr<WKImageRef> PlatformWebView::windowSnapshotImage()
122123
{
123-
// FIXME: implement to capture pixels in the UI process,
124-
// which may be necessary to capture things like 3D transforms.
125-
return 0;
124+
int width = gtk_widget_get_allocated_width(GTK_WIDGET(m_view));
125+
int height = gtk_widget_get_allocated_height(GTK_WIDGET(m_view));
126+
127+
while (gtk_events_pending())
128+
gtk_main_iteration();
129+
130+
cairo_surface_t* imageSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
131+
132+
cairo_t* context = cairo_create(imageSurface);
133+
gtk_widget_draw(GTK_WIDGET(m_view), context);
134+
cairo_destroy(context);
135+
136+
WKRetainPtr<WKImageRef> wkImage = adoptWK(WKImageCreateFromCairoSurface(imageSurface, 0 /* options */));
137+
138+
cairo_surface_destroy(imageSurface);
139+
return wkImage;
126140
}
127141

128142
void PlatformWebView::didInitializeClients()

0 commit comments

Comments
 (0)