Title: [122340] trunk
Revision
122340
Author
[email protected]
Date
2012-07-11 10:50:03 -0700 (Wed, 11 Jul 2012)

Log Message

[Qt] QRawWebView should notify when rendering is done, so that pixel results can be grabbed at the appropriate moment.
https://bugs.webkit.org/show_bug.cgi?id=90641

Reviewed by Jocelyn Turcotte.

Source/WebKit2:

Implement LayerTreeCoordinator::forceRepaint with logic equivalent to the one in
LayerTreeHostCA. If we flush the layers synchronously when forceRepaint is called,when
WKPageForceRepaint returns we are guaranteed to have an up-to-date image, as the visible
tiles are also synchronously updated.

* UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp:
(WebView::WebView):
(WebView::viewNeedsDisplay):
(WebView::frameLoaded):
(WebView):
(WebView::onRepaintDone):
(WebView::finishForceRepaint):
(WebView::finishFirstLayoutForFrame):
(tst_qrawwebview::doNoBackground1):
(tst_qrawwebview::doNoBackground2):
(tst_qrawwebview::doNoBackground3):
(tst_qrawwebview::run):
    The test for QRawWebView has been updated to use the WebKit2 ForcePaint API prior to
    generating the pixel results. This has exposed a timing bug in the test - setting the
    transparentBackground property of a page has to be done before it's created. This has
    been fixed in the test.

* WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp:
(WebKit::LayerTreeCoordinator::forceRepaint):
(WebKit::LayerTreeCoordinator::performScheduledLayerFlush):
(WebKit):

Tools:

* MiniBrowser/qt/raw/View.h: Comment used old class name (WKView).
(View):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (122339 => 122340)


--- trunk/Source/WebKit2/ChangeLog	2012-07-11 17:09:03 UTC (rev 122339)
+++ trunk/Source/WebKit2/ChangeLog	2012-07-11 17:50:03 UTC (rev 122340)
@@ -1,3 +1,37 @@
+2012-07-11  No'am Rosenthal  <[email protected]>
+
+        [Qt] QRawWebView should notify when rendering is done, so that pixel results can be grabbed at the appropriate moment.
+        https://bugs.webkit.org/show_bug.cgi?id=90641
+
+        Reviewed by Jocelyn Turcotte.
+
+        Implement LayerTreeCoordinator::forceRepaint with logic equivalent to the one in
+        LayerTreeHostCA. If we flush the layers synchronously when forceRepaint is called,when
+        WKPageForceRepaint returns we are guaranteed to have an up-to-date image, as the visible
+        tiles are also synchronously updated.
+
+        * UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp:
+        (WebView::WebView):
+        (WebView::viewNeedsDisplay):
+        (WebView::frameLoaded):
+        (WebView):
+        (WebView::onRepaintDone):
+        (WebView::finishForceRepaint):
+        (WebView::finishFirstLayoutForFrame):
+        (tst_qrawwebview::doNoBackground1):
+        (tst_qrawwebview::doNoBackground2):
+        (tst_qrawwebview::doNoBackground3):
+        (tst_qrawwebview::run):
+            The test for QRawWebView has been updated to use the WebKit2 ForcePaint API prior to
+            generating the pixel results. This has exposed a timing bug in the test - setting the
+            transparentBackground property of a page has to be done before it's created. This has
+            been fixed in the test.
+
+        * WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp:
+        (WebKit::LayerTreeCoordinator::forceRepaint):
+        (WebKit::LayerTreeCoordinator::performScheduledLayerFlush):
+        (WebKit):
+
 2012-07-11  MORITA Hajime  <[email protected]>
 
         WebCoreSupport needs objects each of which follows major WebCore objects

Modified: trunk/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp (122339 => 122340)


