Changeset 101683 in webkit
- Timestamp:
- Dec 1, 2011 10:02:20 AM (12 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r101680 r101683 1 2011-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 1 35 2011-12-01 Nayan Kumar K <nayankk@motorola.com> 2 36 -
trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage.cpp
r101165 r101683 28 28 #include "qquickwebview_p.h" 29 29 #include <QtCore/QUrl> 30 #include <QtDeclarative/QSGGeometryNode> 30 31 #include <QtDeclarative/QQuickCanvas> 32 #include <QtDeclarative/QSGMaterial> 31 33 32 34 QQuickWebPage::QQuickWebPage(QQuickItem* parent) … … 39 41 // is always where rendering starts. 40 42 setTransformOrigin(TopLeft); 41 d->initializeSceneGraphConnections();42 43 } 43 44 … … 159 160 } 160 161 161 void QQuickWebPage::itemChange(ItemChange change, const ItemChangeData& data)162 {163 if (change == ItemSceneChange)164 d->initializeSceneGraphConnections();165 QQuickItem::itemChange(change, data);166 }167 168 162 QQuickWebPagePrivate::QQuickWebPagePrivate(QQuickWebPage* view) 169 163 : q(view) … … 171 165 , sgUpdateQueue(view) 172 166 , 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 { 184 169 } 185 170 … … 234 219 } 235 220 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(); 221 struct PageProxyMaterial; 222 struct PageProxyNode; 223 224 // FIXME: temporary until Qt Scenegraph will support custom painting. 225 struct 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 246 struct 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 263 struct 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 284 void 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 296 QSGNode* 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 313 void QQuickWebPagePrivate::resetPaintNode() 314 { 315 m_paintNode = 0; 316 } 317 318 QQuickWebPagePrivate::~QQuickWebPagePrivate() 319 { 320 if (m_paintNode) 321 static_cast<PageProxyNode*>(m_paintNode)->m_pagePrivate = 0; 240 322 } 241 323 -
trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p.h
r101165 r101683 66 66 virtual bool event(QEvent*); 67 67 virtual void geometryChanged(const QRectF&, const QRectF&); 68 virtual void itemChange(ItemChange, const ItemChangeData&);68 virtual QSGNode* updatePaintNode(QSGNode*, UpdatePaintNodeData*); 69 69 70 70 private: 71 Q_PRIVATE_SLOT(d, void _q_onAfterSceneRender());72 73 71 QQuickWebPagePrivate* d; 74 72 friend class QQuickWebView; -
trunk/Source/WebKit2/UIProcess/API/qt/qquickwebpage_p_p.h
r101178 r101683 37 37 public: 38 38 QQuickWebPagePrivate(QQuickWebPage* view); 39 ~QQuickWebPagePrivate(); 39 40 40 41 void setPageProxy(QtWebPageProxy*); 41 42 42 void initializeSceneGraphConnections();43 44 void _q_onAfterSceneRender();45 43 void paintToCurrentGLContext(); 44 void resetPaintNode(); 46 45 47 46 QQuickWebPage* const q; … … 49 48 WebKit::QtSGUpdateQueue sgUpdateQueue; 50 49 bool paintingIsInitialized; 50 QSGNode* m_paintNode; 51 51 }; 52 52 -
trunk/Source/WebKit2/UIProcess/API/qt/tests/qquickwebview/tst_qquickwebview.cpp
r100816 r101683 50 50 51 51 void show(); 52 void showWebView(); 52 53 53 54 private: … … 240 241 } 241 242 243 void 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 242 258 void tst_QQuickWebView::scrollRequest() 243 259 { -
trunk/Source/WebKit2/UIProcess/qt/LayerTreeHostProxyQt.cpp
r101595 r101683 588 588 m_drawingAreaProxy->page()->process()->send(Messages::LayerTreeHost::RenderNextFrame(), m_drawingAreaProxy->page()->pageID()); 589 589 pushUpdateToQueue(FlushLayerChangesMessage::create()); 590 updateViewport(); 590 591 } 591 592
Note: See TracChangeset
for help on using the changeset viewer.