Changeset 101683 in webkit


Ignore:
Timestamp:
Dec 1, 2011 10:02:20 AM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[Qt] [WK2] QQuickWebView covers QML elements that should be rendered on top.
https://bugs.webkit.org/show_bug.cgi?id=73338

Patch by Viatcheslav Ostapenko <ostapenko.viatcheslav@nokia.com> on 2011-12-01
Reviewed by Noam Rosenthal.

Move painting of QQuickWebPage content from canvas afterrendering() to
QSGGeometryNode/QSGMaterial based paint node. Implementation uses QSGMaterialShader
updateState() method to draw TextureMapper graphics layers.
This is considered to be temporary until QSGNode::UserNodeType will be available.

  • UIProcess/API/qt/qquickwebpage.cpp:

(QQuickWebPage::QQuickWebPage):
(QQuickWebPagePrivate::QQuickWebPagePrivate):
(PageProxyMaterialShader::attributeNames):
(PageProxyMaterialShader::vertexShader):
(PageProxyMaterialShader::fragmentShader):
(PageProxyMaterial::PageProxyMaterial):
(PageProxyMaterial::type):
(PageProxyMaterial::createShader):
(PageProxyNode::PageProxyNode):
(PageProxyNode::~PageProxyNode):
(PageProxyMaterialShader::updateState):
(QQuickWebPage::updatePaintNode):
(QQuickWebPagePrivate::resetPaintNode):
(QQuickWebPagePrivate::~QQuickWebPagePrivate):

  • UIProcess/API/qt/qquickwebpage_p.h:
  • UIProcess/API/qt/qquickwebpage_p_p.h:
  • UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp:

(tst_QQuickWebView::showWebView):

  • UIProcess/qt/LayerTreeHostProxyQt.cpp:

(WebKit::LayerTreeHostProxy::didRenderFrame):

