Title: [111138] trunk/Source/WebKit2
Revision
111138
Author
[email protected]
Date
2012-03-18 15:52:01 -0700 (Sun, 18 Mar 2012)

Log Message

[Qt][WK2] Avoid usage of manual scaling in the Qt scenegraph integration
https://bugs.webkit.org/show_bug.cgi?id=81368

Reviewed by Simon Hausmann.

Moved the QtScenegraph integration classes to a separate file,
QtWebPageSGNode. The nodes created for QQuickWebPage now include
a QSGTransformNode that controls the contentsScale, a
QSGSimpleRectNode that controls the background color, and a
QSGRenderNode subclass that renders the actual contents.
* Target.pri:
* UIProcess/API/qt/qquickwebpage.cpp:
(QQuickWebPage::updatePaintNode):
* UIProcess/qt/QtWebPageSGNode.cpp: Added.
* UIProcess/qt/QtWebPageSGNode.h: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (111137 => 111138)


--- trunk/Source/WebKit2/ChangeLog	2012-03-18 21:58:59 UTC (rev 111137)
+++ trunk/Source/WebKit2/ChangeLog	2012-03-18 22:52:01 UTC (rev 111138)
@@ -1,5 +1,23 @@
 2012-03-18  No'am Rosenthal  <[email protected]>
 
+        [Qt][WK2] Avoid usage of manual scaling in the Qt scenegraph integration
+        https://bugs.webkit.org/show_bug.cgi?id=81368
+
+        Reviewed by Simon Hausmann.
+
+        Moved the QtScenegraph integration classes to a separate file,
+        QtWebPageSGNode. The nodes created for QQuickWebPage now include
+        a QSGTransformNode that controls the contentsScale, a 
+        QSGSimpleRectNode that controls the background color, and a
+        QSGRenderNode subclass that renders the actual contents.
+        * Target.pri:
+        * UIProcess/API/qt/qquickwebpage.cpp:
+        (QQuickWebPage::updatePaintNode):
+        * UIProcess/qt/QtWebPageSGNode.cpp: Added.
+        * UIProcess/qt/QtWebPageSGNode.h: Added.
+
+2012-03-18  No'am Rosenthal  <[email protected]>
+
         [Qt] The background is visible for tiles inside the contents area which are not ready
         https://bugs.webkit.org/show_bug.cgi?id=81349
 

Modified: trunk/Source/WebKit2/Target.pri (111137 => 111138)


--- trunk/Source/WebKit2/Target.pri	2012-03-18 21:58:59 UTC (rev 111137)
+++ trunk/Source/WebKit2/Target.pri	2012-03-18 22:52:01 UTC (rev 111138)
@@ -273,6 +273,7 @@
     UIProcess/qt/QtPageClient.h \
     UIProcess/qt/QtWebPageLoadClient.h \
     UIProcess/qt/QtWebPagePolicyClient.h \
+    UIProcess/qt/QtWebPageSGNode.h \
     UIProcess/qt/QtWebPageUIClient.h \
     UIProcess/qt/QtFlickProvider.h \
     UIProcess/qt/QtViewportInteractionEngine.h \
@@ -608,6 +609,7 @@
     UIProcess/qt/QtPageClient.cpp \
     UIProcess/qt/QtWebPageLoadClient.cpp \
     UIProcess/qt/QtWebPagePolicyClient.cpp \
+    UIProcess/qt/QtWebPageSGNode.cpp \
     UIProcess/qt/QtWebPageUIClient.cpp \
     UIProcess/qt/TextCheckerQt.cpp \
     UIProcess/qt/QtFlickProvider.cpp \

Modified: trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp (111137 => 111138)


--- trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp	2012-03-18 21:58:59 UTC (rev 111137)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp	2012-03-18 22:52:01 UTC (rev 111138)
@@ -23,16 +23,12 @@
 
 #include "LayerTreeHostProxy.h"
 #include "QtWebPageEventHandler.h"
+#include "QtWebPageSGNode.h"
 #include "TransformationMatrix.h"
 #include "WebLayerTreeRenderer.h"
 #include "qquickwebpage_p_p.h"
 #include "qquickwebview_p.h"
-#include <QPolygonF>
 #include <QtQuick/QQuickCanvas>
-#include <QtQuick/QSGGeometryNode>
-#include <QtQuick/QSGMaterial>
-#include <QtQuick/QSGSimpleRectNode>
-#include <private/qsgrendernode_p.h>
 
 QQuickWebPage::QQuickWebPage(QQuickWebView* viewportItem)
     : QQuickItem(viewportItem)
@@ -81,108 +77,6 @@
         webPageProxy->drawingArea()->paintLayerTree(painter);
 }
 