--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp	2012-07-11 17:09:03 UTC (rev 122339)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qrawwebview/tst_qrawwebview.cpp	2012-07-11 17:50:03 UTC (rev 122340)
@@ -58,15 +58,16 @@
 class WebView : public QObject, public QRawWebViewClient {
     Q_OBJECT
 public:
-    WebView(const QSize& size)
+    WebView(const QSize& size, bool transparent = false)
     {
         WKPageLoaderClient loaderClient;
         memset(&loaderClient, 0, sizeof(WKPageLoaderClient));
         loaderClient.clientInfo = this;
-        loaderClient.didFinishLoadForFrame = WebView::finishLoadForFrame;
+        loaderClient.didFirstVisuallyNonEmptyLayoutForFrame = WebView::finishFirstLayoutForFrame;
 
         m_webView = new QRawWebView(webContext(), webPageGroup(QString()), this);
         WKPageSetPageLoaderClient(m_webView->pageRef(), &loaderClient);
+        m_webView->setTransparentBackground(transparent);
         m_webView->create();
         WKPageSetUseFixedLayout(m_webView->pageRef(), true);
 
@@ -91,8 +92,6 @@
     virtual void viewNeedsDisplay(const QRect&)
     {
         m_webView->paint(QMatrix4x4(), 1, 0);
-        if (m_frameLoaded)
-            emit loaded();
     }
 
     virtual void viewRequestedScroll(const QPoint&) { }
@@ -103,8 +102,27 @@
     virtual void doneWithKeyEvent(const QKeyEvent*, bool wasHandled) { }
     virtual void doneWithTouchEvent(const QTouchEvent*, bool wasHandled) { }
 
-    static void finishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo);
+    void frameLoaded()
+    {
+        m_frameLoaded = true;
+        WKPageForceRepaint(m_webView->pageRef(), this, finishForceRepaint);
+    }
 
+    void onRepaintDone()
+    {
+        emit loaded();
+    }
+
+    static void finishForceRepaint(WKErrorRef, void* context)
+    {
+        static_cast<WebView*>(context)->onRepaintDone();
+    }
+
+    static void finishFirstLayoutForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
+    {
+        static_cast<WebView*>(const_cast<void*>(clientInfo))->frameLoaded();
+    }
+
 signals:
     void loaded();
 
@@ -113,12 +131,6 @@
     bool m_frameLoaded;
 };
 
-void WebView::finishLoadForFrame(WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void *clientInfo)
-{
-    WebView* obj = static_cast<WebView*>(const_cast<void*>(clientInfo));
-    obj->m_frameLoaded = true;
-}
-
 static bool compareImages(const QImage& i1, const QImage& i2, int count)
 {
     if (i1.size() != i2.size())
@@ -169,37 +181,31 @@
 
 void tst_qrawwebview::doNoBackground1(const QSize& size)
 {
-    WebView view(size);
-    view.setTransparentBackground(true);
+    WebView view(size, true);
     view.load(m_baseUrl + "/redsquare.html");
     view.load(m_baseUrl + "/bluesquare.html");
 }
 
 void tst_qrawwebview::doNoBackground2(const QSize& size)
 {
-    WebView view1(size);
-    view1.setTransparentBackground(true);
+    WebView view1(size, true);
     view1.load(m_baseUrl + "/redsquare.html");
 
-    WebView view2(size);
-    view2.setTransparentBackground(true);
+    WebView view2(size, true);
     view2.load(m_baseUrl + "/bluesquare.html");
 }
 
 void tst_qrawwebview::doNoBackground3(const QSize& size)
 {
-    WebView view1(size);
-    view1.setTransparentBackground(false);
+    WebView view1(size, false);
     view1.load(m_baseUrl + "/redsquare.html");
 
-    WebView view2(size);
-    view2.setTransparentBackground(true);
+    WebView view2(size, true);
     view2.load(m_baseUrl + "/bluesquare.html");
 }
 
 void tst_qrawwebview::run(PaintMethod method, const QString& expectation)
 {
-
     QWindow window;
     window.setSurfaceType(QSurface::OpenGLSurface);
     window.setGeometry(0, 0, 200, 200);

Modified: trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp (122339 => 122340)


--- trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp	2012-07-11 17:09:03 UTC (rev 122339)
+++ trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.cpp	2012-07-11 17:50:03 UTC (rev 122340)
@@ -174,7 +174,10 @@
 
 void LayerTreeCoordinator::forceRepaint()
 {
+    // We need to schedule another flush, otherwise the forced paint might cancel a later expected flush.
+    // This is aligned with LayerTreeHostCA.
     scheduleLayerFlush();
+    flushPendingLayerChanges();
 }
 
 void LayerTreeCoordinator::sizeDidChange(const WebCore::IntSize& newSize)
@@ -231,13 +234,27 @@
 
 bool LayerTreeCoordinator::flushPendingLayerChanges()
 {
+    m_shouldSyncFrame = false;
     bool didSync = m_webPage->corePage()->mainFrame()->view()->syncCompositingStateIncludingSubframes();
     m_nonCompositedContentLayer->syncCompositingStateForThisLayerOnly();
     if (m_pageOverlayLayer)
         m_pageOverlayLayer->syncCompositingStateForThisLayerOnly();
 
     m_rootLayer->syncCompositingStateForThisLayerOnly();
-    return didSync;
+
+    if (m_shouldSyncRootLayer) {
+        m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetRootCompositingLayer(toWebGraphicsLayer(m_rootLayer.get())->id()));
+        m_shouldSyncRootLayer = false;
+    }
+
+    if (!m_shouldSyncFrame)
+        return didSync;
+
+    m_webPage->send(Messages::LayerTreeCoordinatorProxy::DidRenderFrame());
+    m_waitingForUIProcess = true;
+    m_shouldSyncFrame = false;
+
+    return true;
 }
 
 void LayerTreeCoordinator::syncLayerState(WebLayerID id, const WebLayerInfo& info)
@@ -246,6 +263,7 @@
         m_webPage->send(Messages::LayerTreeCoordinatorProxy::DidChangeScrollPosition(m_visibleContentsRect.location()));
         m_shouldSendScrollPositionUpdate = false;
     }
