summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-02-24 16:36:50 +0100
committerSimon Hausmann <simon.hausmann@nokia.com>2012-02-24 16:36:50 +0100
commitad0d549d4cc13433f77c1ac8f0ab379c83d93f28 (patch)
treeb34b0daceb7c8e7fdde4b4ec43650ab7caadb0a9 /Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
parent03e12282df9aa1e1fb05a8b90f1cfc2e08764cec (diff)
downloadqtwebkit-ad0d549d4cc13433f77c1ac8f0ab379c83d93f28.tar.gz
Imported WebKit commit bb52bf3c0119e8a128cd93afe5572413a8617de9 (http://svn.webkit.org/repository/webkit/trunk@108790)
Diffstat (limited to 'Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp')
-rw-r--r--Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp74
1 files changed, 14 insertions, 60 deletions
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 <QtQuick/QQuickCanvas>
#include <QtQuick/QSGGeometryNode>
#include <QtQuick/QSGMaterial>
+#include <private/qsgrendernode_p.h>
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<PageProxyMaterial*>(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()