-class ContentsSGNode : public QSGRenderNode {
-public:
-    ContentsSGNode(PassRefPtr<WebLayerTreeRenderer> renderer)
-        : m_renderer(renderer)
-        , m_scale(1)
-    {
-    }
-
-    virtual StateFlags changedStates()
-    {
-        return StateFlags(StencilState) | ColorState | BlendState;
-    }
-
-    virtual void render(const RenderState&)
-    {
-        QMatrix4x4 renderMatrix = matrix() ? *matrix() : QMatrix4x4();
-
-        // Have to apply render scale manualy because it is not applied on page item.
-        // http://trac.webkit.org/changeset/104450
-        renderMatrix.scale(m_scale);
-
-        // FIXME: Support non-rectangular clippings.
-        layerTreeRenderer()->paintToCurrentGLContext(renderMatrix, inheritedOpacity(), clipRect());
-    }
-
-    ~ContentsSGNode()
-    {
-        layerTreeRenderer()->purgeGLResources();
-    }
-
-    WebLayerTreeRenderer* layerTreeRenderer() const { return m_renderer.get(); }
-    void setScale(float scale) { m_scale = scale; }
-
-private:
-    QRectF clipRect() const
-    {
-        // Start with an invalid rect.
-        QRectF resultRect(0, 0, -1, -1);
-
-        for (const QSGClipNode* clip = clipList(); clip; clip = clip->clipList()) {
-            QMatrix4x4 clipMatrix;
-            if (clip->matrix())
-                clipMatrix = *clip->matrix();
-            QRectF currentClip;
-
-            if (clip->isRectangular())
-                currentClip = clipMatrix.mapRect(clip->clipRect());
-            else {
-                const QSGGeometry* geometry = clip->geometry();
-                // Assume here that clipNode has only coordinate data.
-                const QSGGeometry::Point2D* geometryPoints = geometry->vertexDataAsPoint2D();
-
-                // Clip region should be at least triangle to make valid clip.
-                if (geometry->vertexCount() < 3)
-                    continue;
-
-                QPolygonF polygon;
-
-                for (int i = 0; i < geometry->vertexCount(); i++)
-                    polygon.append(clipMatrix.map(QPoint(geometryPoints[i].x, geometryPoints[i].y)));
-                currentClip = polygon.boundingRect();
-            }
-
-            if (currentClip.isEmpty())
-                continue;
-
-            if (resultRect.isValid())
-                resultRect &= currentClip;
-            else
-                resultRect = currentClip;
-        }
-
-        return resultRect;
-    }
-
-    RefPtr<WebLayerTreeRenderer> m_renderer;
-    float m_scale;
-};
-
-class BackgroundSGNode : public QSGSimpleRectNode {
-public:
-    BackgroundSGNode()
-        : m_contentsNode(0)
-    {
-    }
-
-    ContentsSGNode* contentsNode(PassRefPtr<WebLayerTreeRenderer> renderer)
-    {
-        if (m_contentsNode && m_contentsNode->layerTreeRenderer() == renderer)
-            return m_contentsNode;
-
-        delete m_contentsNode;
-
-        m_contentsNode = new ContentsSGNode(renderer);
-        appendChildNode(m_contentsNode);
-        return m_contentsNode;
-    }
-
-private:
-    ContentsSGNode* m_contentsNode;
-};
-
 QSGNode* QQuickWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*)
 {
     if (!d->webPageProxy->drawingArea())
@@ -191,20 +85,18 @@
     LayerTreeHostProxy* layerTreeHostProxy = d->webPageProxy->drawingArea()->layerTreeHostProxy();
     WebLayerTreeRenderer* renderer = layerTreeHostProxy->layerTreeRenderer();
 
-    BackgroundSGNode* backgroundNode = static_cast<BackgroundSGNode*>(oldNode);
-    if (!backgroundNode)
-        backgroundNode = new BackgroundSGNode();
-    ContentsSGNode* contentsNode = backgroundNode->contentsNode(renderer);
+    QtWebPageSGNode* node = static_cast<QtWebPageSGNode*>(oldNode);
+    if (!node)
+        node = new QtWebPageSGNode();
+    node->setRenderer(renderer);
     renderer->syncRemoteContent();
 
-    contentsNode->setScale(d->contentsScale);
-
+    node->setScale(d->contentsScale);
     QColor backgroundColor = d->webPageProxy->drawsTransparentBackground() ? Qt::transparent : Qt::white;
-    QRectF backgroundRect(0, 0, d->contentsSize.width() * d->contentsScale, d->contentsSize.height() * d->contentsScale);
-    backgroundNode->setColor(backgroundColor);
-    backgroundNode->setRect(backgroundRect);
+    QRectF backgroundRect(QPointF(0, 0), d->contentsSize);
+    node->setBackground(backgroundRect, backgroundColor);
 
-    return backgroundNode;
+    return node;
 }
 
 QtWebPageEventHandler* QQuickWebPage::eventHandler() const

