Diff
Modified: trunk/Source/WebKit2/ChangeLog (98705 => 98706)
--- trunk/Source/WebKit2/ChangeLog 2011-10-28 07:39:59 UTC (rev 98705)
+++ trunk/Source/WebKit2/ChangeLog 2011-10-28 07:59:18 UTC (rev 98706)
@@ -1,3 +1,58 @@
+2011-10-21 No'am Rosenthal <[email protected]>
+
+ [Qt][WK2] Synchronize tiling with accelerated compositing
+ https://bugs.webkit.org/show_bug.cgi?id=69151
+
+ Reviewed by Simon Hausmann.
+
+ Make QTouchWebView always render with accelerated compositing.
+ At first, the web content would only render after the rest of the scene has rendered. In a
+ future patch we'll enable rendering the web content via an FBO, which would cover all other
+ cases as well.
+
+ Right now this only works for QTouchWebView, and thus accelerated compositing is disabled
+ for desktop web-views. This required adding some settings enablers in Q
+ WebPreferencesPrivate. Those are not exposed to the public API, as they are an implementation
+ detail.
+
+ * UIProcess/API/qt/qtouchwebpage.cpp:
+ (QTouchWebPage::QTouchWebPage):
+ (QTouchWebPage::initSceneGraphConnections):
+ (QTouchWebPagePrivate::QTouchWebPagePrivate):
+ (QTouchWebPagePrivate::setPage):
+ (computeEffectiveOpacity):
+ (QTouchWebPagePrivate::paintToCurrentGLContext):
+ (QTouchWebPagePrivate::_q_onAfterSceneRender):
+ (QTouchWebPagePrivate::_q_onSceneGraphInitialized):
+ (QTouchWebPage::itemChange):
+ * UIProcess/API/qt/qtouchwebpage.h:
+ * UIProcess/API/qt/qtouchwebpage_p.h:
+ * UIProcess/API/qt/qwebpreferences.cpp:
+ (QWebPreferencesPrivate::testAttribute):
+ (QWebPreferencesPrivate::setAttribute):
+ (QWebPreferencesPrivate::get):
+ * UIProcess/API/qt/qwebpreferences_p.h:
+ * UIProcess/TiledDrawingAreaProxy.cpp:
+ (WebKit::TiledDrawingAreaProxy::renderNextFrame):
+ * UIProcess/qt/QtDesktopWebPageProxy.cpp:
+ (QtDesktopWebPageProxy::QtDesktopWebPageProxy):
+ * UIProcess/qt/QtTouchViewInterface.cpp:
+ (WebKit::QtTouchViewInterface::setViewNeedsDisplay):
+ * UIProcess/qt/QtTouchWebPageProxy.cpp:
+ (QtTouchWebPageProxy::QtTouchWebPageProxy):
+ (QtTouchWebPageProxy::createDrawingAreaProxy):
+ (QtTouchWebPageProxy::renderToCurrentGLContext):
+ (QtTouchWebPageProxy::setVisibleContentRectAndScale):
+ (QtTouchWebPageProxy::setVisibleContentRectTrajectoryVector):
+ (QtTouchWebPageProxy::renderNextFrame):
+ * UIProcess/qt/QtTouchWebPageProxy.h:
+ * WebProcess/WebPage/qt/LayerTreeHostQt.cpp:
+ (WebKit::LayerTreeHost::supportsAcceleratedCompositing):
+ * WebProcess/WebPage/qt/WebPageQt.cpp:
+ (WebKit::WebPage::platformInitialize):
+ * WebProcess/qt/WebProcessMainQt.cpp:
+ (WebKit::WebProcessMainQt):
+
2011-10-27 Martin Robinson <[email protected]>
Fix the GTK+ build after r98664.
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.cpp (98705 => 98706)
--- trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.cpp 2011-10-28 07:39:59 UTC (rev 98705)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.cpp 2011-10-28 07:59:18 UTC (rev 98706)
@@ -22,11 +22,13 @@
#include "qtouchwebpage.h"
#include "QtTouchWebPageProxy.h"
+#include "TransformationMatrix.h"
#include "qtouchwebpage_p.h"
#include <QApplication>
#include <QGraphicsSceneMouseEvent>
#include <QPainter>
-#include <QSGNode>
+#include <QSGCanvas>
+#include <QSGEngine>
#include <QUrl>
QTouchWebPage::QTouchWebPage(QSGItem* parent)
@@ -38,8 +40,22 @@
// We do the transform from the top left so the viewport can assume the position 0, 0
// is always where rendering starts.
setTransformOrigin(TopLeft);
+ initSceneGraphConnections();
}
+void QTouchWebPage::initSceneGraphConnections()
+{
+ if (d->paintingIsInitialized)
+ return;
+ if (!canvas())
+ return;
+ d->paintingIsInitialized = true;
+ if (sceneGraphEngine())
+ d->_q_onSceneGraphInitialized();
+ else
+ connect(canvas(), SIGNAL(sceneGraphInitialized()), this, SLOT(_q_onSceneGraphInitialized()));
+}
+
QTouchWebPage::~QTouchWebPage()
{
delete d;
@@ -67,28 +83,6 @@
/*! \reimp
*/
-QSGNode* QTouchWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*)
-{
- if (!oldNode)
- oldNode = new QSGNode;
-
- // A swap is on the queue, and QtSGUpdateQueue::applyUpdates will empty the queue, so we know that
- // the old frame's buffers won't be used anymore (for buffers used all the way from the web process
- // to the graphic card). Notify the web process that it can render the next frame.
- if (d->sgUpdateQueue.isSwapPending())
- // The UI thread is currently locked and calling this from the rendering thread didn't crash
- // yet, so I'm assuming that this is OK. Else we have to wait until the SG update is over
- // and the UI thread returns to the event loop picking our event before it can be sent to
- // the web process. This would increase our chances of missing a frame.
- d->page->renderNextFrame();
- d->sgUpdateQueue.applyUpdates(oldNode);
-
- // QSGItem takes ownership of this return value and it's children between and after updatePaintNode calls.
- return oldNode;
-}
-
-/*! \reimp
-*/
bool QTouchWebPage::event(QEvent* ev)
{
if (d->page->handleEvent(ev))
@@ -150,6 +144,7 @@
, page(0)
, navigationController(0)
, sgUpdateQueue(view)
+ , paintingIsInitialized(false)
{
}
@@ -158,6 +153,59 @@
ASSERT(!this->page);
ASSERT(page);
this->page = page;
+
}
+static float computeEffectiveOpacity(const QSGItem* item)
+{
+ if (!item)
+ return 1.0;
+
+ float opacity = item->opacity();
+ if (opacity < 0.01)
+ return 0;
+
+ return opacity * computeEffectiveOpacity(item->parentItem());
+}
+
+void QTouchWebPagePrivate::paintToCurrentGLContext()
+{
+ if (!q->isVisible())
+ return;
+
+ QTransform transform = q->itemTransform(0, 0);
+ float opacity = computeEffectiveOpacity(q);
+ QRectF clipRect = q->parentItem()->mapRectToScene(q->parentItem()->boundingRect());
+
+ glEnable(GL_SCISSOR_TEST);
+ const int left = clipRect.left();
+ const int width = clipRect.width();
+ const int bottom = q->canvas()->height() - (clipRect.bottom() + 1);
+ const int height = clipRect.height();
+
+ glScissor(left, bottom, width, height);
+
+ page->renderToCurrentGLContext(transform, opacity);
+ glDisable(GL_SCISSOR_TEST);
+}
+
+void QTouchWebPagePrivate::_q_onAfterSceneRender()
+{
+ // TODO: Allow painting before the scene or in the middle of the scene with an FBO.
+ paintToCurrentGLContext();
+}
+
+void QTouchWebPagePrivate::_q_onSceneGraphInitialized()
+{
+ QSGEngine* engine = q->sceneGraphEngine();
+ QObject::connect(engine, SIGNAL(afterRendering()), q, SLOT(_q_onAfterSceneRender()), Qt::DirectConnection);
+}
+
+void QTouchWebPage::itemChange(ItemChange change, const ItemChangeData &data)
+{
+ if (change == ItemSceneChange)
+ initSceneGraphConnections();
+ QSGItem::itemChange(change, data);
+}
+
#include "moc_qtouchwebpage.cpp"
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h (98705 => 98706)
--- trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h 2011-10-28 07:39:59 UTC (rev 98705)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage.h 2011-10-28 07:59:18 UTC (rev 98706)
@@ -63,7 +63,6 @@
QWebNavigationController* navigationController() const;
QWebPreferences* preferences() const;
- virtual QSGNode* updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*);
virtual bool event(QEvent*);
Q_SIGNALS:
@@ -83,8 +82,14 @@
virtual void touchEvent(QTouchEvent*);
virtual void geometryChanged(const QRectF&, const QRectF&);
+ virtual void itemChange(ItemChange, const ItemChangeData&);
private:
+ Q_PRIVATE_SLOT(d, void _q_onAfterSceneRender());
+ Q_PRIVATE_SLOT(d, void _q_onSceneGraphInitialized());
+
+ void initSceneGraphConnections();
+
QTouchWebPagePrivate* d;
friend class QTouchWebViewPrivate;
friend class WebKit::QtTouchViewInterface;
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage_p.h (98705 => 98706)
--- trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage_p.h 2011-10-28 07:39:59 UTC (rev 98705)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qtouchwebpage_p.h 2011-10-28 07:59:18 UTC (rev 98706)
@@ -38,10 +38,15 @@
void setPage(QtTouchWebPageProxy*);
+ void _q_onAfterSceneRender();
+ void _q_onSceneGraphInitialized();
+ void paintToCurrentGLContext();
+
QTouchWebPage* const q;
QtTouchWebPageProxy* page;
QWebNavigationController* navigationController;
WebKit::QtSGUpdateQueue sgUpdateQueue;
+ bool paintingIsInitialized;
};
#endif /* qtouchwebpage_p_h */
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp (98705 => 98706)
--- trunk/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp 2011-10-28 07:39:59 UTC (rev 98705)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qwebpreferences.cpp 2011-10-28 07:59:18 UTC (rev 98706)
@@ -22,6 +22,7 @@
#include "WKPageGroup.h"
#include "WKPreferences.h"
+#include "WKPreferencesPrivate.h"
#include "WKRetainPtr.h"
#include "WKStringQt.h"
#include "qwebpreferences_p.h"
@@ -52,6 +53,8 @@
return WKPreferencesGetPrivateBrowsingEnabled(ref);
case DnsPrefetchEnabled:
return WKPreferencesGetDNSPrefetchingEnabled(ref);
+ case AcceleratedCompositingEnabled:
+ return WKPreferencesGetAcceleratedCompositingEnabled(ref);
default:
ASSERT_NOT_REACHED();
return false;
@@ -85,6 +88,9 @@
case DnsPrefetchEnabled:
WKPreferencesSetDNSPrefetchingEnabled(ref, enable);
break;
+ case AcceleratedCompositingEnabled:
+ WKPreferencesSetAcceleratedCompositingEnabled(ref, enable);
+ break;
default:
ASSERT_NOT_REACHED();
}
@@ -376,3 +382,8 @@
d->setFontSize(QWebPreferencesPrivate::DefaultFixedFontSize, size);
emit defaultFixedFontSizeChanged();
}
+
+QWebPreferencesPrivate* QWebPreferencesPrivate::get(QWebPreferences* preferences)
+{
+ return preferences->d;
+}
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h (98705 => 98706)
--- trunk/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h 2011-10-28 07:39:59 UTC (rev 98705)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qwebpreferences_p.h 2011-10-28 07:59:18 UTC (rev 98706)
@@ -31,6 +31,7 @@
XSSAuditingEnabled,
FrameFlatteningEnabled,
PrivateBrowsingEnabled,
+ AcceleratedCompositingEnabled,
DnsPrefetchEnabled
};
@@ -61,4 +62,6 @@
unsigned fontSize(FontSizeType type) const;
WKPreferencesRef ref;
+
+ static QWebPreferencesPrivate* get(QWebPreferences*);
};
Modified: trunk/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.cpp (98705 => 98706)
--- trunk/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.cpp 2011-10-28 07:39:59 UTC (rev 98705)
+++ trunk/Source/WebKit2/UIProcess/TiledDrawingAreaProxy.cpp 2011-10-28 07:59:18 UTC (rev 98706)
@@ -67,7 +67,6 @@
void TiledDrawingAreaProxy::renderNextFrame()
{
- page()->process()->send(Messages::DrawingArea::RenderNextFrame(), page()->pageID());
}
void TiledDrawingAreaProxy::sizeDidChange()
Modified: trunk/Source/WebKit2/UIProcess/qt/QtDesktopWebPageProxy.cpp (98705 => 98706)
--- trunk/Source/WebKit2/UIProcess/qt/QtDesktopWebPageProxy.cpp 2011-10-28 07:39:59 UTC (rev 98705)
+++ trunk/Source/WebKit2/UIProcess/qt/QtDesktopWebPageProxy.cpp 2011-10-28 07:59:18 UTC (rev 98706)
@@ -27,6 +27,7 @@
#include "WebPopupMenuProxyQtDesktop.h"
#include "qdesktopwebview.h"
#include "qdesktopwebview_p.h"
+#include "qwebpreferences_p.h"
#include <QApplication>
#include <QEvent>
#include <QGraphicsSceneDragDropEvent>
@@ -55,6 +56,7 @@
: QtWebPageProxy(desktopWebView, desktopWebView, context, pageGroup)
{
init();
+ QWebPreferencesPrivate::get(preferences())->setAttribute(QWebPreferencesPrivate::AcceleratedCompositingEnabled, false);
}
PassOwnPtr<DrawingAreaProxy> QtDesktopWebPageProxy::createDrawingAreaProxy()
Modified: trunk/Source/WebKit2/UIProcess/qt/QtTouchViewInterface.cpp (98705 => 98706)
--- trunk/Source/WebKit2/UIProcess/qt/QtTouchViewInterface.cpp 2011-10-28 07:39:59 UTC (rev 98705)
+++ trunk/Source/WebKit2/UIProcess/qt/QtTouchViewInterface.cpp 2011-10-28 07:59:18 UTC (rev 98706)
@@ -51,6 +51,7 @@
void QtTouchViewInterface::setViewNeedsDisplay(const QRect&)
{
+ m_pageView->update();
}
QSize QtTouchViewInterface::drawingAreaSize()
Modified: trunk/Source/WebKit2/UIProcess/qt/QtTouchWebPageProxy.cpp (98705 => 98706)
--- trunk/Source/WebKit2/UIProcess/qt/QtTouchWebPageProxy.cpp 2011-10-28 07:39:59 UTC (rev 98705)
+++ trunk/Source/WebKit2/UIProcess/qt/QtTouchWebPageProxy.cpp 2011-10-28 07:59:18 UTC (rev 98706)
@@ -21,9 +21,11 @@
#include "config.h"
#include "QtTouchWebPageProxy.h"
+#include "DrawingAreaProxyImpl.h"
#include <IntRect.h>
#include <NativeWebTouchEvent.h>
#include <WebEventFactoryQt.h>
+#include <qwebpreferences_p.h>
using namespace WebCore;
@@ -32,12 +34,13 @@
, m_panGestureRecognizer(viewportInteractionEngine)
, m_pinchGestureRecognizer(viewportInteractionEngine)
{
+ QWebPreferencesPrivate::get(preferences())->setAttribute(QWebPreferencesPrivate::AcceleratedCompositingEnabled, true);
init();
}
PassOwnPtr<DrawingAreaProxy> QtTouchWebPageProxy::createDrawingAreaProxy()
{
- return TiledDrawingAreaProxy::create(touchViewInterface(), m_webPageProxy.get());
+ return DrawingAreaProxyImpl::create(m_webPageProxy.get());
}
void QtTouchWebPageProxy::processDidCrash()
@@ -51,6 +54,13 @@
{
}
+void QtTouchWebPageProxy::renderToCurrentGLContext(const TransformationMatrix& transform, float opacity)
+{
+ DrawingAreaProxy* drawingArea = m_webPageProxy->drawingArea();
+ if (drawingArea)
+ drawingArea->paintToCurrentGLContext(transform, opacity);
+}
+
#if ENABLE(TOUCH_EVENTS)
void QtTouchWebPageProxy::doneWithTouchEvent(const NativeWebTouchEvent& event, bool wasEventHandled)
{
@@ -81,7 +91,7 @@
void QtTouchWebPageProxy::setVisibleContentRectAndScale(const QRectF& visibleContentRect, float scale)
{
QRect alignedVisibleContentRect = visibleContentRect.toAlignedRect();
- drawingArea()->setVisibleContentRectAndScale(alignedVisibleContentRect, scale);
+ m_webPageProxy->drawingArea()->setVisibleContentsRectAndScale(alignedVisibleContentRect, scale);
// FIXME: Once we support suspend and resume, this should be delayed until the page is active if the page is suspended.
m_webPageProxy->setFixedVisibleContentRect(alignedVisibleContentRect);
@@ -89,7 +99,7 @@
void QtTouchWebPageProxy::setVisibleContentRectTrajectoryVector(const QPointF& trajectoryVector)
{
- drawingArea()->setVisibleContentRectTrajectoryVector(trajectoryVector);
+ m_webPageProxy->drawingArea()->setVisibleContentRectTrajectoryVector(trajectoryVector);
}
void QtTouchWebPageProxy::setResizesToContentsUsingLayoutSize(const QSize& targetLayoutSize)
@@ -115,5 +125,4 @@
void QtTouchWebPageProxy::renderNextFrame()
{
- drawingArea()->renderNextFrame();
}
Modified: trunk/Source/WebKit2/UIProcess/qt/QtTouchWebPageProxy.h (98705 => 98706)
--- trunk/Source/WebKit2/UIProcess/qt/QtTouchWebPageProxy.h 2011-10-28 07:39:59 UTC (rev 98705)
+++ trunk/Source/WebKit2/UIProcess/qt/QtTouchWebPageProxy.h 2011-10-28 07:59:18 UTC (rev 98706)
@@ -27,7 +27,6 @@
#include "QtPinchGestureRecognizer.h"
#include "QtTouchViewInterface.h"
#include "QtWebPageProxy.h"
-#include "TiledDrawingAreaProxy.h"
#include <wtf/PassOwnPtr.h>
namespace WebKit {
@@ -47,6 +46,7 @@
void setResizesToContentsUsingLayoutSize(const QSize& targetLayoutSize);
void findZoomableAreaForPoint(const QPoint&);
void renderNextFrame();
+ void renderToCurrentGLContext(const WebCore::TransformationMatrix&, float);
protected:
virtual void paintContent(QPainter*, const QRect& area);
@@ -59,7 +59,6 @@
#endif
QtTouchViewInterface* touchViewInterface() const { return static_cast<QtTouchViewInterface*>(m_viewInterface); }
- TiledDrawingAreaProxy* drawingArea() const { return static_cast<WebKit::TiledDrawingAreaProxy*>(m_webPageProxy->drawingArea()); }
void touchEvent(QTouchEvent*);
Modified: trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp (98705 => 98706)
--- trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp 2011-10-28 07:39:59 UTC (rev 98705)
+++ trunk/Source/WebKit2/WebProcess/WebPage/qt/LayerTreeHostQt.cpp 2011-10-28 07:59:18 UTC (rev 98706)
@@ -371,7 +371,7 @@
bool LayerTreeHost::supportsAcceleratedCompositing()
{
- return false;
+ return true;
}
#if USE(TILED_BACKING_STORE)
Modified: trunk/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp (98705 => 98706)
--- trunk/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp 2011-10-28 07:39:59 UTC (rev 98705)
+++ trunk/Source/WebKit2/WebProcess/WebPage/qt/WebPageQt.cpp 2011-10-28 07:59:18 UTC (rev 98706)
@@ -84,6 +84,10 @@
void WebPage::platformInitialize()
{
+ Settings* settings = m_page->settings();
+
+ // If accelerated compositing is enabled, we want to be in force-compositing mode, so that we don't switch between composited/non-composited state.
+ settings->setForceCompositingMode(true);
}
void WebPage::platformPreferencesDidChange(const WebPreferencesStore&)
Modified: trunk/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp (98705 => 98706)
--- trunk/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp 2011-10-28 07:39:59 UTC (rev 98705)
+++ trunk/Source/WebKit2/WebProcess/qt/WebProcessMainQt.cpp 2011-10-28 07:59:18 UTC (rev 98706)
@@ -42,6 +42,10 @@
#include <MComponentData>
#endif
+#if USE(ACCELERATED_COMPOSITING)
+#include "WebGraphicsLayer.h"
+#endif
+
#ifndef NDEBUG
#if !OS(WINDOWS)
#include <unistd.h>
@@ -186,6 +190,10 @@
return 1;
}
+#if USE(ACCELERATED_COMPOSITING)
+ WebGraphicsLayer::initFactory();
+#endif
+
WebKit::WebProcess::shared().initialize(identifier, RunLoop::main());
RunLoop::run();