Beispiel #1
0
QSGNode* QQuickWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*)
{
    QQuickWebViewPrivate* webViewPrivate = QQuickWebViewPrivate::get(d->viewportItem);

    WebCore::CoordinatedGraphicsScene* scene = webViewPrivate->coordinatedGraphicsScene();
    if (!scene)
        return oldNode;

    QtWebPageSGNode* node = static_cast<QtWebPageSGNode*>(oldNode);

    const QWindow* window = this->window();
    ASSERT(window);

    if (window && webViewPrivate->deviceScaleFactor() != window->devicePixelRatio()) {
        webViewPrivate->setIntrinsicDeviceScaleFactor(window->devicePixelRatio());
        // This signal is queued since if we are running a threaded renderer. This might cause failures
        // if tests are reading the new value between the property change and the signal emission.
        emit d->viewportItem->experimental()->test()->devicePixelRatioChanged();
    }

    if (!node)
        node = new QtWebPageSGNode;

    node->setCoordinatedGraphicsScene(scene);

    node->setScale(d->contentsScale);
    node->setDevicePixelRatio(window->devicePixelRatio());
    QColor backgroundColor = webViewPrivate->transparentBackground() ? Qt::transparent : Qt::white;
    QRectF backgroundRect(QPointF(0, 0), d->contentsSize);
    node->setBackground(backgroundRect, backgroundColor);

    return node;
}
Beispiel #2
0
QSGNode* QQuickWebPage::updatePaintNode(QSGNode* oldNode, UpdatePaintNodeData*)
{
    if (!d->webPageProxy->drawingArea())
        return oldNode;

    LayerTreeHostProxy* layerTreeHostProxy = d->webPageProxy->drawingArea()->layerTreeHostProxy();
    WebLayerTreeRenderer* renderer = layerTreeHostProxy->layerTreeRenderer();

    QtWebPageSGNode* node = static_cast<QtWebPageSGNode*>(oldNode);
    if (!node)
        node = new QtWebPageSGNode();
    node->setRenderer(renderer);
    renderer->syncRemoteContent();

    node->setScale(d->contentsScale);
    QColor backgroundColor = d->webPageProxy->drawsTransparentBackground() ? Qt::transparent : Qt::white;
    QRectF backgroundRect(QPointF(0, 0), d->contentsSize);
    node->setBackground(backgroundRect, backgroundColor);

    return node;
}