Added: trunk/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp (0 => 111138)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.cpp	2012-03-18 22:52:01 UTC (rev 111138)
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "QtWebPageSGNode.h"
+
+#include "WebLayerTreeRenderer.h"
+#include <QtGui/QPolygonF>
+#include <QtQuick/QSGSimpleRectNode>
+#include <private/qsgrendernode_p.h>
+
+namespace WebKit {
+
+class ContentsSGNode : public QSGRenderNode {
+public:
+    ContentsSGNode(PassRefPtr<WebLayerTreeRenderer> renderer)
+        : m_renderer(renderer)
+    {
+    }
+
+    virtual StateFlags changedStates()
+    {
+        return StateFlags(StencilState) | ColorState | BlendState;
+    }
+
+    virtual void render(const RenderState&)
+    {
+        QMatrix4x4 renderMatrix = matrix() ? *matrix() : QMatrix4x4();
+
+        // FIXME: Support non-rectangular clippings.
+        layerTreeRenderer()->paintToCurrentGLContext(renderMatrix, inheritedOpacity(), clipRect());
+    }
+
+    ~ContentsSGNode()
+    {
+        layerTreeRenderer()->purgeGLResources();
+    }
+
+    WebLayerTreeRenderer* layerTreeRenderer() const { return m_renderer.get(); }
+
+private:
+    QRectF clipRect() const
+    {
+        // Start with an invalid rect.
+        QRectF resultRect(0, 0, -1, -1);
+
+        for (const QSGClipNode* clip = clipList(); clip; clip = clip->clipList()) {
+            QMatrix4x4 clipMatrix;
+            if (clip->matrix())
+                clipMatrix = *clip->matrix();
+            QRectF currentClip;
+
+            if (clip->isRectangular())
+                currentClip = clipMatrix.mapRect(clip->clipRect());
+            else {
+                const QSGGeometry* geometry = clip->geometry();
+                // Assume here that clipNode has only coordinate data.
+                const QSGGeometry::Point2D* geometryPoints = geometry->vertexDataAsPoint2D();
+
+                // Clip region should be at least triangle to make valid clip.
+                if (geometry->vertexCount() < 3)
+                    continue;
+
+                QPolygonF polygon;
+
+                for (int i = 0; i < geometry->vertexCount(); i++)
+                    polygon.append(clipMatrix.map(QPoint(geometryPoints[i].x, geometryPoints[i].y)));
+                currentClip = polygon.boundingRect();
+            }
+
+            if (currentClip.isEmpty())
+                continue;
+
+            if (resultRect.isValid())
+                resultRect &= currentClip;
+            else
+                resultRect = currentClip;
+        }
+
+        return resultRect;
+    }
+
+    RefPtr<WebLayerTreeRenderer> m_renderer;
+};
+
+QtWebPageSGNode::QtWebPageSGNode()
+    : m_contentsNode(0)
+    , m_backgroundNode(new QSGSimpleRectNode)
+{
+    appendChildNode(m_backgroundNode);
+}
+
+void QtWebPageSGNode::setBackground(const QRectF& rect, const QColor& color)
+{
+    m_backgroundNode->setRect(rect);
+    m_backgroundNode->setColor(color);
+}
+
+void QtWebPageSGNode::setScale(float scale)
+{
+    QMatrix4x4 matrix;
+    matrix.scale(scale);
+    setMatrix(matrix);
+}
+
+void QtWebPageSGNode::setRenderer(PassRefPtr<WebLayerTreeRenderer> renderer)
+{
+    if (m_contentsNode && m_contentsNode->layerTreeRenderer() == renderer)
+        return;
+
+    delete m_contentsNode;
+    m_contentsNode = new ContentsSGNode(renderer);
+    appendChildNode(m_contentsNode);
+}
+
+}

Added: trunk/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h (0 => 111138)


--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h	                        (rev 0)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageSGNode.h	2012-03-18 22:52:01 UTC (rev 111138)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this program; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef QtWebPageSGNode_h
+#define QtWebPageSGNode_h
+
+#include "PassRefPtr.h"
+#include <QtQuick/QSGTransformNode>
+class QSGSimpleRectNode;
+
+namespace WebKit {
+
+class ContentsSGNode;
+class WebLayerTreeRenderer;
+
+class QtWebPageSGNode : public QSGTransformNode {
+    public:
+        QtWebPageSGNode();
+        void setBackground(const QRectF&, const QColor&);
+        void setScale(float);
+        void setRenderer(PassRefPtr<WebLayerTreeRenderer>);
+
+    private:
+        ContentsSGNode* m_contentsNode;
+        QSGSimpleRectNode* m_backgroundNode;
+    };
+}
+
+#endif /* QtWebPageSGNode_h */
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to