From ad0d549d4cc13433f77c1ac8f0ab379c83d93f28 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Fri, 24 Feb 2012 16:36:50 +0100 Subject: Imported WebKit commit bb52bf3c0119e8a128cd93afe5572413a8617de9 (http://svn.webkit.org/repository/webkit/trunk@108790) --- Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp | 74 +++++------------------ 1 file changed, 14 insertions(+), 60 deletions(-) (limited to 'Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp') diff --git a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp index 22c6703c4..d164a6b85 100644 --- a/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp +++ b/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp @@ -29,6 +29,7 @@ #include #include #include +#include QQuickWebPage::QQuickWebPage(QQuickWebView* viewportItem) : QQuickItem(viewportItem) @@ -97,7 +98,7 @@ void QQuickWebPagePrivate::paintToCurrentGLContext() transform.scale(contentsScale, contentsScale); float opacity = computeEffectiveOpacity(q); - QRectF clipRect = q->parentItem()->mapRectToScene(q->parentItem()->boundingRect()); + QRectF clipRect = viewportItem->mapRectToScene(viewportItem->boundingRect()); if (!clipRect.isValid()) return; @@ -109,57 +110,22 @@ void QQuickWebPagePrivate::paintToCurrentGLContext() drawingArea->paintToCurrentGLContext(transform, opacity, clipRect); } -struct PageProxyMaterial; -struct PageProxyNode; - -// FIXME: temporary until Qt Scenegraph will support custom painting. -struct PageProxyMaterialShader : public QSGMaterialShader { - virtual void updateState(const RenderState& state, QSGMaterial* newMaterial, QSGMaterial* oldMaterial); - virtual char const* const* attributeNames() const - { - static char const* const attr[] = { "vertex", 0 }; - return attr; - } - - // vertexShader and fragmentShader are no-op shaders. - // All real painting is gone by TextureMapper through LayerTreeHostProxy. - virtual const char* vertexShader() const - { - return "attribute highp vec4 vertex; \n" - "void main() { gl_Position = vertex; }"; - } - - virtual const char* fragmentShader() const - { - return "void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); }"; - } -}; - -struct PageProxyMaterial : public QSGMaterial { - PageProxyMaterial(PageProxyNode* node) : m_node(node) { } - - QSGMaterialType* type() const +struct PageProxyNode : public QSGRenderNode { + PageProxyNode(QQuickWebPagePrivate* page) + : m_pagePrivate(page) { - static QSGMaterialType type; - return &type; } - QSGMaterialShader* createShader() const + virtual StateFlags changedStates() { - return new PageProxyMaterialShader; + return StateFlags(DepthState) | StencilState | ScissorState | ColorState | BlendState + | CullState | ViewportState; } - PageProxyNode* m_node; -}; - -struct PageProxyNode : public QSGGeometryNode { - PageProxyNode(QQuickWebPagePrivate* page) : - m_pagePrivate(page) - , m_material(this) - , m_geometry(QSGGeometry::defaultAttributes_Point2D(), 4) + virtual void render(const RenderState &) { - setGeometry(&m_geometry); - setMaterial(&m_material); + if (m_pagePrivate) + m_pagePrivate->paintToCurrentGLContext(); } ~PageProxyNode() @@ -169,22 +135,8 @@ struct PageProxyNode : public QSGGeometryNode { } QQuickWebPagePrivate* m_pagePrivate; - PageProxyMaterial m_material; - QSGGeometry m_geometry; }; -void PageProxyMaterialShader::updateState(const RenderState& state, QSGMaterial* newMaterial, QSGMaterial* oldMaterial) -{ - if (!newMaterial) - return; - - PageProxyNode* node = static_cast(newMaterial)->m_node; - // FIXME: Normally we wouldn't paint inside QSGMaterialShader::updateState, - // but this is a temporary hack until custom paint nodes are available. - if (node->m_pagePrivate) - node->m_pagePrivate->paintToCurrentGLContext(); -} - QSGNode* QQuickWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*) { if (!(flags() & ItemHasContents)) { @@ -242,13 +194,15 @@ QTransform QQuickWebPage::transformFromItem() const QTransform QQuickWebPage::transformToItem() const { - return QTransform(d->contentsScale, 0, 0, 0, d->contentsScale, 0, x(), y(), 1); + QPointF pos = d->viewportItem->pageItemPos(); + return QTransform(d->contentsScale, 0, 0, 0, d->contentsScale, 0, pos.x(), pos.y(), 1); } void QQuickWebPagePrivate::updateSize() { QSizeF scaledSize = contentsSize * contentsScale; q->setSize(scaledSize); + viewportItem->updateContentsSize(scaledSize); } void QQuickWebPagePrivate::resetPaintNode() -- cgit v1.2.1