Location:
trunk/Source/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r101680 r101683  
     12011-12-01  Viatcheslav Ostapenko  <ostapenko.viatcheslav@nokia.com>
     2
     3        [Qt] [WK2] QQuickWebView covers QML elements that should be rendered on top.
     4        https://bugs.webkit.org/show_bug.cgi?id=73338
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        Move painting of QQuickWebPage content from canvas afterrendering() to
     9        QSGGeometryNode/QSGMaterial based paint node. Implementation uses QSGMaterialShader
     10        updateState() method to draw TextureMapper graphics layers.
     11        This is considered to be temporary until QSGNode::UserNodeType will be available.
     12
     13        * UIProcess/API/qt/qquickwebpage.cpp:
     14        (QQuickWebPage::QQuickWebPage):
     15        (QQuickWebPagePrivate::QQuickWebPagePrivate):
     16        (PageProxyMaterialShader::attributeNames):
     17        (PageProxyMaterialShader::vertexShader):
     18        (PageProxyMaterialShader::fragmentShader):
     19        (PageProxyMaterial::PageProxyMaterial):
     20        (PageProxyMaterial::type):
     21        (PageProxyMaterial::createShader):
     22        (PageProxyNode::PageProxyNode):
     23        (PageProxyNode::~PageProxyNode):
     24        (PageProxyMaterialShader::updateState):
     25        (QQuickWebPage::updatePaintNode):
     26        (QQuickWebPagePrivate::resetPaintNode):
     27        (QQuickWebPagePrivate::~QQuickWebPagePrivate):
     28        * UIProcess/API/qt/qquickwebpage_p.h:
     29        * UIProcess/API/qt/qquickwebpage_p_p.h:
     30        * UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp:
     31        (tst_QQuickWebView::showWebView):
     32        * UIProcess/qt/LayerTreeHostProxyQt.cpp:
     33        (WebKit::LayerTreeHostProxy::didRenderFrame):
     34
    1352011-12-01  Nayan Kumar K  <nayankk@motorola.com>
    236
  • trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp

    r101165 r101683  
    2828#include "qquickwebview_p.h"
    2929#include <QtCore/QUrl>
     30#include <QtDeclarative/QSGGeometryNode>
    3031#include <QtDeclarative/QQuickCanvas>
     32#include <QtDeclarative/QSGMaterial>
    3133
    3234QQuickWebPage::QQuickWebPage(QQuickItem* parent)
     
    3941    // is always where rendering starts.
    4042    setTransformOrigin(TopLeft);
    41     d->initializeSceneGraphConnections();
    4243}
    4344
     
    159160}
    160161
    161 void QQuickWebPage::itemChange(ItemChange change, const ItemChangeData& data)
    162 {
    163     if (change == ItemSceneChange)
    164         d->initializeSceneGraphConnections();
    165     QQuickItem::itemChange(change, data);
    166 }
    167 
    168162QQuickWebPagePrivate::QQuickWebPagePrivate(QQuickWebPage* view)
    169163    : q(view)
     
    171165    , sgUpdateQueue(view)
    172166    , paintingIsInitialized(false)
    173 {
    174 }
    175 
    176 void QQuickWebPagePrivate::initializeSceneGraphConnections()
    177 {
    178     if (paintingIsInitialized)
    179         return;
    180     if (!q->canvas())
    181         return;
    182     paintingIsInitialized = true;
    183     QObject::connect(q->canvas(), SIGNAL(afterRendering()), q, SLOT(_q_onAfterSceneRender()), Qt::DirectConnection);
     167    , m_paintNode(0)
     168{
    184169}
    185170
     
    234219}
    235220
    236 void QQuickWebPagePrivate::_q_onAfterSceneRender()
    237 {
    238     // TODO: Allow painting before the scene or in the middle of the scene with an FBO.
    239     paintToCurrentGLContext();
     221struct PageProxyMaterial;
     222struct PageProxyNode;
     223
     224// FIXME: temporary until Qt Scenegraph will support custom painting.
     225struct PageProxyMaterialShader : public QSGMaterialShader {
     226    virtual void updateState(const RenderState& state, QSGMaterial* newMaterial, QSGMaterial* oldMaterial);
     227    virtual char const* const* attributeNames() const
     228    {
     229        static char const* const attr[] = { 0 };
     230        return attr;
     231    }
     232
     233    // vertexShader and fragmentShader are no-op shaders.
     234    // All real painting is gone by TextureMapper through LayerTreeHostProxy.
     235    virtual const char* vertexShader() const
     236    {
     237        return "void main() { gl_Position = gl_Vertex; }";
     238    }
     239
     240    virtual const char* fragmentShader() const
     241    {
     242        return "void main() { gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0); }";
     243    }
     244};
     245
     246struct PageProxyMaterial : public QSGMaterial {
     247    PageProxyMaterial(PageProxyNode* node) : m_node(node) { }
     248
     249    QSGMaterialType* type() const
     250    {
     251        static QSGMaterialType type;
     252        return &type;
     253    }
     254
     255    QSGMaterialShader* createShader() const
     256    {
     257        return new PageProxyMaterialShader;
     258    }
     259
     260    PageProxyNode* m_node;
     261};
     262
     263struct PageProxyNode : public QSGGeometryNode {
     264    PageProxyNode(QQuickWebPagePrivate* page) :
     265        m_pagePrivate(page)
     266      , m_material(this)
     267      , m_geometry(QSGGeometry::defaultAttributes_Point2D(), 4)
     268    {
     269        setGeometry(&m_geometry);
     270        setMaterial(&m_material);
     271    }
     272
     273    ~PageProxyNode()
     274    {
     275        if (m_pagePrivate)
     276            m_pagePrivate->resetPaintNode();
     277    }
     278
     279    QQuickWebPagePrivate* m_pagePrivate;
     280    PageProxyMaterial m_material;
     281    QSGGeometry m_geometry;
     282};
     283
     284void PageProxyMaterialShader::updateState(const RenderState& state, QSGMaterial* newMaterial, QSGMaterial* oldMaterial)
     285{
     286    if (!newMaterial)
     287        return;
     288
     289    PageProxyNode* node = static_cast<PageProxyMaterial*>(newMaterial)->m_node;
     290    // FIXME: Normally we wouldn't paint inside QSGMaterialShader::updateState,
     291    // but this is a temporary hack until custom paint nodes are available.
     292    if (node->m_pagePrivate)
     293        node->m_pagePrivate->paintToCurrentGLContext();
     294}
     295
     296QSGNode* QQuickWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*)
     297{
     298    if (!(flags() & ItemHasContents)) {
     299        if (oldNode)
     300            delete oldNode;
     301        return 0;
     302    }
     303
     304    PageProxyNode* proxyNode = static_cast<PageProxyNode*>(oldNode);
     305    if (!proxyNode) {
     306        proxyNode = new PageProxyNode(d);
     307        d->m_paintNode = proxyNode;
     308    }
     309
     310    return proxyNode;
     311}
     312
     313void QQuickWebPagePrivate::resetPaintNode()
     314{
     315    m_paintNode = 0;
     316}
     317
     318QQuickWebPagePrivate::~QQuickWebPagePrivate()
     319{
     320    if (m_paintNode)
     321        static_cast<PageProxyNode*>(m_paintNode)->m_pagePrivate = 0;
    240322}
    241323
  • trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h

    r101165 r101683  
    6666    virtual bool event(QEvent*);
    6767    virtual void geometryChanged(const QRectF&, const QRectF&);
    68     virtual void itemChange(ItemChange, const ItemChangeData&);
     68    virtual QSGNode* updatePaintNode(QSGNode*, UpdatePaintNodeData*);
    6969
    7070private:
    71     Q_PRIVATE_SLOT(d, void _q_onAfterSceneRender());
    72 
    7371    QQuickWebPagePrivate* d;
    7472    friend class QQuickWebView;
  • trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h

    r101178 r101683  
    3737public:
    3838    QQuickWebPagePrivate(QQuickWebPage* view);
     39    ~QQuickWebPagePrivate();
    3940
    4041    void setPageProxy(QtWebPageProxy*);
    4142
    42     void initializeSceneGraphConnections();
    43 
    44     void _q_onAfterSceneRender();
    4543    void paintToCurrentGLContext();
     44    void resetPaintNode();
    4645
    4746    QQuickWebPage* const q;
     
    4948    WebKit::QtSGUpdateQueue sgUpdateQueue;
    5049    bool paintingIsInitialized;
     50    QSGNode* m_paintNode;
    5151};
    5252
  • trunk/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp

    r100816 r101683  
    5050
    5151    void show();
     52    void showWebView();
    5253
    5354private:
     
    240241}
    241242
     243void tst_QQuickWebView::showWebView()
     244{
     245    webView()->setSize(QSizeF(300, 400));
     246
     247    webView()->load(QUrl::fromLocalFile(QLatin1String(TESTS_SOURCE_DIR "/html/scroll.html")));
     248    QVERIFY(waitForSignal(webView(), SIGNAL(loadSucceeded())));
     249
     250    m_window->show();
     251    // This should not crash.
     252    webView()->setVisible(true);
     253    QTest::qWait(200);
     254    webView()->setVisible(false);
     255    QTest::qWait(200);
     256}
     257
    242258void tst_QQuickWebView::scrollRequest()
    243259{
  • trunk/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp

    r101595 r101683  
    588588    m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::RenderNextFrame(), m_drawingAreaProxy->page()->pageID());
    589589    pushUpdateToQueue(FlushLayerChangesMessage::create());
     590    updateViewport();
    590591}
    591592
Note: See TracChangeset for help on using the changeset viewer.