+
     m_shouldSyncFrame = true;
     m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetCompositingLayerState(id, info));
 }
@@ -344,25 +362,16 @@
     if (!m_isValid)
         return;
 
-    m_shouldSyncFrame = false;
-    flushPendingLayerChanges();
-    if (!m_shouldSyncFrame)
-        return;
+    if (flushPendingLayerChanges())
+        didPerformScheduledLayerFlush();
+}
 
-    if (m_shouldSyncRootLayer) {
-        m_webPage->send(Messages::LayerTreeCoordinatorProxy::SetRootCompositingLayer(toWebGraphicsLayer(m_rootLayer.get())->id()));
-        m_shouldSyncRootLayer = false;
+void LayerTreeCoordinator::didPerformScheduledLayerFlush()
+{
+    if (m_notifyAfterScheduledLayerFlush) {
+        static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers();
+        m_notifyAfterScheduledLayerFlush = false;
     }
-
-    m_webPage->send(Messages::LayerTreeCoordinatorProxy::DidRenderFrame());
-    m_waitingForUIProcess = true;
-
-    if (!m_notifyAfterScheduledLayerFlush)
-        return;
-
-    // Let the drawing area know that we've done a flush of the layer changes.
-    static_cast<DrawingAreaImpl*>(m_webPage->drawingArea())->layerHostDidFlushLayers();
-    m_notifyAfterScheduledLayerFlush = false;
 }
 
 void LayerTreeCoordinator::layerFlushTimerFired(Timer<LayerTreeCoordinator>*)

Modified: trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h (122339 => 122340)


--- trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h	2012-07-11 17:09:03 UTC (rev 122339)
+++ trunk/Source/WebKit2/WebProcess/WebPage/LayerTreeCoordinator/LayerTreeCoordinator.h	2012-07-11 17:50:03 UTC (rev 122340)
@@ -104,7 +104,7 @@
     bool flushPendingLayerChanges();
     void cancelPendingLayerFlush();
     void performScheduledLayerFlush();
-    void sendLayersToUI();
+    void didPerformScheduledLayerFlush();
 
     OwnPtr<WebCore::GraphicsLayer> m_rootLayer;
 

Modified: trunk/Tools/ChangeLog (122339 => 122340)


--- trunk/Tools/ChangeLog	2012-07-11 17:09:03 UTC (rev 122339)
+++ trunk/Tools/ChangeLog	2012-07-11 17:50:03 UTC (rev 122340)
@@ -1,3 +1,13 @@
+2012-07-11  No'am Rosenthal  <[email protected]>
+
+        [Qt] QRawWebView should notify when rendering is done, so that pixel results can be grabbed at the appropriate moment.
+        https://bugs.webkit.org/show_bug.cgi?id=90641
+
+        Reviewed by Jocelyn Turcotte.
+
+        * MiniBrowser/qt/raw/View.h: Comment used old class name (WKView).
+        (View):
+
 2012-07-11  Min Qin  <[email protected]>
 
         [Android] sending an extra to the DRT apk so that DRT can be run in a seperate thread

Modified: trunk/Tools/MiniBrowser/qt/raw/View.h (122339 => 122340)


--- trunk/Tools/MiniBrowser/qt/raw/View.h	2012-07-11 17:09:03 UTC (rev 122339)
+++ trunk/Tools/MiniBrowser/qt/raw/View.h	2012-07-11 17:50:03 UTC (rev 122340)
@@ -31,7 +31,7 @@
     View(const QString& url);
     ~View();
 
-public: // WKViewClient
+public: // QRawWebViewClient
     virtual void viewNeedsDisplay(const QRect&);
     virtual void viewRequestedScroll(const QPoint&) { }
     virtual void viewProcessCrashed() { }
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to